Gateway
Note:The gateway broadcasts data only during the first 60 seconds of power
1.Scan
c
[TTGateway startScanGatewayWithBlock:^(TTGatewayScanModel *model) {
}];2.Connect
c
[TTGateway connectGatewayWithGatewayMac:gatewayMac block:^(TTGatewayConnectStatus connectStatus) {
if (connectStatus == TTGatewayConnectSuccess) {
//The gateway automatically disconnects the application after 180 seconds
[TTGateway stopScanGateway];
[TTGateway scanWiFiByGatewayWithBlock:^(BOOL isFinished, NSArray *WiFiArr, TTGatewayStatus status) {
}
}
}];3.Get the network near the gateway
c
[TTGateway scanWiFiByGatewayWithBlock:^(BOOL isFinished, NSArray *WiFiArr, TTGatewayStatus status) {
if (status == TTGatewayNotConnect || status == TTGatewayDisconnect ) {
//connect gateway again
return ;
}
if (WiFiArr.count > 0) {
NSMutableArray *arr = [NSMutableArray arrayWithArray:WiFiArr];
if (isFinished == YES) {
}
}
}];4.Init gateway
c
//Parameters
NSMutableDictionary *dict = [NSMutableDictionary new];
dict[@"SSID"] = wifi;
dict[@"wifiPwd"] = wifiPassword;
dict[@"uid"] = userID;
dict[@"userPwd"] = userPassword;
dict[@"gatewayName"]= @"name";
dict[@"gatewayVersion"]= @2; //@2 means G2,@3 means G3,@4 means G4
[TTGateway initializeGatewayWithInfoDic:dict block:^(TTSystemInfoModel *systemInfoModel, TTGatewayStatus status) {
if (status == TTGatewayNotConnect || status == TTGatewayDisconnect) {
//Please re-power the gateway
return ;
}
if (status == TTGatewaySuccess) {
[TTGateway disconnectGatewayWithGatewayMac:self.gatewayMac block:nil];
[self isUploadSuccess:systemInfoModel];
return;
}
if (status == TTGatewayWrongSSID) {
[self.view showToast:LS(@"WiFi name error")];
return;
}
if (status == TTGatewayWrongSSID) {
[self.view showToast:LS(@"WiFi password error")];
return;
}
[self.view showToast:LS(@"Failure")];
}];