Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Committer:
Jeej
Date:
Fri Oct 21 15:31:45 2016 +0000
Revision:
66:492b1d7ba370
Parent:
65:ac3844adfe49
Child:
67:9ac9d109b80a
Wait after sending data to not release the resource too soon

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 43:28202405094d 1 #ifndef _D7A_H_
Jeej 43:28202405094d 2 #define _D7A_H_
Jeej 43:28202405094d 3
Jeej 43:28202405094d 4 #include "d7a_common.h"
Jeej 43:28202405094d 5
Jeej 43:28202405094d 6
Jeej 43:28202405094d 7 //======================================================================
Jeej 43:28202405094d 8 // Defines
Jeej 43:28202405094d 9 //======================================================================
Jeej 43:28202405094d 10
Jeej 43:28202405094d 11 #define D7A_UID_LEN (8)
Jeej 43:28202405094d 12
Jeej 65:ac3844adfe49 13 #define D7A_XCL_ENDPOINT_NO (0x01) // Normal rate
Jeej 65:ac3844adfe49 14 #define D7A_XCL_GATEWAY_NO (0x21) // Normal Rate
Jeej 65:ac3844adfe49 15
Jeej 65:ac3844adfe49 16 #define D7A_XCL_ENDPOINT_LO (0x11) // Low rate
Jeej 65:ac3844adfe49 17 #define D7A_XCL_GATEWAY_LO (0x31) // Low Rate
Jeej 65:ac3844adfe49 18
Jeej 65:ac3844adfe49 19 #define D7A_XCL_ENDPOINT_HI (0x41) // High rate
Jeej 65:ac3844adfe49 20 #define D7A_XCL_GATEWAY_HI (0x51) // High Rate
Jeej 55:5ea18a3a01b9 21
Jeej 58:38a366236bda 22 #define D7A_CTF_VAL(mant,exp) ((uint8_t)(mant|(exp<<5)))
Jeej 58:38a366236bda 23
Jeej 58:38a366236bda 24 #define D7A_NBID(nbid) (nbid >= 32)? D7A_CTF_VAL(8,1) : D7A_CTF_VAL(nbid,0)
Jeej 58:38a366236bda 25
Jeej 43:28202405094d 26
Jeej 43:28202405094d 27 //======================================================================
Jeej 43:28202405094d 28 // Enums
Jeej 43:28202405094d 29 //======================================================================
Jeej 43:28202405094d 30
Jeej 43:28202405094d 31 //======================================================================
Jeej 43:28202405094d 32 // d7a_fs_storage_t
Jeej 43:28202405094d 33 //----------------------------------------------------------------------
Jeej 43:28202405094d 34 /// File "Storage Class"
Jeej 43:28202405094d 35 //======================================================================
Jeej 43:28202405094d 36 typedef enum {
Jeej 55:5ea18a3a01b9 37 /// No data is keeped. Write only!
Jeej 43:28202405094d 38 /// Ex: Use for commands.
Jeej 43:28202405094d 39 TRANSIENT = 0,
Jeej 43:28202405094d 40 /// Data is stocked in RAM and initialized at 0.
Jeej 43:28202405094d 41 /// Can not guarantee data integrity over time.
Jeej 43:28202405094d 42 /// Ex: Use for often updated data.
Jeej 43:28202405094d 43 VOLATILE,
Jeej 43:28202405094d 44 /// Data is stocked in RAM and initialized with the last flushed data from EEPROM.
Jeej 43:28202405094d 45 /// Can not guarantee data integrity over time.
Jeej 43:28202405094d 46 /// Ex: Use for temporary configurations.
Jeej 43:28202405094d 47 RESTORABLE,
Jeej 43:28202405094d 48 /// Data is stoked in EEPROM.
Jeej 43:28202405094d 49 /// Data integrity is guaranteed.
Jeej 43:28202405094d 50 /// Ex: Use for important configurations.
Jeej 43:28202405094d 51 /// /!\ Use sparingly as operations on these type of files are time and ressource consuming
Jeej 43:28202405094d 52 PERMANENT
Jeej 43:28202405094d 53 } d7a_fs_storage_t;
Jeej 43:28202405094d 54
Jeej 43:28202405094d 55 //======================================================================
Jeej 43:28202405094d 56 // d7a_fs_perm_t
Jeej 43:28202405094d 57 //----------------------------------------------------------------------
Jeej 43:28202405094d 58 /// File permissions for USER/GUEST
Jeej 43:28202405094d 59 //======================================================================
Jeej 43:28202405094d 60 typedef enum {
Jeej 66:492b1d7ba370 61 O_O = 0b11000000,
Jeej 66:492b1d7ba370 62 R_O = 0b11100000,
Jeej 66:492b1d7ba370 63 R_R = 0b11100100,
Jeej 66:492b1d7ba370 64 W_O = 0b11010000,
Jeej 66:492b1d7ba370 65 W_W = 0b11010010,
Jeej 64:49a67f36d9c5 66 RW_O = 0b11110000,
Jeej 64:49a67f36d9c5 67 RW_R = 0b11110100,
Jeej 64:49a67f36d9c5 68 RW_W = 0b11110010,
Jeej 64:49a67f36d9c5 69 RW_RW = 0b11110110,
Jeej 64:49a67f36d9c5 70 RWX_O = 0b11111000,
Jeej 64:49a67f36d9c5 71 RWX_RWX = 0b11111111,
Jeej 43:28202405094d 72 } d7a_fs_perm_t;
Jeej 43:28202405094d 73
Jeej 43:28202405094d 74 // =======================================================================
Jeej 43:28202405094d 75 // d7a_nls_t
Jeej 43:28202405094d 76 // -----------------------------------------------------------------------
Jeej 43:28202405094d 77 /// Enumerator of the NWL security modes
Jeej 43:28202405094d 78 // =======================================================================
Jeej 43:28202405094d 79 typedef enum
Jeej 43:28202405094d 80 {
Jeej 43:28202405094d 81 /// No security enabled
Jeej 43:28202405094d 82 D7A_NLS_NO = 0,
Jeej 43:28202405094d 83 /// Encryption only, Counter Mode
Jeej 43:28202405094d 84 D7A_NLS_AES_CTR,
Jeej 43:28202405094d 85 /// No encryption, Authentication, Cipher-block chaining with 128 bit MAC
Jeej 43:28202405094d 86 D7A_NLS_AES_CBC_MAC_128,
Jeej 43:28202405094d 87 /// No encryption, Authentication, Cipher-block chaining with 64 bit MAC
Jeej 43:28202405094d 88 D7A_NLS_AES_CBC_MAC_64,
Jeej 43:28202405094d 89 /// No encryption, Authentication, Cipher-block chaining with 32 bit MAC
Jeej 43:28202405094d 90 D7A_NLS_AES_CBC_MAC_32,
Jeej 43:28202405094d 91 /// Authentication with CBC-MAC-128 and Encryption with Counter Mode
Jeej 43:28202405094d 92 D7A_NLS_AES_CCM_128,
Jeej 43:28202405094d 93 /// Authentication with CBC-MAC-64 and Encryption with Counter Mode
Jeej 43:28202405094d 94 D7A_NLS_AES_CCM_64,
Jeej 43:28202405094d 95 /// Authentication with CBC-MAC-32 and Encryption with Counter Mode
Jeej 43:28202405094d 96 D7A_NLS_AES_CCM_32,
Jeej 43:28202405094d 97 /// QTY
Jeej 43:28202405094d 98 D7A_NLS_QTY
Jeej 43:28202405094d 99
Jeej 43:28202405094d 100 } d7a_nls_t;
Jeej 43:28202405094d 101
Jeej 43:28202405094d 102
Jeej 45:b85384e7d825 103 // Mimic ALP Errors
Jeej 45:b85384e7d825 104 typedef enum
Jeej 45:b85384e7d825 105 {
Jeej 45:b85384e7d825 106 D7A_ERR_ITF_FULL = 2, // 0x02: For interfaces supporting buffering, indicates buffer reached maximum capacity (no data loss)
Jeej 45:b85384e7d825 107 D7A_ERR_PARTIAL_COMPLETION = 1, // 0x01: Action received and partially completed at response. To be completed after response
Jeej 45:b85384e7d825 108
Jeej 45:b85384e7d825 109 D7A_ERR_NONE = 0, // 0x00: Action completed (OK)
Jeej 45:b85384e7d825 110 D7A_ERR_FILE_NOT_FOUND = -1, // 0xFF: Error access file: File ID does not exist
Jeej 45:b85384e7d825 111 D7A_ERR_FILE_EXIST = -2, // 0xFE: Error create file: File ID already exists
Jeej 45:b85384e7d825 112 D7A_ERR_FILE_NOT_RESTORABLE = -3, // 0xFD: Error restore file: File is not restorable
Jeej 45:b85384e7d825 113 D7A_ERR_PERMISSION_DENIED = -4, // 0xFC: Error access file: Insufficient permissions
Jeej 45:b85384e7d825 114 D7A_ERR_LENGTH_OVERFLOW = -5, // 0xFB: Error create file: Supplied length (in header) is beyond file limits
Jeej 45:b85384e7d825 115 D7A_ERR_ALLOC_OVERFLOW = -6, // 0xFA: Error create file: Supplied allocation (in header) is beyond file limits
Jeej 45:b85384e7d825 116 D7A_ERR_OFFSET_OVERFLOW = -7, // 0xF9: Error write: Supplied start offset is out of bounds of file allocation
Jeej 45:b85384e7d825 117 D7A_ERR_WRITE_OVERFLOW = -8, // 0xF8: Error complete write: Supplied data goes beyond file allocation
Jeej 45:b85384e7d825 118 D7A_ERR_WRITE_ERROR = -9, // 0xF7: Error write: impossible to write in storage location
Jeej 45:b85384e7d825 119 D7A_ERR_OPERATION_UNKNOWN = -10,// 0xF6: Error unknown Operation
Jeej 45:b85384e7d825 120 D7A_ERR_OPERAND_INCOMPLETE = -11,// 0xF5: Error incomplete Operand
Jeej 45:b85384e7d825 121 D7A_ERR_OPERAND_WRONG_FORMAT = -12,// 0xF4: Error wrong Operand format
Jeej 45:b85384e7d825 122 D7A_ERR_ITF_INVALID = -13,// 0xF3: Error invalid interface
Jeej 45:b85384e7d825 123 D7A_ERR_ITF_OVERFLOW = -14,// 0xF2: Error interface overflown (i.e. ressources exhausted, buffer full with data discarded)
Jeej 45:b85384e7d825 124 D7A_ERR_QUERY_FAIL = -15,// 0xF1: (Group of) Query result was false (Informative error code).
Jeej 45:b85384e7d825 125
Jeej 45:b85384e7d825 126 D7A_ERR_UNKNOWN = -128,// 0x80: Unknown error
Jeej 57:fd9c8b67ffdc 127 D7A_ERR_FS_TIMEOUT ,// 0x81: Internal FS Error
Jeej 57:fd9c8b67ffdc 128 D7A_ERR_ITF_UNKNOWN ,// 0x82: Unknown Interface
Jeej 45:b85384e7d825 129
Jeej 45:b85384e7d825 130 // Modem errors
Jeej 45:b85384e7d825 131 D7A_ERR_NOT_READY ,// The modem is not ready to recieve commands
Jeej 45:b85384e7d825 132 D7A_ERR_COM_LINK ,// A serial link timeout occured
Jeej 45:b85384e7d825 133 D7A_ERR_ILLEGAL_FID ,// The FID specified is illegal
Jeej 45:b85384e7d825 134 D7A_ERR_ILLEGAL_FILE_DEF ,// The FILE parameters specified are illegal
Jeej 45:b85384e7d825 135 D7A_ERR_CMD_TO ,// The command expired
Jeej 45:b85384e7d825 136 D7A_ERR_TX_FAILED ,// Transmission failed
Jeej 66:492b1d7ba370 137 D7A_ERR_STATE ,// The device is not in the right state to execute the command
Jeej 56:da34fc11e760 138
Jeej 45:b85384e7d825 139 } d7a_errors_t;
Jeej 45:b85384e7d825 140
Jeej 55:5ea18a3a01b9 141
Jeej 55:5ea18a3a01b9 142 /// Types of retry policies
Jeej 55:5ea18a3a01b9 143 /// Respond: When finished the host will be notified
Jeej 55:5ea18a3a01b9 144 /// Persist: When finished on error data is kept in the queue for next transmission
Jeej 55:5ea18a3a01b9 145 /// Depth: Number of commands kept in the queue
Jeej 55:5ea18a3a01b9 146 /// Bulk: Notifications sent only when the queue is full
Jeej 55:5ea18a3a01b9 147 /// Retries: Number of retries after initial transmission
Jeej 55:5ea18a3a01b9 148 /// Slot: Time between retries (sec)
Jeej 46:665391110051 149 typedef enum {
Jeej 55:5ea18a3a01b9 150 /// Respond: true
Jeej 55:5ea18a3a01b9 151 /// Persist: false
Jeej 55:5ea18a3a01b9 152 /// Depth: 1
Jeej 55:5ea18a3a01b9 153 /// Bulk: false
Jeej 55:5ea18a3a01b9 154 /// Retries: 0
Jeej 55:5ea18a3a01b9 155 /// Slot: 0
Jeej 46:665391110051 156 ALP_RPOL_ONESHOT = 0,
Jeej 55:5ea18a3a01b9 157 /// Respond: true
Jeej 55:5ea18a3a01b9 158 /// Persist: false
Jeej 55:5ea18a3a01b9 159 /// Depth: 1
Jeej 55:5ea18a3a01b9 160 /// Bulk: false
Jeej 55:5ea18a3a01b9 161 /// Retries: 3
Jeej 55:5ea18a3a01b9 162 /// Slot: 2
Jeej 46:665391110051 163 ALP_RPOL_SINGLE = 1,
Jeej 55:5ea18a3a01b9 164 /// Respond: true
Jeej 55:5ea18a3a01b9 165 /// Persist: false
Jeej 55:5ea18a3a01b9 166 /// Depth: 1
Jeej 55:5ea18a3a01b9 167 /// Bulk: false
Jeej 55:5ea18a3a01b9 168 /// Retries: 3
Jeej 55:5ea18a3a01b9 169 /// Slot: 2
Jeej 46:665391110051 170 ALP_RPOL_REPORT = 2,
Jeej 55:5ea18a3a01b9 171 /// Respond: false
Jeej 55:5ea18a3a01b9 172 /// Persist: true
Jeej 55:5ea18a3a01b9 173 /// Depth: 4
Jeej 55:5ea18a3a01b9 174 /// Bulk: false
Jeej 55:5ea18a3a01b9 175 /// Retries: 16
Jeej 55:5ea18a3a01b9 176 /// Slot: 20
Jeej 46:665391110051 177 ALP_RPOL_REPORT_CHECKED = 3,
Jeej 55:5ea18a3a01b9 178 /// Respond: true
Jeej 55:5ea18a3a01b9 179 /// Persist: false
Jeej 55:5ea18a3a01b9 180 /// Depth: 4
Jeej 55:5ea18a3a01b9 181 /// Bulk: true
Jeej 55:5ea18a3a01b9 182 /// Retries: 0
Jeej 55:5ea18a3a01b9 183 /// Slot: 1
Jeej 46:665391110051 184 ALP_RPOL_BULK = 4,
Jeej 59:b42eae56b51b 185 /// Respond: false
Jeej 59:b42eae56b51b 186 /// Persist: false
Jeej 59:b42eae56b51b 187 /// Depth: 1
Jeej 59:b42eae56b51b 188 /// Bulk: false
Jeej 59:b42eae56b51b 189 /// Retries: 0
Jeej 59:b42eae56b51b 190 /// Slot: 1
Jeej 59:b42eae56b51b 191 ALP_RPOL_BLINK = 5,
Jeej 55:5ea18a3a01b9 192
Jeej 55:5ea18a3a01b9 193 //ALP_RPOL_SPARE_2 = 6,
Jeej 55:5ea18a3a01b9 194 //ALP_RPOL_SPARE_3 = 7,
Jeej 55:5ea18a3a01b9 195 } alp_rpol_t;
Jeej 46:665391110051 196
Jeej 55:5ea18a3a01b9 197 /// Action when file notifying
Jeej 55:5ea18a3a01b9 198 typedef enum {
Jeej 55:5ea18a3a01b9 199 D7A_ACTION_NONE = 0,
Jeej 55:5ea18a3a01b9 200 /// Notify the whole file
Jeej 55:5ea18a3a01b9 201 D7A_NOTIFICATION_FULL = 100,
Jeej 55:5ea18a3a01b9 202 /// Notify only part of the file
Jeej 55:5ea18a3a01b9 203 D7A_NOTIFICATION_PART
Jeej 55:5ea18a3a01b9 204 } d7a_action_t;
Jeej 45:b85384e7d825 205
Jeej 58:38a366236bda 206
Jeej 58:38a366236bda 207 // =======================================================================
Jeej 58:38a366236bda 208 // d7a_id_t
Jeej 58:38a366236bda 209 // -----------------------------------------------------------------------
Jeej 58:38a366236bda 210 // Identifier types enumerator
Jeej 58:38a366236bda 211 // =======================================================================
Jeej 58:38a366236bda 212 typedef enum
Jeej 58:38a366236bda 213 {
Jeej 58:38a366236bda 214 // Void identifier (broadcast)
Jeej 58:38a366236bda 215 // with indication of number of reached devices
Jeej 58:38a366236bda 216 D7A_ID_NBID = 0,
Jeej 58:38a366236bda 217 // Void identifier (broadcast)
Jeej 58:38a366236bda 218 D7A_ID_NOID = 1,
Jeej 58:38a366236bda 219 // Unique Identifier
Jeej 58:38a366236bda 220 D7A_ID_UID = 2,
Jeej 58:38a366236bda 221 // Virtual identifier
Jeej 58:38a366236bda 222 D7A_ID_VID = 3,
Jeej 58:38a366236bda 223
Jeej 58:38a366236bda 224 } d7a_id_t;
Jeej 58:38a366236bda 225
Jeej 43:28202405094d 226 //======================================================================
Jeej 43:28202405094d 227 // Structures
Jeej 43:28202405094d 228 //======================================================================
Jeej 43:28202405094d 229
Jeej 43:28202405094d 230 //======================================================================
Jeej 43:28202405094d 231 // d7a_com_config_t
Jeej 43:28202405094d 232 //----------------------------------------------------------------------
Jeej 43:28202405094d 233 /// Com port configuration structure
Jeej 43:28202405094d 234 //======================================================================
Jeej 43:28202405094d 235 typedef struct {
Jeej 43:28202405094d 236 /// Tx pin
Jeej 43:28202405094d 237 PinName tx;
Jeej 43:28202405094d 238 /// RX pin
Jeej 43:28202405094d 239 PinName rx;
Jeej 43:28202405094d 240 /// WKUP pin
Jeej 43:28202405094d 241 PinName rts;
Jeej 43:28202405094d 242 /// HST_WKUP pin
Jeej 43:28202405094d 243 PinName cts;
Jeej 43:28202405094d 244 /// Size of RX buffer
Jeej 43:28202405094d 245 uint16_t rx_buffer_size;
Jeej 43:28202405094d 246 } d7a_com_config_t;
Jeej 43:28202405094d 247
Jeej 59:b42eae56b51b 248 TYPEDEF_STRUCT_PACKED {
Jeej 59:b42eae56b51b 249 uint8_t fid;
Jeej 59:b42eae56b51b 250 uint32_t length;
Jeej 59:b42eae56b51b 251 uint32_t offset;
Jeej 59:b42eae56b51b 252 uint8_t buf[1];
Jeej 59:b42eae56b51b 253 } d7a_data_t;
Jeej 59:b42eae56b51b 254
Jeej 59:b42eae56b51b 255 // =======================================================================
Jeej 59:b42eae56b51b 256 // d7a_msg_t
Jeej 59:b42eae56b51b 257 // -----------------------------------------------------------------------
Jeej 59:b42eae56b51b 258 /// Response data and meta-data from a device
Jeej 59:b42eae56b51b 259 // =======================================================================
Jeej 59:b42eae56b51b 260 typedef struct
Jeej 59:b42eae56b51b 261 {
Jeej 59:b42eae56b51b 262 /// Error code
Jeej 59:b42eae56b51b 263 int8_t err;
Jeej 59:b42eae56b51b 264 /// Responder's UID
Jeej 59:b42eae56b51b 265 uint8_t id[D7A_UID_LEN];
Jeej 59:b42eae56b51b 266 /// Transmission Link Budget
Jeej 59:b42eae56b51b 267 int8_t lb;
Jeej 61:87be16080640 268 /// Transmission RSSI
Jeej 61:87be16080640 269 int8_t rxlev;
Jeej 59:b42eae56b51b 270 /// Potential data
Jeej 59:b42eae56b51b 271 d7a_data_t* data;
Jeej 59:b42eae56b51b 272 } d7a_msg_t;
Jeej 49:81d5bddb02f0 273
Jeej 49:81d5bddb02f0 274
Jeej 43:28202405094d 275 typedef uint32_t (*WriteFileFunction)( const uint8_t file_id,
Jeej 43:28202405094d 276 const uint16_t offset,
Jeej 43:28202405094d 277 const uint16_t size,
Jeej 43:28202405094d 278 const uint8_t* const content);
Jeej 43:28202405094d 279
Jeej 43:28202405094d 280 typedef uint32_t (*ReadFileFunction)( const uint8_t file_id,
Jeej 43:28202405094d 281 const uint16_t offset,
Jeej 43:28202405094d 282 const uint16_t size,
Jeej 43:28202405094d 283 uint8_t* buf);
Jeej 43:28202405094d 284
Jeej 46:665391110051 285 typedef void (*NotifDoneFunction)( const uint8_t file_id,
Jeej 46:665391110051 286 const uint8_t error);
Jeej 59:b42eae56b51b 287
Jeej 59:b42eae56b51b 288 typedef void (*UnsolicitedMsgFunction)( d7a_msg_t** msg);
Jeej 46:665391110051 289
Jeej 43:28202405094d 290 //======================================================================
Jeej 43:28202405094d 291 // d7a_fs_callbacks_t
Jeej 43:28202405094d 292 //----------------------------------------------------------------------
Jeej 43:28202405094d 293 /// File system callbacks
Jeej 43:28202405094d 294 //======================================================================
Jeej 43:28202405094d 295 typedef struct {
Jeej 43:28202405094d 296 /// Write in local file
Jeej 43:28202405094d 297 WriteFileFunction write_file;
Jeej 43:28202405094d 298 /// Read from local file
Jeej 43:28202405094d 299 ReadFileFunction read_file;
Jeej 49:81d5bddb02f0 300 /// Is called when the notification is finished (depending on the retry policy)
Jeej 46:665391110051 301 NotifDoneFunction notif_done;
Jeej 59:b42eae56b51b 302 /// This function is called when an unsolicited message is catched
Jeej 59:b42eae56b51b 303 UnsolicitedMsgFunction unsolicited_msg;
Jeej 49:81d5bddb02f0 304 } d7a_callbacks_t;
Jeej 43:28202405094d 305
Jeej 43:28202405094d 306 //======================================================================
Jeej 43:28202405094d 307 // fw_version_t
Jeej 43:28202405094d 308 //----------------------------------------------------------------------
Jeej 43:28202405094d 309 /// Firmware version Structure
Jeej 43:28202405094d 310 /// Used within the revision structure
Jeej 43:28202405094d 311 //======================================================================
Jeej 43:28202405094d 312 TYPEDEF_STRUCT_PACKED
Jeej 43:28202405094d 313 {
Jeej 43:28202405094d 314 /// Software identifier
Jeej 43:28202405094d 315 uint8_t id;
Jeej 43:28202405094d 316 /// Version major
Jeej 43:28202405094d 317 uint8_t major;
Jeej 43:28202405094d 318 /// Version minor
Jeej 43:28202405094d 319 uint8_t minor;
Jeej 43:28202405094d 320 /// Version patch
Jeej 43:28202405094d 321 uint16_t patch;
Jeej 43:28202405094d 322 /// Version hash
Jeej 43:28202405094d 323 uint32_t hash;
Jeej 43:28202405094d 324 } fw_version_t;
Jeej 43:28202405094d 325
Jeej 43:28202405094d 326 //======================================================================
Jeej 43:28202405094d 327 // d7a_revision_t
Jeej 43:28202405094d 328 //----------------------------------------------------------------------
Jeej 43:28202405094d 329 /// Revision Structure
Jeej 43:28202405094d 330 ///
Jeej 43:28202405094d 331 /// Usage within D7B server:
Jeej 43:28202405094d 332 /// An XML describing the File system of a device is associated to a
Jeej 43:28202405094d 333 /// couple manufacturer_id/device_id (==Device).
Jeej 43:28202405094d 334 /// Different versions of the Device's XML can exist and can be mapped
Jeej 43:28202405094d 335 /// according to fw_version id/major/minor
Jeej 43:28202405094d 336 //======================================================================
Jeej 43:28202405094d 337 TYPEDEF_STRUCT_PACKED
Jeej 43:28202405094d 338 {
Jeej 43:28202405094d 339 /// Manufacturer ID: provided by Wizzilab
Jeej 43:28202405094d 340 uint32_t manufacturer_id;
Jeej 43:28202405094d 341 /// Device ID: Arbitrary number, at user/customer choice
Jeej 43:28202405094d 342 uint32_t device_id;
Jeej 43:28202405094d 343 /// Hardware Board ID:
Jeej 43:28202405094d 344 uint32_t hw_version;
Jeej 43:28202405094d 345 /// Firmware Version: made of
Jeej 43:28202405094d 346 /// - major,minor and patch indexes : comes from versioning tool
Jeej 43:28202405094d 347 /// - fw_id : "build-flavour" : comes from build setup
Jeej 43:28202405094d 348 /// FW_ID | MAJOR | MINOR | PATCH | HASH |
Jeej 43:28202405094d 349 /// 1B | 1B | 1B | 2B | 4B |
Jeej 43:28202405094d 350 fw_version_t fw_version;
Jeej 43:28202405094d 351 /// "file-system" signature XXX: to be worked out
Jeej 43:28202405094d 352 uint32_t fs_crc;
Jeej 43:28202405094d 353 } d7a_revision_t;
Jeej 43:28202405094d 354
Jeej 43:28202405094d 355
Jeej 43:28202405094d 356 // =======================================================================
Jeej 43:28202405094d 357 // d7a_addressee_ctrl_t
Jeej 43:28202405094d 358 // -----------------------------------------------------------------------
Jeej 43:28202405094d 359 /// Bitfield structure of the Addressee control byte
Jeej 43:28202405094d 360 // =======================================================================
Jeej 43:28202405094d 361 typedef union
Jeej 43:28202405094d 362 {
Jeej 53:3e4aa4b57090 363 /// bit access fields
Jeej 43:28202405094d 364 struct {
Jeej 43:28202405094d 365 /// Network security method
Jeej 43:28202405094d 366 uint8_t nls : 4;
Jeej 43:28202405094d 367 /// ID type
Jeej 43:28202405094d 368 uint8_t idf : 2;
Jeej 43:28202405094d 369 /// RFU
Jeej 43:28202405094d 370 uint8_t rfu_6 : 1;
Jeej 43:28202405094d 371 uint8_t rfu_7 : 1;
Jeej 43:28202405094d 372 } bf;
Jeej 43:28202405094d 373
Jeej 53:3e4aa4b57090 374 /// byte access
Jeej 43:28202405094d 375 uint8_t byte;
Jeej 43:28202405094d 376
Jeej 43:28202405094d 377 } d7a_addressee_ctrl_t;
Jeej 43:28202405094d 378
Jeej 43:28202405094d 379 // =======================================================================
Jeej 43:28202405094d 380 // d7a_xcl_t
Jeej 43:28202405094d 381 // -----------------------------------------------------------------------
Jeej 43:28202405094d 382 /// Bitfield structure of the Addressee Access Class
Jeej 43:28202405094d 383 // =======================================================================
Jeej 43:28202405094d 384 typedef union
Jeej 43:28202405094d 385 {
Jeej 53:3e4aa4b57090 386 /// bit access fields
Jeej 43:28202405094d 387 struct {
Jeej 43:28202405094d 388 /// Subclass mask
Jeej 43:28202405094d 389 uint8_t m : 4;
Jeej 43:28202405094d 390 /// Specifier
Jeej 43:28202405094d 391 uint8_t s : 4;
Jeej 43:28202405094d 392 } bf;
Jeej 43:28202405094d 393
Jeej 53:3e4aa4b57090 394 /// byte access
Jeej 43:28202405094d 395 uint8_t byte;
Jeej 43:28202405094d 396
Jeej 43:28202405094d 397 } d7a_xcl_t;
Jeej 43:28202405094d 398
Jeej 43:28202405094d 399 // =======================================================================
Jeej 43:28202405094d 400 // d7a_addressee_t
Jeej 43:28202405094d 401 // -----------------------------------------------------------------------
Jeej 43:28202405094d 402 /// Structure of the D7ATP Addressee byte
Jeej 43:28202405094d 403 // =======================================================================
Jeej 43:28202405094d 404 TYPEDEF_STRUCT_PACKED
Jeej 43:28202405094d 405 {
Jeej 54:540b327bfa14 406 /// Addressee control byte
Jeej 43:28202405094d 407 d7a_addressee_ctrl_t ctrl;
Jeej 54:540b327bfa14 408 /// Access Class
Jeej 43:28202405094d 409 d7a_xcl_t xcl;
Jeej 54:540b327bfa14 410 /// UID
Jeej 43:28202405094d 411 uint8_t id[D7A_UID_LEN];
Jeej 43:28202405094d 412
Jeej 43:28202405094d 413 } d7a_addressee_t;
Jeej 43:28202405094d 414
Jeej 43:28202405094d 415
Jeej 43:28202405094d 416 //======================================================================
Jeej 43:28202405094d 417 // Prototypes
Jeej 43:28202405094d 418 //======================================================================
Jeej 43:28202405094d 419
Jeej 43:28202405094d 420 //======================================================================
Jeej 43:28202405094d 421 // d7a_open
Jeej 43:28202405094d 422 //----------------------------------------------------------------------
Jeej 43:28202405094d 423 /// @brief Open D7A driver and start the modem
Jeej 53:3e4aa4b57090 424 /// @param com_config Com port configuration structure
Jeej 53:3e4aa4b57090 425 /// @param reset_pin Reset pin
Jeej 53:3e4aa4b57090 426 /// @param callbacks File system callbacks (You cannot use local files if this is not specified)
Jeej 45:b85384e7d825 427 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 428 //======================================================================
Jeej 55:5ea18a3a01b9 429 d7a_errors_t d7a_open(const d7a_com_config_t* com_config,
Jeej 55:5ea18a3a01b9 430 PinName reset_pin,
Jeej 55:5ea18a3a01b9 431 const d7a_callbacks_t* callbacks);
Jeej 43:28202405094d 432
Jeej 43:28202405094d 433 //======================================================================
Jeej 43:28202405094d 434 // d7a_close
Jeej 43:28202405094d 435 //----------------------------------------------------------------------
Jeej 43:28202405094d 436 /// @brief Close D7A driver and stop the modem
Jeej 45:b85384e7d825 437 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 438 //======================================================================
Jeej 45:b85384e7d825 439 d7a_errors_t d7a_close(void);
Jeej 43:28202405094d 440
Jeej 43:28202405094d 441 //======================================================================
Jeej 43:28202405094d 442 // d7a_start
Jeej 43:28202405094d 443 //----------------------------------------------------------------------
Jeej 43:28202405094d 444 /// @brief Start the modem
Jeej 45:b85384e7d825 445 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 446 //======================================================================
Jeej 45:b85384e7d825 447 d7a_errors_t d7a_start(void);
Jeej 43:28202405094d 448
Jeej 43:28202405094d 449 //======================================================================
Jeej 43:28202405094d 450 // d7a_stop
Jeej 43:28202405094d 451 //----------------------------------------------------------------------
Jeej 43:28202405094d 452 /// @brief Stop the modem (goes to low power)
Jeej 45:b85384e7d825 453 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 454 //======================================================================
Jeej 45:b85384e7d825 455 d7a_errors_t d7a_stop(void);
Jeej 43:28202405094d 456
Jeej 43:28202405094d 457 //======================================================================
Jeej 43:28202405094d 458 // d7a_create
Jeej 43:28202405094d 459 //----------------------------------------------------------------------
Jeej 43:28202405094d 460 /// @brief Creates a file on the modem
Jeej 53:3e4aa4b57090 461 /// @param file_id ID of the file to create
Jeej 53:3e4aa4b57090 462 /// @param prop Type of file
Jeej 53:3e4aa4b57090 463 /// @param perm Access permissions
Jeej 53:3e4aa4b57090 464 /// @param size Length of the created file
Jeej 53:3e4aa4b57090 465 /// @param alloc Maximum size of the file
Jeej 55:5ea18a3a01b9 466 /// @param action Type of action to trigger
Jeej 55:5ea18a3a01b9 467 /// @param retry Index to the retry policy to use when notifying
Jeej 45:b85384e7d825 468 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 469 //======================================================================
Jeej 55:5ea18a3a01b9 470 d7a_errors_t d7a_create(const uint8_t file_id,
Jeej 55:5ea18a3a01b9 471 d7a_fs_storage_t prop,
Jeej 55:5ea18a3a01b9 472 d7a_fs_perm_t perm,
Jeej 55:5ea18a3a01b9 473 uint32_t size,
Jeej 55:5ea18a3a01b9 474 uint32_t alloc,
Jeej 55:5ea18a3a01b9 475 d7a_action_t action = D7A_ACTION_NONE,
Jeej 55:5ea18a3a01b9 476 alp_rpol_t retry = ALP_RPOL_ONESHOT);
Jeej 43:28202405094d 477
Jeej 43:28202405094d 478 //======================================================================
Jeej 43:28202405094d 479 // d7a_declare
Jeej 43:28202405094d 480 //----------------------------------------------------------------------
mikl_andre 48:950406be9810 481 /// @brief Declare a file stored on the host to the modem (need to have implemented the fs_callbacks)
Jeej 53:3e4aa4b57090 482 /// @param file_id ID of the file to declare
Jeej 53:3e4aa4b57090 483 /// @param prop Type of file
Jeej 53:3e4aa4b57090 484 /// @param perm Access permissions
Jeej 53:3e4aa4b57090 485 /// @param size Length of the created file
Jeej 53:3e4aa4b57090 486 /// @param alloc Maximum size of the file
Jeej 55:5ea18a3a01b9 487 /// @param action Type of action to trigger
Jeej 55:5ea18a3a01b9 488 /// @param retry Index to the retry policy to use when notifying
Jeej 45:b85384e7d825 489 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 490 //======================================================================
Jeej 55:5ea18a3a01b9 491 d7a_errors_t d7a_declare(const uint8_t file_id,
Jeej 55:5ea18a3a01b9 492 d7a_fs_storage_t prop,
Jeej 55:5ea18a3a01b9 493 d7a_fs_perm_t perm,
Jeej 55:5ea18a3a01b9 494 uint32_t size,
Jeej 55:5ea18a3a01b9 495 uint32_t alloc,
Jeej 55:5ea18a3a01b9 496 d7a_action_t action = D7A_ACTION_NONE,
Jeej 55:5ea18a3a01b9 497 alp_rpol_t retry = ALP_RPOL_ONESHOT);
Jeej 43:28202405094d 498
Jeej 43:28202405094d 499 //======================================================================
Jeej 43:28202405094d 500 // d7a_read
Jeej 43:28202405094d 501 //----------------------------------------------------------------------
Jeej 43:28202405094d 502 /// @brief Read data from a file
Jeej 53:3e4aa4b57090 503 /// @param file_id File ID of file to read
Jeej 53:3e4aa4b57090 504 /// @param offset Offset from which to start reading
Jeej 53:3e4aa4b57090 505 /// @param size Size of data to read
Jeej 53:3e4aa4b57090 506 /// @param buf Buffer to retrieve data
Jeej 53:3e4aa4b57090 507 /// @param addressee Addressee to an eventual distant device
Jeej 53:3e4aa4b57090 508 /// @param retry Index to the retry policy to use
Jeej 45:b85384e7d825 509 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 510 //======================================================================
Jeej 58:38a366236bda 511 d7a_msg_t** d7a_read(const uint8_t file_id,
Jeej 55:5ea18a3a01b9 512 const uint32_t offset,
Jeej 55:5ea18a3a01b9 513 const uint32_t size,
Jeej 55:5ea18a3a01b9 514 d7a_addressee_t* addressee = NULL,
Jeej 55:5ea18a3a01b9 515 alp_rpol_t retry = ALP_RPOL_ONESHOT);
Jeej 43:28202405094d 516
Jeej 43:28202405094d 517 //======================================================================
Jeej 43:28202405094d 518 // d7a_write
Jeej 43:28202405094d 519 //----------------------------------------------------------------------
Jeej 43:28202405094d 520 /// @brief Write data to a file
Jeej 53:3e4aa4b57090 521 /// @param file_id File ID of file to write
Jeej 53:3e4aa4b57090 522 /// @param offset Offset from which to start reading
Jeej 53:3e4aa4b57090 523 /// @param size Size of data to read
Jeej 53:3e4aa4b57090 524 /// @param buf Buffer to retrieve data
Jeej 53:3e4aa4b57090 525 /// @param addressee Addressee to an eventual distant device
Jeej 53:3e4aa4b57090 526 /// @param retry Index to the retry policy to use
Jeej 53:3e4aa4b57090 527 /// @param resp Wait to see if write is OK
Jeej 45:b85384e7d825 528 /// @return d7a_errors_t Error code
Jeej 43:28202405094d 529 //======================================================================
Jeej 58:38a366236bda 530 d7a_msg_t** d7a_write(const uint8_t file_id,
Jeej 55:5ea18a3a01b9 531 const uint32_t offset,
Jeej 55:5ea18a3a01b9 532 const uint32_t size,
Jeej 55:5ea18a3a01b9 533 const uint8_t* const buf,
Jeej 55:5ea18a3a01b9 534 d7a_addressee_t* addressee = NULL,
Jeej 55:5ea18a3a01b9 535 alp_rpol_t retry = ALP_RPOL_ONESHOT,
Jeej 55:5ea18a3a01b9 536 bool resp = true);
Jeej 46:665391110051 537
Jeej 46:665391110051 538 //======================================================================
mikl_andre 48:950406be9810 539 // d7a_notify
Jeej 46:665391110051 540 //----------------------------------------------------------------------
Jeej 46:665391110051 541 /// @brief Write data to a file
Jeej 53:3e4aa4b57090 542 /// @param file_id File ID of file to write
Jeej 53:3e4aa4b57090 543 /// @param offset Offset from which to start writing
Jeej 53:3e4aa4b57090 544 /// @param size Size of data to write
Jeej 46:665391110051 545 /// @return d7a_errors_t Error code
Jeej 46:665391110051 546 //======================================================================
Jeej 55:5ea18a3a01b9 547 d7a_errors_t d7a_notify(const uint8_t file_id,
Jeej 55:5ea18a3a01b9 548 const uint32_t offset = 0,
Jeej 55:5ea18a3a01b9 549 const uint32_t size = 0);
Jeej 43:28202405094d 550
Jeej 60:8d4133fbc060 551 //======================================================================
Jeej 60:8d4133fbc060 552 // d7a_free_msg
Jeej 60:8d4133fbc060 553 //----------------------------------------------------------------------
Jeej 60:8d4133fbc060 554 /// @brief Free the modem infos
Jeej 60:8d4133fbc060 555 /// @param msg message to free
Jeej 60:8d4133fbc060 556 //======================================================================
Jeej 60:8d4133fbc060 557 void d7a_free_msg(d7a_msg_t** msg);
Jeej 50:30440c9aeb7c 558
Jeej 60:8d4133fbc060 559 //======================================================================
Jeej 60:8d4133fbc060 560 // d7a_print_msg
Jeej 60:8d4133fbc060 561 //----------------------------------------------------------------------
Jeej 60:8d4133fbc060 562 /// @brief Prints the message
Jeej 60:8d4133fbc060 563 /// @param msg message to print
Jeej 60:8d4133fbc060 564 //======================================================================
Jeej 60:8d4133fbc060 565 void d7a_print_msg(d7a_msg_t** msg);
Jeej 58:38a366236bda 566
Jeej 50:30440c9aeb7c 567 //======================================================================
Jeej 50:30440c9aeb7c 568 // d7a_modem_print_infos
Jeej 50:30440c9aeb7c 569 //----------------------------------------------------------------------
Jeej 50:30440c9aeb7c 570 /// @brief Prints the modem infos
Jeej 50:30440c9aeb7c 571 //======================================================================
Jeej 50:30440c9aeb7c 572 void d7a_modem_print_infos(void);
Jeej 50:30440c9aeb7c 573
Jeej 50:30440c9aeb7c 574
Jeej 50:30440c9aeb7c 575
Jeej 50:30440c9aeb7c 576
Jeej 43:28202405094d 577 #endif // _D7A_H_