Barnard-PL-Labs / esp32-tanks

5 stars 0 forks source link

Create Protocol for Tank Communication #5

Closed zjc2106 closed 6 months ago

zjc2106 commented 7 months ago

[X] Determine JSON format to send to/from tanks [X] Determine what messages line up with specific movement functions

zjc2106 commented 6 months ago

I updated the code to use a simple JSON object when sending commands from the server to the tank. I used the ArduinoJSON library (https://arduinojson.org) to serialize and deserialize JSON messages. Also used this repository for example code: https://github.com/techiesms/ESPNOW-JSON

Example JSON object that is sent from server to tank: { "direction": "f", "value": "100" }

"direction" can be "f", "b", "r", or "l" (forward, backward, right, or left) "value" can be any number (degrees for right and left, distance for forward and backward)

Stuff to discuss next meeting:

  1. Should we also use JSON objects when the tank sends back the commands it ran, or is that simply for debugging?
  2. I also wanted to incorporate timing into the JSON object and command, but then I started looking into AttachTimerInterrupt and figured I should wait to discuss with everyone how that should be implemented. Should we even incorporate timing into the struct? We definitely need some way to make a queue when a new command is sent while the old command is running.
  3. Any other data the JSON object should take, other than direction, value, or (possibly) time?

Shoutout to Brennen- the ESP-NOW code that he wrote worked great

See commit 1a35ec2