jonah.id / Smart Plug
  1. 2019-03-21 — Smart Plug Intro
  2. 2019-03-22 — Smart Plug Prototype 0.1
  3. 2019-03-22 — Smart Plug Prototype 0.2
  4. 2019-03-22 — Smart Plug Prototype 0.3
  5. 2019-03-22 — Smart Plug Prototype 0.4
  6. 2019-03-27 — Smart Plug Prototype 0.5
  7. 2019-03-29 — Smart Plug Prototype 0.6
  8. 2019-04-04 — Smart Plug Prototype 1.0
  9. 2019-06-05 — Smart Plug Prototype 2.0
  10. 2019-07-14 — Rust on Arduino
  11. 2019-07-28 — W5500 Driver for Rust Embedded-HAL on AVR
  12. 2019-07-31 — Working UDP Listener in Rust (finally) ⬿

Working UDP Listener in Rust (finally)

After much wailing and gnashing of teeth, I figured out what the problem with my program was. The W5500 driver’s ability to edit registers is not broken, it was my own mistake. In my simple example set up to write/read to/from a register, I forgot to alter the configuration of the SPI instance to match what the W5500 chip expects. Fixing this instantly yielded results.

https://github.com/jonahbron/smart-plug/blob/0655b0671ad76788fccc0043198b9e15e715d753/src/main.rs

Hello from Arduino!
initialized
activated
IP: 192.168.86.30

This gave me new-found hope in the possibility of using the driver and not needing to implement my own. So I pushed forward to try receiving a UDP packet again. After messing around with the same compiler/linker errors I’ve been getting around the library, I found that passing in a buffer 16 bytes in length or less fixes the problem with receive.

https://github.com/jonahbron/smart-plug/blob/3bce81436a8eb3d8e97249d21715ebaef374a786/src/main.rs

And to my extreme excitement (and surprise), it worked! I was able to use netcat to send a packet to the board via the network, and see the serial output displaying the ASCII character codes.

The light is finally green. Next I will create the v2 prototype of the Smart Plug, while continuing my contributions to the AVR-HAL/w5500 projects in parallel.

Creative Commons License