ESP8266 protocol implementation

9 years 7 months ago #1187 by geir
I'm trying to use the ESP8266 EasyIoT Driver to input data from another system, but I'm having trouble understanding the protocol from the GitHub source code.

Maybe someone with a working Arduino / ESP8266 sensor could do a Wireshark log of the TCP-session between the ESP8266 and the EasyIoT server? Preferably a complete sesion from the point where the a new sensor is added in the server, requesting it's unique _nodeId and then starting to transmit some simple data (f.ex. a single temperature reading).

So far I have mostly just been sucessfull at seeing the EasyIoT server debug response to more or less random data like this (strangely the EasyIoT server seems to interpret every single 0xFF as two 0xFF):
Client open
2015-04-22T22:53:36.8491465+02:00       DEBUG   Esp8266
Rx:68-01-FF-FF-03-00-01-02-03-04
2015-04-22T22:53:37.4241794+02:00       DEBUG   Esp8266
Rx:68-01-FF-FF-03-00-01-02-03-04-68-01-FF-FF-03-00-01-02-03-04
2015-04-22T22:53:37.4251794+02:00       DEBUG   Esp8266
Receive: command: 3, type: 0, len: 20, sender: 65535, sensor:1, crc: 3(Error)
2015-04-22T22:53:37.4261795+02:00       DEBUG   Esp8266
Invalid CRC
2015-04-22T22:53:47.4997556+02:00       DEBUG   Esp8266
Cient timeout
Thread was being aborted.

Please Log in or Create an account to join the conversation.

9 years 7 months ago - 9 years 7 months ago #1188 by EasyIoT

geir wrote: I'm trying to use the ESP8266 EasyIoT Driver to input data from another system, but I'm having trouble understanding the protocol from the GitHub source code.

Maybe someone with a working Arduino / ESP8266 sensor could do a Wireshark log of the TCP-session between the ESP8266 and the EasyIoT server? Preferably a complete sesion from the point where the a new sensor is added in the server, requesting it's unique _nodeId and then starting to transmit some simple data (f.ex. a single temperature reading).

So far I have mostly just been sucessfull at seeing the EasyIoT server debug response to more or less random data like this (strangely the EasyIoT server seems to interpret every single 0xFF as two 0xFF):

Client open
2015-04-22T22:53:36.8491465+02:00       DEBUG   Esp8266
Rx:68-01-FF-FF-03-00-01-02-03-04
2015-04-22T22:53:37.4241794+02:00       DEBUG   Esp8266
Rx:68-01-FF-FF-03-00-01-02-03-04-68-01-FF-FF-03-00-01-02-03-04
2015-04-22T22:53:37.4251794+02:00       DEBUG   Esp8266
Receive: command: 3, type: 0, len: 20, sender: 65535, sensor:1, crc: 3(Error)
2015-04-22T22:53:37.4261795+02:00       DEBUG   Esp8266
Invalid CRC
2015-04-22T22:53:47.4997556+02:00       DEBUG   Esp8266
Cient timeout
Thread was being aborted.


Interesting. Read this thread:
iot-playground.com/forum/esp8266-easyiot...tcp-or-http-protocol

In your case you have invalid CRC. For every message CRC is calculated. If it's not correct message is ignored. And you need ping every 5s. And also add node in system before send messages to server.

You have also other options to send data to EasyIoT server, like http call. See lua or Arduino IDE examples. I will also add mqtt in future.

Please Log in or Create an account to join the conversation.

9 years 7 months ago #1197 by geir
I'm aware of the invalid CRC since I was just playing around, sending more or less random data to the EasyIoT server. However I have concluded that a telegram needs to start with 0x68 :)

Since I'm struggling to understand the code in the Arduino library, I would be very thankfull if anyone could provide me the raw bytes sendt and received during a connection of a new ESP8266. First I would need to understand how to correctly request for a _nodeId, then how to send a simple measured value / ping-telegrams if no new values are to be sendt. Since my device can not run the Arduino library, I'm dependant on building the correct TCP-telegram byte for byte. I'm under the impression that the protocol is quite simple, so I guess this should be doable if I just understand the bytes of the protocol telegrams myself.

I would prefer this raw TCP connection over HTTP or similar (which I belive to have higher overhead).

Please Log in or Create an account to join the conversation.

9 years 7 months ago #1206 by EasyIoT

geir wrote: I'm aware of the invalid CRC since I was just playing around, sending more or less random data to the EasyIoT server. However I have concluded that a telegram needs to start with 0x68 :)

Since I'm struggling to understand the code in the Arduino library, I would be very thankfull if anyone could provide me the raw bytes sendt and received during a connection of a new ESP8266. First I would need to understand how to correctly request for a _nodeId, then how to send a simple measured value / ping-telegrams if no new values are to be sendt. Since my device can not run the Arduino library, I'm dependant on building the correct TCP-telegram byte for byte. I'm under the impression that the protocol is quite simple, so I guess this should be doable if I just understand the bytes of the protocol telegrams myself.

I would prefer this raw TCP connection over HTTP or similar (which I belive to have higher overhead).


I do not have Wireshark. Just see code and everything will be clear. In Esp8266EasyIoTMsg.h is message definition, 0x68 is beginning of message and in Esp8266EasyIoT.cpp method process() is main function to handle messages.

Please Log in or Create an account to join the conversation.

9 years 7 months ago #1217 by geir
I have tried understanding the protocol based on the source, but I guess it's a bit over my level. Maybe you help me out by writing down a typical dialog between ESP8266 and EasyIoT server? Based on what I know so far, I suppose these are the steps:

You chose to add a new device in EasyIoT server and get a 30 second timeframe to connect a new device. The new device is powered up and opens a TCP-connection to the EasyIoT server before the dialog starts:
  1. Client request it's _nodeId (using 0xFFFF as it's temporary _nodeId?): 0x68 ... 0xFF 0xFF ...
  2. Server responds with a _nodeId: 0x68 ...
  3. Maybe the client also needs to tell the server what kind of measurand it is providing (f.ex. temperature)?
  4. Client sends a measured value (f.ex. temperature): 0x68 ...
  5. Client sends a ping if no new value after 5 seconds: 0x68 ...

I would be very thankfull if someone could fill in this dialog with the actual bytes of a real life communication session. Then I guess I will be able to further expand my understanding of different variants of the telegrams with for example multiple sensor and similar.

Please Log in or Create an account to join the conversation.

9 years 6 months ago #1220 by geir
It's a slow progress, but I'm finally I'm able to make the EasyIoT server respond with a _nodeId for my device! :)
68 01 FF FF 03 00 FF 00 65  Device asking for _nodeId
68 02 00 00 63 01 FF 02 D4 03 00  Server responding with 0x3000

Guess I will need to "reverse engineer" some more from the Arduino library until my device actually is able to be registered on the server and eventually deliver som data.

Please Log in or Create an account to join the conversation.

Time to create page: 0.366 seconds

Forum latest

  • No posts to display.