直连微信硬件回调

智能设备

智能设备—–灯控
控制开关,调节亮度。


开源项目源码:https://git.oschina.net/javen205/jfinal-weixin.git

谁有做蓝牙硬件设备并准备与微信公众号对接可以一起交流

回调模式返回的json如下

直连设备回调 灯控

如何使用

注意:测试发现在Wifi直连微信硬件回调中,无能设置的是加密模式还是明文模式回调返回的json都是明文。所以目前只支持明文模式
  1. clone 项目
    如有不会的伙伴参考:从零开始使用Git

  2. 修改配置文件

    src/main/resources/a_little_config.txt 中的 token appId appSecret 或者复制一份命名为a_little_config_pro.txt 将其修改

    如下图

  3. 设置回调的URL

    回调的URL为 http://域名/msg ;Token 与您修改的配置保持一致;消息加解密方式 设置为 明文模式;配置文件中将 encryptMessage 设置为 false 或者注释掉

如果任何疑问请留言

博客评论区留言亦或者在开源项目Issue中提出

openId:ofkJSuGtXgB8n23e-y0kqDjJLXxk

扫码绑定

1
2
3
4
5
6
7
8
9
10
11
{
"device_id": "gh_8746b7fa293e_f1e10a4eb78b8148",
"device_type": "gh_8746b7fa293e",
"msg_id": 76663912,
"msg_type": "bind",
"create_time": 1469896072,
"open_id": "ofkJSuL6kYUoIbknjbRY0EISgGEY",
"session_id": 0,
"content": "",
"qrcode_suffix_data": ""
}

设备上操作 开启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"device_id": "gh_8746b7fa293e_f1e10a4eb78b8148",
"device_type": "gh_8746b7fa293e",
"msg_id": 76661379,
"msg_type": "notify",
"services": {
"operation_status": {
"status": 0
},
"power_switch": {
"on_off": true
},
"lightbulb": {
"alpha": 19
}
},
"create_time": 1469891527
}

设备上操作 关闭

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
{
"device_id": "gh_8746b7fa293e_f1e10a4eb78b8148",
"device_type": "gh_8746b7fa293e",
"msg_id": 76661314,
"msg_type": "notify",
"services": {
"operation_status": {
"status": 1
},
"power_switch": {
"on_off": true
},
"lightbulb": {
"alpha": 19
}
},
"create_time": 1469891412
}

面板控制 关闭

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"asy_error_code": 0,
"asy_error_msg": "ok",
"device_id": "gh_8746b7fa293e_f1e10a4eb78b8148",
"device_type": "gh_8746b7fa293e",
"msg_id": 76656877,
"msg_type": "set_resp",
"services": {
"operation_status": {
"status": 1
},
"power_switch": {
"on_off": true
},
"lightbulb": {
"alpha": 38
}
},
"create_time": 1469886772
}

面板控制 开启

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"asy_error_code": 0,
"asy_error_msg": "ok",
"device_id": "gh_8746b7fa293e_f1e10a4eb78b8148",
"device_type": "gh_8746b7fa293e",
"msg_id": 76656853,
"msg_type": "set_resp",
"services": {
"operation_status": {
"status": 0
},
"power_switch": {
"on_off": true
},
"lightbulb": {
"alpha": 38
}
},
"create_time": 1469886730
}

效果图展示

Javen wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!
坚持原创技术分享,您的支持将鼓励我继续创作!