Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
45:b85384e7d825
Parent:
43:28202405094d
Child:
46:665391110051
--- a/include/d7a_modem.h	Tue Aug 30 17:15:31 2016 +0000
+++ b/include/d7a_modem.h	Thu Sep 01 09:35:27 2016 +0000
@@ -2,54 +2,66 @@
 #define _D7A_MODEM_H_
 
 
-enum {
-    WM_ERR_COM_LINK=10,
-    WM_ERR_NOT_READY,
-};
-// Msg/Cmd exchanged on CMD FLOW ID
-enum {
-    WM_READY,
-};
-
-
-
 //======================================================================
 // MODEM commands over COM port
 //======================================================================
 typedef enum
 {
+    //============================================
+    // COMMANDS
+    //============================================
     /// Soft-reset Modem Device
     /// ARGS: none
     WM_CMD_RST                      = 0x01,
+
     /// Start D7A communication stack
     /// ARGS: none TODO: pass number of fifos ?
     WM_CMD_D7A_STACK_START          = 0x02,
+
     /// Stop D7A communication stack
     /// ARGS: none
     WM_CMD_D7A_STACK_STOP           = 0x03,
+
     /// Register a File for notification
     /// ARGS: register_file_param_t
     WM_CMD_REGISTER_FILE            = 0x04,
+
     /// Notify a (previously registered) file
     /// ARGS: notify_file_param_t
     WM_CMD_NOTIFY_FILE              = 0x05,
-    WM_CMD_CREATE_FILE              = 0x06,
-    WM_CMD_DECLARE_FILE             = 0x07,
-    WM_CMD_START_STACK              = 0x08,
-    WM_CMD_STOP_STACK               = 0x09,
 
+    /// Command that will be instantly answered with WM_OK
+    /// ARGS: none
+    WM_CMD_READY                    = 0x06,
+
+    //============================================
+    // RESPONSES
+    //============================================
     /// Send by the Modem Device after a command has been executed/taken
     /// into account, and the Modem is ready to handle a new command.
-    /// Can be used as a command that will be instantly answered with WM_CMD_READY
     /// ARGS: none
-    WM_CMD_READY                    = 0x80,
+    WM_OK                           = 0x80,
 
     /// Send by the Modem Device after a (re)boot.
     /// ARGS: boot_status_t
-    WM_CMD_BOOT                     = 0x81,
+    WM_BOOT                         = 0x81,
+
+    /// Send by the Modem Device in case of failing command
+    /// ARGS: wm_error_code_t (u8)
+    WM_ERROR                        = 0x82,
 
 } wm_cmd_t;
 
+typedef enum {
+    WM_ERR_NONE             = 0,
+    WM_ERR_NOT_READY        = 1,
+    WM_ERR_COM_LINK         = 2,
+    WM_ERR_ILLEGAL_FID      = 3,
+    WM_ERR_ILLEGAL_FILE_DEF = 4,
+
+    WM_ERR_UNKNOWN     = 0xff
+} wm_error_code_t;
+
 typedef union {
     uint32_t w;
     struct {
@@ -68,7 +80,7 @@
 } wm_status_t;
 
 
-typedef struct {
+TYPEDEF_STRUCT_PACKED {
     uint8_t  fid;
     uint8_t  type;
     uint8_t  afid;
@@ -79,15 +91,15 @@
     uint32_t alloc;
 } register_file_param_t;
 
-void d7a_modem_open(PinName reset_pin = NC);
-void d7a_modem_reset(void);
-bool d7a_modem_wait_ready(uint32_t millisec = osWaitForever);
+d7a_errors_t d7a_modem_open(PinName reset_pin = NC);
+d7a_errors_t d7a_modem_reset(void);
+d7a_errors_t d7a_modem_wait_ready(uint32_t millisec = osWaitForever);
 void d7a_modem_new_pkt(d7a_com_rx_msg_t* pkt);
 d7a_com_rx_msg_t* d7a_modem_wait_pkt(uint32_t millisec = osWaitForever);
 void d7a_modem_msg(uint8_t value, uint8_t* buf, uint8_t len);
-bool d7a_modem_register(register_file_param_t* file_infos);
-bool d7a_modem_start(void);
-bool d7a_modem_stop(void);
+d7a_errors_t d7a_modem_register(register_file_param_t* file_infos);
+d7a_errors_t d7a_modem_start(void);
+d7a_errors_t d7a_modem_stop(void);
 void d7a_modem_print_infos(void);