static internal void DoDemo(int numDevices) { Program.IODir += "MultiDevice/"; CertMaker m = new CertMaker(Program.IODir); IoTDevice[] deviceList = new IoTDevice[numDevices]; HubController = new HubControl(); // make the devices and enroll them in the hub for (int j = 0; j < numDevices; j++) { string devId = GetDeviceID(j); Program.SetDeviceNumber(j); int fwidSeed = 0; m.MakeNew(5, false, fwidSeed); HubController.Connect(); HubController.RemoveDevice(devId); var devInfo = ExtensionDecoder.Decode(Program.ToPath(Program.AliasCert)); HubController.EnrollDevice(devId, fwidSeed, Helpers.Hexify(devInfo.FirmwareID), devInfo.Cert.Thumbprint); IoTDevice device = new IoTDevice(devId, 0, j); deviceList[j] = device; } // run through messaging and update bool[] primaryOrSEcondary = new bool[numDevices]; int epoch = 0; while (true) { for (int j = 0; j < numDevices; j++) { Program.SetDeviceNumber(j); var device = deviceList[j]; string devId = GetDeviceID(j); // send messages using current firmware device.RefreshCert(); device.SendMessages(1, 30); if (device.FirmwareUpdateNeeded) { // update the firmware on the device int fwidSeed = device.DesiredFwVersionNumber; m.MakeAliasCert(true, fwidSeed); var devInfo = ExtensionDecoder.Decode(Program.ToPath(Program.AliasCert)); // and tell the hub HubController.RefreshDevice(devId, fwidSeed, Helpers.Hexify(devInfo.FirmwareID), devInfo.Cert.Thumbprint, primaryOrSEcondary[j]); primaryOrSEcondary[j] = !primaryOrSEcondary[j]; device.CurrentFwVersionNumber = fwidSeed; } } Debug.WriteLine($"Epoch == {epoch++}"); } }
internal UpdateDemo() { HubController = new HubControl(); HubController.Connect(); HubController.RemoveAllDevices(); }