当前位置:网站首页>硬件连接服务器 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进制格式转
将获取到的数据存入到数据库哦。
}
硬件的东西真的麻烦
边栏推荐
- Onenet platform control w5500 development board LED light
- 【MySQL 17】安装异常:Could not open file ‘/var/log/mysql/mysqld.log‘ for error logging: Permission denied
- Similarity matrix, diagonalization condition
- Database integrity -- six constraints learning
- SQL language (V)
- 【USB设备设计】--复合设备,双HID高速(64Byte 和 1024Byte)
- What is the difference between session and cookie?? Xiaobai came to tell you
- JDBC summary
- 擎创科技加入龙蜥社区,共建智能运维平台新生态
- MySQL historical data supplement new data
猜你喜欢

Information management system for typical works of urban sculpture (picture sharing system SSM)

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

SQL injection LESS18 (header injection + error injection)

Job interviews are always a second kill? After reading the seckill system notes secretly stored by JD T8, I have given my knees

What is the global event bus?

SQL injection less23 (filter comment)

Oil monkey script link

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

Risks in software testing phase

Wiznet embedded Ethernet technology training open class (free!!!)
随机推荐
贪心问题01_活动安排代码分析
W5500 adjusts the brightness of LED light band through upper computer control
动态规划问题03_最大子段和
Risks in software testing phase
JS scope and pre parsing
cookie and session
flinksql client 连接kafka select * from table没有数据报错,如何解决?
Small and micro enterprise smart business card management applet
JS流程控制
varest蓝图设置json
Teach you how to configure S2E as the working mode of TCP server through MCU
Use three.js to realize the cool cyberpunk style 3D digital earth large screen
JS常用内置对象 数据类型的分类 传参 堆栈
程序员送给女孩子的精美礼物,H5立方体,唯美,精致,高清
Teach you how to configure S2E to UDP working mode through MCU
第4章线性方程组
Summary of combination problems of Li Kou brush questions (backtracking)
JDBC summary
W5500 upload temperature and humidity to onenet platform
brpc源码解析(八)—— 基础类EventDispatcher详解