Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
678 B

  1. #include <sys/types.h>
  2. #include <stdint.h>
  3. #include <strobe.h>
  4. struct pktbuf {
  5. uint8_t *pkt;
  6. uint16_t pktlen;
  7. };
  8. /* first arg is input buffer, second arg is what will be sent as reply */
  9. typedef void (*process_msgfunc_t)(struct pktbuf, struct pktbuf *);
  10. enum comm_state {
  11. COMMS_WAIT_REQUEST = 1,
  12. COMMS_WAIT_CONFIRM,
  13. COMMS_PROCESS_MSGS,
  14. };
  15. struct comms_state {
  16. strobe_s cs_state;
  17. enum comm_state cs_comm_state;
  18. strobe_s cs_start; /* special starting state cache */
  19. process_msgfunc_t cs_procmsg;
  20. };
  21. size_t _strobe_state_size();
  22. void comms_init(struct comms_state *, process_msgfunc_t);
  23. void comms_process(struct comms_state *, struct pktbuf, struct pktbuf *);