V0.7.2 Arroyo Toad
Added support to toggle sensors
This commit is contained in:
@@ -58,8 +58,22 @@ import MessageUtils
|
||||
privateKey: privateKey
|
||||
)
|
||||
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev)
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev2)
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev, success: { msg in
|
||||
print(msg)
|
||||
let _signedMessage = try! deserializeV1(serializedData: msg)
|
||||
print(_signedMessage.toString())
|
||||
},
|
||||
failure: {
|
||||
print("Something went wrong")
|
||||
})
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev2, success: { msg in
|
||||
print(msg)
|
||||
let _signedMessage = try! deserializeV1(serializedData: msg)
|
||||
print(_signedMessage.toString())
|
||||
},
|
||||
failure: {
|
||||
print("Something went wrong")
|
||||
})
|
||||
|
||||
sleep(15)
|
||||
|
||||
@@ -102,7 +116,18 @@ import MessageUtils
|
||||
privateKey: privateKey
|
||||
)
|
||||
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev)
|
||||
try IoTSimulatorCore.addDevice(
|
||||
location: "Delta",
|
||||
device: dev,
|
||||
success: { msg in
|
||||
print(msg)
|
||||
let _signedMessage = try! deserializeV1(serializedData: msg)
|
||||
print(_signedMessage.toString())
|
||||
},
|
||||
failure: {
|
||||
print("Something went wrong")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
let _sleep = 15
|
||||
@@ -116,3 +141,65 @@ import MessageUtils
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Test func stressLoop2() async throws {
|
||||
|
||||
let devices: UInt128 = 1
|
||||
|
||||
let env = PhysicalEnvironment("Delta")
|
||||
let truth = PhysicalData(.Temperature, 22)
|
||||
|
||||
env.setPhysicalData(DataType.Temperature, truth)
|
||||
|
||||
IoTSimulatorCore.addEnv(environment: env)
|
||||
|
||||
let signKeyPath = "./Private/privateKey.pem"
|
||||
|
||||
let privateKey = try pem2_P256key(filePath: signKeyPath)
|
||||
|
||||
for i: UInt128 in 0..<devices {
|
||||
|
||||
let dev: EdgeDevice = EdgeDevice(
|
||||
deviceID: i,
|
||||
dataType: .Temperature,
|
||||
disconnected: false,
|
||||
location: Location(x: 20, y: 10, z: 0),
|
||||
dutyCicle: 200 + UInt.random(in: 200...1000),
|
||||
sensors: [
|
||||
0: RealSensor(
|
||||
sensorID: 0, sensorType: .Temperature, faulty: false, meanNoise: 1, stdNoise: 3,
|
||||
quantizationBits: 3),
|
||||
1: RealSensor(
|
||||
sensorID: 1, sensorType: .Temperature, faulty: false, meanNoise: 1, stdNoise: 3,
|
||||
quantizationBits: 3),
|
||||
2: RealSensor(
|
||||
sensorID: 2, sensorType: .Temperature, faulty: false, meanNoise: 1, stdNoise: 3,
|
||||
quantizationBits: 3),
|
||||
],
|
||||
privateKey: privateKey
|
||||
)
|
||||
|
||||
try IoTSimulatorCore.addDevice(location: "Delta", device: dev, success: { msg in
|
||||
print(msg)
|
||||
let _signedMessage = try! deserializeV1(serializedData: msg)
|
||||
print(_signedMessage.toString())
|
||||
},
|
||||
failure: {
|
||||
print("Something went wrong")
|
||||
})
|
||||
}
|
||||
|
||||
let _sleep = 15
|
||||
|
||||
for i in 0..<_sleep {
|
||||
print("Hi, at \(i)s\n\n")
|
||||
sleep(1)
|
||||
|
||||
IoTSimulatorCore.toggleSensor(devID: 0, sensorID: 0)
|
||||
|
||||
}
|
||||
print("NUKE EM ALLLLLLLLLL!!!!!\n\n")
|
||||
IoTSimulatorCore.nukeAll()
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user