|
APP发送控制指令虚拟设备不响应
发送指令的回调会被调用,但是,回调的结果不对
- @Override
- public void didReceiveData(XPGWifiDevice device,
- ConcurrentHashMap<String, Object> dataMap,
- int result){
- 。。。
- }
复制代码 如上所示,回调函数的3个参数里面,dataMap为空,result值为-20
经查API,-20对应的错误代码为
- public static final int XPGWifiError_INVALID_PARAM -20
复制代码 但是,我发送数据的格式
- int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
复制代码 跟IOE Demo发送数据的格式
- int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
复制代码 是完全一样的
但是,IOE Demo发送的控制指令虚拟设备完全能够正常响应
另,虚拟设备推送的数据也无法正常接收,接收到的结果值为213,我不知道这个213代表什么,我也不知道这是不是代表接收成功,但是日志的确没有像正常接收数据那样打印接收到的json格式的数据包
下面附上程序运行日志,各位大大帮帮忙看看我的问题出在哪里
- 84 matches in 83 lines for "22717" in buffer: log.txt
- 7:E/dalvikvm(22717): could not disable core file generation for pid 22717: Operation not permitted
- 39:W/xpgc (22717): 11:31:16 succeed output log to file:/sdcard/XpgAirCondition.log
- 41:W/linker (22717): library "libmaliinstr.so" not found
- 43:W/linker (22717): error:
- 47:W/xpgc (22717): 11:31:18 running gethostbyname(): api.gizwits.com
- 51:W/xpgc (22717): 11:31:18 gethostbyname api.gizwits.com success: 182.254.227.66
- 53:W/xpgc (22717): 11:31:18 running connect()
- 55:I/xpgc (22717): 11:31:18 connect to 182.254.227.66, port 80 success, fd 77
- 57:I/xpgc (22717):
- 59:W/xpgc (22717): 11:31:18 Send http head: POST /app/login HTTP/1.1
- 62:W/xpgc (22717): language: zh-CN
- 65:W/xpgc (22717): User-Agent: XPGWiFiSDK (v1.3.0.15082322)
- 68:W/xpgc (22717): Host: api.gizwits.com:80
- 71:W/xpgc (22717): Connection: keep-alive
- 74:W/xpgc (22717): Content-Type: application/json
- 77:W/xpgc (22717): X-Gizwits-Application-Id: 1837bd3c335f409ba6dba16b8dd5747c
- 80:W/xpgc (22717): Content-Length: 48
- 83:W/xpgc (22717):
- 86:W/xpgc (22717):
- 88:W/xpgc (22717):
- 90:W/xpgc (22717): 11:31:18 Send http body: {"username":"15077884905","password":"12345678"}
- 92:W/xpgc (22717):
- 94:I/xpgc (22717): 11:31:18 Http Content-Length or first ChunckedSize: 113
- 96:I/xpgc (22717):
- 98:W/xpgc (22717): 11:31:18 User 15077884905 login success, uid:404884c5a668434ebb552e15143a4e55, token:0e7f3a6434484597885885b0246daf71, expire_at:1441423879
- 100:I/xpgc (22717): 11:31:18 _recvThread() httpStruct = 0x772e5298 type = 6
- 102:I/xpgc (22717):
- 104:I/XPGWifiSDK(22717): Success callback didUserLogin, XPGWifiSDKListener != null
- 106:W/xpgc (22717): 11:31:18 Success Callback in>>> static void GWifiSDK::onUserLoginResp(UserLoginResp_t*) (error:0, errorMessage:)
- 108:W/xpgc (22717): 11:31:18 [_XPGWifiSDK.cpp][2061] bool GWifiSDK::DiscoverDevices(): udp package send success
- 110:W/xpgc (22717): 11:31:18 running gethostbyname(): api.gizwits.com
- 114:W/xpgc (22717): 11:31:18 gethostbyname api.gizwits.com success: 182.254.227.66
- 116:W/xpgc (22717): 11:31:18 running connect()
- 118:I/xpgc (22717): 11:31:18 connect to 182.254.227.66, port 80 success, fd 77
- 120:I/xpgc (22717):
- 122:W/xpgc (22717): 11:31:18 Send http head: GET /app/bindings?show_disabled=0&limit=10000&skip=0 HTTP/1.1
- 125:W/xpgc (22717): language: zh-CN
- 128:W/xpgc (22717): User-Agent: XPGWiFiSDK (v1.3.0.15082322)
- 131:W/xpgc (22717): Host: api.gizwits.com:80
- 134:W/xpgc (22717): Connection: keep-alive
- 137:W/xpgc (22717): Content-Type: application/json
- 140:W/xpgc (22717): X-Gizwits-Application-Id: 1837bd3c335f409ba6dba16b8dd5747c
- 143:W/xpgc (22717): X-Gizwits-User-token: 0e7f3a6434484597885885b0246daf71
- 146:W/xpgc (22717): Content-Length: 0
- 149:W/xpgc (22717):
- 152:W/xpgc (22717):
- 154:W/xpgc (22717):
- 156:W/xpgc (22717): 11:31:18 Send http body: (null)
- 158:W/xpgc (22717):
- 162:I/xpgc (22717): 11:31:18 Http Content-Length or first ChunckedSize: 309
- 164:I/xpgc (22717):
- 166:W/xpgc (22717): 11:31:18 Http response: {"devices": [{"is_disabled": false, "mac": "virtual:site", "is_online": true, "host": "sandbox.gizwits.com", "port": 1883, "remark": "", "did": "i6wbbMacUrBursbzysga5i", "wifi_soft_version": null, "product_key": "03a1c94f1e35439da9341c9dd228e9fa", "is_sandbox": true, "passcode": "123456", "type": "normal"}]}
- 168:W/xpgc (22717):
- 170:W/xpgc (22717): 11:31:18 Get 1 devices from api.gizwits.com success
- 172:I/xpgc (22717): 11:31:18 _recvThread() httpStruct = 0x77362ef8 type = 14
- 174:I/xpgc (22717):
- 176:W/xpgc (22717): 11:31:18 Success Callback in>>> static void GWifiSDK::onGetBoundDeviesResp(GetBoundDevicesResp_t*) (error:0, errorMessage:)
- 178:I/xpgc (22717): 11:31:18 static void GWifiSDK::onGetBoundDeviesResp(GetBoundDevicesResp_t*): Start UnBindAllDevices
- 180:I/xpgc (22717): 11:31:18 static void GWifiSDK::onGetBoundDeviesResp(GetBoundDevicesResp_t*): End UnBindAllDevices
- 182:W/xpgc (22717): 11:31:18 bool GWifiDevice::IsBind(char const*)():760, device VIRTUAL:SITE is not bind to uid 404884c5a668434ebb552e15143a4e55, because the cache uid is empty.
- 184:I/xpgc (22717): 11:31:18 void GWifiSDK::MergeBindDevicesToTempDevices(): first, callback with bind list info.
- 186:I/xpgc (22717): 11:31:18 void GWifiSDK::DiscoverCallback(int): ==> try to push device[1] mac:VIRTUAL:SITE, did:i6wbbMacUrBursbzysga5i, isLan:0, isOnline:1, isLogined:0, ip:, passcode: 123456 into devicelist
- 188:I/XPGWifiSDK(22717): Success callback didDiscovered 1 devices, XPGWifiSDKListener = com.snlion.gizwits.activity.BaseActivity$1@43625600: com.xtremeprog.xpgconnect.XPGWifiDevice@4364d620, mac: VIRTUAL:SITE
- 190:I/xpgc (22717): 11:31:18 void GWifiSDK::DiscoverCallback(int): (2189) Discovered 1 devices and notified UI
- 192:I/xpgc (22717): 11:31:18 void GWifiSDK::DiscoverCallback(int): (2190) getBoundDevices ack: 0
- 194:I/XPGWifiDevice(22717): setListener: com.snlion.gizwits.activity.BaseActivity$2@43625610, com.xtremeprog.xpgconnect.XPGWifiDevice@4364d620: VIRTUAL:SITE
- 198:I/xpgc (22717): 11:31:20 Start connecting to ip & port: 182.254.226.171:1883.
- 200:I/xpgc (22717): 11:31:20 ------------------------>connect elapsed: 77.000.
- 202:I/xpgc (22717): 11:31:20 ... succeed.
- 204:I/xpgc (22717): 11:31:20 Connected to server sandbox.gizwits.com:1883, connId: 0.
- 206:W/xpgc (22717): 11:31:20 xpgcLogin() clientid=usrPWnEU2aizHPXdlvMU2iq
- 208:W/xpgc (22717):
- 210:I/xpgc (22717): 11:31:20 mqtt_init_auth username:2$1837bd3c335f409ba6dba16b8dd5747c$404884c5a668434ebb552e15143a4e55 password:0e7f3a6434484597885885b0246daf71
- 212:W/xpgc (22717): 11:31:20 _recvThread() mqtt callback 32
- 214:I/xpgc (22717): 11:31:20 subscribing topic: dev2app/i6wbbMacUrBursbzysga5i
- 216:I/xpgc (22717): 11:31:20 topic "dev2app/i6wbbMacUrBursbzysga5i" subscribed
- 218:W/xpgc (22717): 11:31:20 _recvThread() mqtt callback 144
- 220:I/xpgc (22717): 11:31:20 void GWifiDevicePrivate::OnLogin(int): 0
- 222:I/XPGWifiDevice(22717): Success callback didLogin, XPGWifiDeviceListener = com.snlion.gizwits.activity.BaseActivity$2@43625610, com.xtremeprog.xpgconnect.XPGWifiDevice@4364d620: VIRTUAL:SITE
- 224:I/xpgc (22717): 11:31:20 int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
- 228:I/xpgc (22717): 11:31:24 int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
- 230:I/xpgc (22717): 11:31:26 int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
- 240:I/xpgc (22717): 11:31:28 int GWifiDevice::write(char const*): {"entity0":{"Switch":"1"},"cmd":1}
复制代码 此日志的过滤条件是22717,即线程号,所以不用担心有用的信息会被过滤掉
发送数据的代码段:
- if(device.isOnline()){
- try{
- final JSONObject jsonsend = new JSONObject();
- jsonsend.put("cmd", 1);
- JSONObject jsonparam = new JSONObject();
- jsonparam.put("Switch", "1");
- jsonsend.put("entity0", jsonparam);
- device.write(jsonsend.toString());
- }catch(JSONException e){
- e.printStackTrace();
- }
- }else{
- Toast.makeText(DeviceListActivity.this, "Error:Device Is Not Online !", Toast.LENGTH_SHORT).show();
- }
- <b></b><i></i><u></u><sub></sub><sup></sup><strike></strike>
复制代码
相关回调:
- @Override
- public void didReceiveData(XPGWifiDevice device,
- ConcurrentHashMap<String, Object> dataMap,
- int result){
- Message msg = Message.obtain();
- //msg.obj = "Data Received Success";
- if(result == -20){
- msg.obj = "INVALID PARAMS";
- }else{
- msg.obj = "Other Error"+result;
- }
- msg.what = DATA_RECEIVE;
- mcHandler.sendMessage(msg);
- }; // end of didReceiveData
复制代码- PS:我的SDK是昨天升级的,升级之前是收不到这个回调的,因为我不知道SDK具体更新了什么,相关代码也不知道该修改哪里,也许这是个线索
|
|