当前位置:网站首页>硬件连接服务器 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进制格式转
将获取到的数据存入到数据库哦。
}
硬件的东西真的麻烦
边栏推荐
- Database integrity -- six constraints learning
- 【MySQL 17】安装异常:Could not open file ‘/var/log/mysql/mysqld.log‘ for error logging: Permission denied
- SQL language (6)
- Information management system for typical works of urban sculpture (picture sharing system SSM)
- Dynamic planning question 05_ Missile interception
- 基于W5500实现的考勤系统
- session和cookie有什么区别??小白来告诉你
- "Mqtt protocol explanation and Practice (access to onenet)" of wiznet w5500 series training activities
- 【IMX6ULL笔记】--内核底层驱动初步探究
- W5500多节点连接
猜你喜欢
![[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel](/img/0f/a0139be99c61fde08e73a5be6d6b4c.png)
[imx6ull notes] - a preliminary exploration of the underlying driver of the kernel

阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程

2022 年中回顾|一文看懂预训练模型最新进展

MIIdock简述

Miidock Brief

Reflection reflection

Review in the middle of 2022 | understand the latest progress of pre training model

Functions in JS

Small program of vegetable distribution in community

return 和 finally的执行顺序 ?各位大佬请看过来,
随机推荐
Esp8266 uses drv8833 drive board to drive N20 motor
【leetcode刷题】
Brief description of model deployment
Activity registration | play with kubernetes container service improvement class officially opened!
【高并发】我用10张图总结出了这份并发编程最佳学习路线!!(建议收藏)
菜单栏+状态栏+工具栏==PYQT5
JS中的对象
PL/SQL入门,非常详细的笔记
RedisUtil
矩阵的特征值和特征向量
W5500 upload temperature and humidity to onenet platform
Linked list related (design linked list and ring linked list)
Hardware peripherals =maixpy3
绘图==PYQT5
【电子器件笔记5】二极管参数和选型
【无标题】
Greedy problem 01_ Activity arrangement problem
用 Redis 做一个可靠的延迟队列
硬件外设=maixpy3
Hacker introductory tutorial (very detailed) from zero basic introduction to proficiency, it is enough to read this one.