createOneDevice static method
Future
createOneDevice(
- Device device
)
Implementation
static Future createOneDevice(Device device) async {
final channel = await Channel.getOpenIoTHubChannel();
final stub = CommonDeviceManagerClient(channel);
final response = await stub.addDevice(device);
print('Greeter client received: ${response}');
channel.shutdown();
//服务器同步
HostInfo hostInfo = HostInfo();
hostInfo.uUID = device.uuid;
hostInfo.name = device.name;
hostInfo.description = device.description;
hostInfo.gatewayUUID = device.runId;
hostInfo.hostAddr = device.addr;
hostInfo.mac = device.mac;
HostManager.AddHost(hostInfo);
}