Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Revision:
45:b85384e7d825
Parent:
43:28202405094d
Child:
46:665391110051
--- a/include/d7a.h	Tue Aug 30 17:15:31 2016 +0000
+++ b/include/d7a.h	Thu Sep 01 09:35:27 2016 +0000
@@ -87,6 +87,45 @@
 } d7a_nls_t;
 
 
+// Mimic ALP Errors
+typedef enum
+{
+    D7A_ERR_ITF_FULL                    =  2, // 0x02: For interfaces supporting buffering, indicates buffer reached maximum capacity (no data loss)
+    D7A_ERR_PARTIAL_COMPLETION          =  1, // 0x01: Action received and partially completed at response.  To be completed after response
+
+    D7A_ERR_NONE                        =  0, // 0x00: Action completed (OK)
+    D7A_ERR_FILE_NOT_FOUND              = -1, // 0xFF: Error access file: File ID does not exist
+    D7A_ERR_FILE_EXIST                  = -2, // 0xFE: Error create file: File ID already exists
+    D7A_ERR_FILE_NOT_RESTORABLE         = -3, // 0xFD: Error restore file: File is not restorable
+    D7A_ERR_PERMISSION_DENIED           = -4, // 0xFC: Error access file: Insufficient permissions
+    D7A_ERR_LENGTH_OVERFLOW             = -5, // 0xFB: Error create file: Supplied length (in header) is beyond file limits
+    D7A_ERR_ALLOC_OVERFLOW              = -6, // 0xFA: Error create file: Supplied allocation (in header) is beyond file limits
+    D7A_ERR_OFFSET_OVERFLOW             = -7, // 0xF9: Error write: Supplied start offset is out of bounds of file allocation
+    D7A_ERR_WRITE_OVERFLOW              = -8, // 0xF8: Error complete write: Supplied data goes beyond file allocation
+    D7A_ERR_WRITE_ERROR                 = -9, // 0xF7: Error write: impossible to write in storage location
+    D7A_ERR_OPERATION_UNKNOWN           = -10,// 0xF6: Error unknown Operation
+    D7A_ERR_OPERAND_INCOMPLETE          = -11,// 0xF5: Error incomplete Operand
+    D7A_ERR_OPERAND_WRONG_FORMAT        = -12,// 0xF4: Error wrong Operand format
+    D7A_ERR_ITF_INVALID                 = -13,// 0xF3: Error invalid interface
+    D7A_ERR_ITF_OVERFLOW                = -14,// 0xF2: Error interface overflown (i.e. ressources exhausted, buffer full with data discarded)
+    D7A_ERR_QUERY_FAIL                  = -15,// 0xF1: (Group of) Query result was false (Informative error code).
+
+    D7A_ERR_UNKNOWN                     = -128,// 0x80: Unknown error
+    D7A_ERR_FS_TIMEOUT,                       // 0x81: Internal FS Error
+    D7A_ERR_ITF_UNKNOWN,                      // 0x82: Unknown Interface
+    
+    // Modem errors
+    D7A_ERR_NOT_READY                   ,// The modem is not ready to recieve commands
+    D7A_ERR_COM_LINK                    ,// A serial link timeout occured
+    D7A_ERR_ILLEGAL_FID                 ,// The FID specified is illegal
+    D7A_ERR_ILLEGAL_FILE_DEF            ,// The FILE parameters specified are illegal
+    D7A_ERR_CMD_TO                      ,// The command expired
+    D7A_ERR_TX_FAILED                   ,// Transmission failed
+    
+
+} d7a_errors_t;
+
+
 //======================================================================
 // Structures
 //======================================================================
@@ -253,31 +292,33 @@
 /// @param d7a_com_config_t*    Com port configuration structure
 /// @param PinName              Reset pin
 /// @param d7a_fs_callbacks_t*  File system callbacks (You cannot use local files if this is not specified)
+/// @return d7a_errors_t        Error code
 //======================================================================
-void d7a_open(const d7a_com_config_t* com_config, PinName reset_pin = NC, const d7a_fs_callbacks_t* fs_callbacks = NULL);
+d7a_errors_t d7a_open(const d7a_com_config_t* com_config, PinName reset_pin = NC, const d7a_fs_callbacks_t* fs_callbacks = NULL);
 
 //======================================================================
 // d7a_close
 //----------------------------------------------------------------------
 /// @brief                      Close D7A driver and stop the modem
+/// @return d7a_errors_t        Error code
 //======================================================================
-void d7a_close(void);
+d7a_errors_t d7a_close(void);
 
 //======================================================================
 // d7a_start
 //----------------------------------------------------------------------
 /// @brief                      Start the modem
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_start(void);
+d7a_errors_t d7a_start(void);
 
 //======================================================================
 // d7a_stop
 //----------------------------------------------------------------------
 /// @brief                      Stop the modem (goes to low power)
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_stop(void);
+d7a_errors_t d7a_stop(void);
 
 //======================================================================
 // d7a_create
@@ -289,9 +330,9 @@
 /// @param uint32_t             Maximum size of the file
 /// @param uint8_t              File ID to an eventual Action file
 /// @param uint8_t              File ID to an eventual Interface file
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_create(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
+d7a_errors_t d7a_create(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
 
 //======================================================================
 // d7a_declare
@@ -304,9 +345,9 @@
 /// @param uint32_t             Maximum size of the file
 /// @param uint8_t              File ID to an eventual Action file
 /// @param uint8_t              File ID to an eventual Interface file
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_declare(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
+d7a_errors_t d7a_declare(const uint8_t file_id, d7a_fs_storage_t prop, d7a_fs_perm_t perm, uint32_t size, uint32_t alloc, uint8_t action_file = 0, uint8_t interface = 0);
 
 //======================================================================
 // d7a_read
@@ -316,9 +357,9 @@
 /// @param uint32_t             Offset from which to start reading
 /// @param uint32_t             Size of data to read
 /// @param uint8_t*             Buffer to retrieve data
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
+d7a_errors_t d7a_read(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
 
 //======================================================================
 // d7a_write
@@ -328,8 +369,8 @@
 /// @param uint32_t             Offset from which to start writing
 /// @param uint32_t             Size of data to write
 /// @param uint8_t*             Buffer of the data to write
-/// @return bool                true if error
+/// @return d7a_errors_t        Error code
 //======================================================================
-bool d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
+d7a_errors_t d7a_write(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true);
 
 #endif // _D7A_H_
\ No newline at end of file