- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个连接互联网的物联网设备(比如说先进的连接互联网的天气传感器,它可以发送传感器数据并执行一些高级操作,如旋转、打开、打开阀门/以及其他一些操作)。
编辑:
该设备为墙壁供电(电源 socket ),并具有移动互联网连接标准有线以太网连接(只需插入 Cat5 电缆)
我需要能够获得设备的状态(大约 500 字节的数据),并且希望能够 发送简单的命令,如 :
rotate-180-deg
turn-lights-on
turn-lights-off
open-valve-1
switch-sensor-X-on
switch-sensor-X-off
rotate-180-degrees
,我的中央服务器必须等到设备联系它并在 HTTP 请求的响应中 - 我可以放置一些命令,所以当设备收到响应时,它会实际执行命令。
最佳答案
This article详细介绍了将数据从服务器发送到设备的三个选项。
根据您的描述,听起来您使用的是 短轮询 :
The most basic way to solve this communication problem is called short polling—a method where the client periodically asks the server if there is new data available for it. This is the simplest solution to code, though it is not recommended if you need to notify a device in real time.
The next option is long polling. In this case, the client performs the request and the server won’t respond until it has something to send. This enables real-time push notifications from the cloud to devices, though it requires the device to leave the connection open for as long as it needs to listen to the server. Using this technique consumes more energy and also risks the loss of the connection. Consider the case where a device remotely controls the door of a truck. If a long poll request has been made, and then the truck goes into a tunnel, the mobile connection will drop. The device will then need additional logic to kill the hung connection and open a new one.
A third option is to use newer protocols like CoAp or MQTT, for example, which were designed to provide low latency, small packet sizes and stable communication over weak networks. These newer protocols provide a two-way communication channel, which in turn supports push notifications. This makes them good choices for IoT projects requiring the ability to control connected devices in real time. The only downside could be the lack of firmware libraries and examples for embedded devices, which are significantly more abundant for HTTP-based connections. Choosing the right protocol will depend on your application and how often you will need to communicate with a device.
关于arduino - 对于墙壁供电的物联网设备,读取数据和发送命令的最佳方式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35347042/
根据外媒 9to5google 的消息,小米电视棒现已通过 FCC 的审批,可能很快在美国上市。 IT之家了解到,这款 FCC 认证的小米电视棒的型号为 MITVMDZ24AA,是两款小米 M
我正在为客户设计和开发由 Wordpress 和 Woocommerce 提供支持的网页,但我被迫使用插件,然后对其进行修改以适应建议的设计和功能。 插件是“Woocommerce Visual Pr
我是一名优秀的程序员,十分优秀!