物联网设备如何连接到服务器

时间:2022-01-02 23:55:53

I am working on IoT project, and I should keep the embedded device to be connected with a web-service. So, which is better, requesting the webservice every 1 or 2 seconds, or opening a socket with the server to guarantee the real time operations.

我正在开展物联网项目,我应该让嵌入式设备与网络服务保持联系。因此,更好的是,每隔1或2秒请求Web服务,或者使用服务器打开套接字以保证实时操作。

Taking into Consideration that working with sockets, may require me to write a lot of bunches of codes, as there's no frameworks for socket over ARM for example.

考虑到使用套接字,可能需要我编写很多代码串,因为例如没有ARM套接字的框架。

Thanks

谢谢

2 个解决方案

#1


3  

My team and I are currently working on an IOT platform, here are my suggestions:

我和我的团队目前正在开发IOT平台,以下是我的建议:

  1. If your product only report data or status periodically, using a web service to receive the data will work fine, and it's very easy to implement.
  2. 如果您的产品仅定期报告数据或状态,则使用Web服务接收数据将正常工作,并且非常容易实现。
  3. If you need to send realtime operations from server to your device, using a long tcp connection is a better choice. There are some good protocol to help you implement this, like MQTT.
  4. 如果需要从服务器向设备发送实时操作,使用长tcp连接是更好的选择。有一些很好的协议可以帮助你实现这个,比如MQTT。
  5. For the second case above, requesting a web service to receive realtime operations will work, but it's definitely not a good idea. It will increase your server's load and your device's energy consumption.
  6. 对于上面的第二种情况,请求Web服务接收实时操作将起作用,但这绝对不是一个好主意。它会增加服务器的负载和设备的能耗。

After all, you need to make your choice on your product's requirements.

毕竟,您需要根据产品的要求做出选择。

#2


2  

You can use MQTT protocol, its library is available for embedded c as well as for arduino. Also you can choose, Rest/Coap with nodejs as the request will be waiting until node will give response In this both scenario, real time communication can be approached without any socket and refreshing time.

您可以使用MQTT协议,其库可用于嵌入式c以及arduino。此外,您可以选择Rest / Coap with nodejs,因为请求将等待,直到节点将给出响应。在这两种情况下,可以在没有任何套接字和刷新时间的情况下接近实时通信。

#1


3  

My team and I are currently working on an IOT platform, here are my suggestions:

我和我的团队目前正在开发IOT平台,以下是我的建议:

  1. If your product only report data or status periodically, using a web service to receive the data will work fine, and it's very easy to implement.
  2. 如果您的产品仅定期报告数据或状态,则使用Web服务接收数据将正常工作,并且非常容易实现。
  3. If you need to send realtime operations from server to your device, using a long tcp connection is a better choice. There are some good protocol to help you implement this, like MQTT.
  4. 如果需要从服务器向设备发送实时操作,使用长tcp连接是更好的选择。有一些很好的协议可以帮助你实现这个,比如MQTT。
  5. For the second case above, requesting a web service to receive realtime operations will work, but it's definitely not a good idea. It will increase your server's load and your device's energy consumption.
  6. 对于上面的第二种情况,请求Web服务接收实时操作将起作用,但这绝对不是一个好主意。它会增加服务器的负载和设备的能耗。

After all, you need to make your choice on your product's requirements.

毕竟,您需要根据产品的要求做出选择。

#2


2  

You can use MQTT protocol, its library is available for embedded c as well as for arduino. Also you can choose, Rest/Coap with nodejs as the request will be waiting until node will give response In this both scenario, real time communication can be approached without any socket and refreshing time.

您可以使用MQTT协议,其库可用于嵌入式c以及arduino。此外,您可以选择Rest / Coap with nodejs,因为请求将等待,直到节点将给出响应。在这两种情况下,可以在没有任何套接字和刷新时间的情况下接近实时通信。