Open Platform
Skip to content

Gateway ​

init gateway ​

1.scan gateway (only in setting mode gateway can be discovered) ​
c
GatewayClient.getDefault().startScanGateway(new ScanGatewayCallback() {
    @Override
    public void onScanGatewaySuccess(ExtendedBluetoothDevice device) {
 
    }
 
    @Override
    public void onScanFailed(int errorCode) {
 
    }
});
2.connect gateway ​
c
GatewayClient.getDefault().connectGateway(item, new ConnectCallback() {
   @Override
   public void onConnectSuccess(ExtendedBluetoothDevice device) {
        
   }
   @Override
   public void onDisconnected() {
        
   }
}
3.config wifi and nickname for gateway and do init by bluetooth ​
c
configureGatewayInfo.uid = MyApplication.getmInstance().getAccountInfo().getUid();
configureGatewayInfo.userPwd = MyApplication.getmInstance().getAccountInfo().getMd5Pwd();
 
configureGatewayInfo.ssid = binding.wifiName.getText().toString().trim();
 
configureGatewayInfo.wifiPwd = binding.wifiPwd.getText().toString().trim();
 
configureGatewayInfo.plugName = device.getAddress();
 
GatewayClient.getDefault().initGateway(configureGatewayInfo, new InitGatewayCallback() {
    @Override
    public void onInitGatewaySuccess(DeviceInfo deviceInfo) {
        LogUtil.d("gateway init success");
        isInitSuccess(deviceInfo);
    }
 
    @Override
    public void onFail(GatewayError error) {
 
    }
});
4.Request cloud API:Query the init status of the gateway to confirm gateway is added success ​
5.Request cloud API: Upload detail info of gateway to upload gateway info to server ​
CopyRight © 2012-2026 Sciener.All Rights Reserved