diff options
author | xengineering <me@xengineering.eu> | 2024-06-01 12:48:44 +0200 |
---|---|---|
committer | xengineering <me@xengineering.eu> | 2024-06-01 12:48:44 +0200 |
commit | 7d7280a5b162800ef72d48a8a3d2afb4f0496b85 (patch) | |
tree | 457e8f20f98e638239b6f66c84995026f71ebf0a /firmware/src/main.c | |
parent | 010cf768c20c71603172ae4c300ce3d571863141 (diff) | |
download | iot-core-main.tar iot-core-main.tar.zst iot-core-main.zip |
This only covers the correct frame size, setting the buffer to 0 and
copy the payload over.
Missing is:
- copy destination address
- copy source address
- set frame type
- calculate and add CRC32 checksum
Diffstat (limited to 'firmware/src/main.c')
-rw-r--r-- | firmware/src/main.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/firmware/src/main.c b/firmware/src/main.c index e18cc77..8b31505 100644 --- a/firmware/src/main.c +++ b/firmware/src/main.c @@ -1,4 +1,5 @@ #include <stdbool.h> +#include <sys/types.h> #include <zephyr/device.h> #include <zephyr/drivers/uart.h> @@ -24,10 +25,17 @@ int main(void) } uint8_t payload[] = {0xDE, DL_SLIP_END, DL_SLIP_ESC, 0xAD}; + uint8_t frame[DL_MAX_FRAME_SIZE]; + + ssize_t flen = dl_encode_frame(payload, ARRAY_SIZE(payload), frame); + if (flen < 0) { + printk("Failed to encode frame"); + return 0; + } while (true) { k_sleep(K_MSEC(1000)); - dl_send_frame(uart_dev, payload, ARRAY_SIZE(payload)); + dl_send_frame(uart_dev, frame, flen); } return 0; |