当前位置:网站首页>硬件连接服务器 tcp通讯协议 gateway
硬件连接服务器 tcp通讯协议 gateway
2022-07-25 11:02:00 【hexiaoniao】
最近的需求坑死我了。是一个网关设备(类似路由器),有网络,也可以连接有线。还有手环,通过蓝牙连接到网关
。需求是:服务器上gateway监听网关设备。网关(就是客户端或者终端设备)和Gateway连接上了。就可以发送命令给终端了。
先本地下载Gateway,http://doc2.workerman.net/on-messsge.html
本地要装php ,然后环境变量也要加哦。别忘记

windows是没有start.php的。直接双击启动服务器。start_for_win.bat
1.插上网关。电脑连接网关网络哦
2.配置网关设备连接信息 。此处选中tcp协议。ip为本地服务器ip。端口随意配置。尽量不要8080.容易被占用。
此处端口要和Gateway 配置端口保持一致。不然连接不上哦

3.
3.start.gateway配置:最后写0.0.0.0 默认内网外网都可以访问

4.双机start_for_win.bat
效果:

代表服务已经开启了哦
4.events.php文件是处理业务代码的,自动产生。唯一的。不用定义
public static function onConnect($client_id)
$data="ADBA0001600016AB3A3ACB98A0000566313210767C00FE";//命令
Gateway::sendToClient($client_id, pack("H*",$data));pack("H*",$data)以16进制格式来发送
}
5.当客户端收到命令。会回调数据到服务器哦
public static function onMessage($client_id, $message)
{
// var_dump($client_id);
var_dump(bin2hex($message));//16进制格式转
将获取到的数据存入到数据库哦。
}
硬件的东西真的麻烦
边栏推荐
- Miidock Brief
- MySQL historical data supplement new data
- How to solve the problem that "w5500 chip cannot connect to the server immediately after power failure and restart in tcp_client mode"
- brpc源码解析(八)—— 基础类EventDispatcher详解
- 【mysql学习08】
- W5500上传温湿度到oneNET平台
- pycharm连接远程服务器ssh -u 报错:No such file or directory
- 布局管理==PYQT5
- Teach you how to configure S2E as the working mode of TCP server through MCU
- Various controls ==pyqt5
猜你喜欢

JS流程控制

Reinforcement learning (IV)

第4章线性方程组
![[MySQL learning 09]](/img/27/2578f320789ed32552d6f69f14a151.png)
[MySQL learning 09]

JS运算符

Power BI----这几个技能让报表更具“逼格“
![[electronic device notes 5] diode parameters and selection](/img/4d/05c60641dbdbfbfa6c3cc19a24fa03.png)
[electronic device notes 5] diode parameters and selection

教你如何通过MCU将S2E配置为UDP的工作模式

Emmet syntax quick query syntax basic syntax part

Experimental reproduction of image classification (reasoning only) based on caffe resnet-50 network
随机推荐
[leetcode brush questions]
11. Reading rumors spread with deep learning
return 和 finally的执行顺序 ?各位大佬请看过来,
Talking about Devops monitoring, how does the team choose monitoring tools?
Web APIs(获取元素 事件基础 操作元素)
Use three.js to realize the cool cyberpunk style 3D digital earth large screen
brpc源码解析(八)—— 基础类EventDispatcher详解
[MySQL learning 09]
30套中国风PPT/创意PPT模板
谣言检测文献阅读十一—Preventing rumor spread with deep learning
JS常用内置对象 数据类型的分类 传参 堆栈
JS中的数组
Information management system for typical works of urban sculpture (picture sharing system SSM)
Plot ==pyqt5
相似矩阵,可对角化条件
How does the whole network display IP ownership?
【USB设备设计】--复合设备,双HID高速(64Byte 和 1024Byte)
Teach you how to configure S2E as the working mode of TCP server through MCU
Web APIs (get element event basic operation element)
【MySQL 17】安装异常:Could not open file ‘/var/log/mysql/mysqld.log‘ for error logging: Permission denied