Trond Enger / d7a_1x

Fork of d7a_1x by WizziLab

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers d7a.h Source File

d7a.h

00001 #ifndef _D7A_H_
00002 #define _D7A_H_
00003 
00004 #include "rtos.h"
00005 #include "d7a_common.h"
00006 
00007 //======================================================================
00008 // Defines
00009 //======================================================================
00010 
00011 #define D7A_UID_LEN                 (8)
00012 
00013 // Predefined Access classes
00014 // Normal Rate
00015 #define D7A_XCL_ENDPOINT_NO         (0x01)
00016 #define D7A_XCL_SUBCONTROLLER_NO    (0x02)
00017 #define D7A_XCL_GATEWAY_NO          (0x21)
00018 // Low Rate
00019 #define D7A_XCL_ENDPOINT_LO         (0x11)
00020 #define D7A_XCL_SUBCONTROLLER_LO    (0x12)
00021 #define D7A_XCL_GATEWAY_LO          (0x31)
00022 // High Rate
00023 #define D7A_XCL_ENDPOINT_HI         (0x41)
00024 #define D7A_XCL_SUBCONTROLLER_HI    (0x42)
00025 #define D7A_XCL_GATEWAY_HI          (0x51)
00026 
00027 #define D7A_CTF_VAL(mant,exp)       ((uint8_t)(mant|(exp<<5)))
00028 
00029 #define D7A_NBID(nbid)              (nbid >= 32)? D7A_CTF_VAL(8,1) : D7A_CTF_VAL(nbid,0)
00030 
00031 #define D7A_ROOT_KEY_SIZE           (16)
00032 
00033 // Predefined interface files
00034 #define FIRST_IFT_FILE              (108)
00035 
00036 #define D7A_ITF_ONESHOT             (108)
00037 #define D7A_ITF_SINGLE              (109)
00038 #define D7A_ITF_REPORT              (110)
00039 #define D7A_ITF_REPORT_CHECKED      (111)
00040 #define D7A_ITF_BULK                (112)
00041 #define D7A_ITF_BLINK               (113)
00042 
00043 #define D7A_FID_ALP_CFG             (50)
00044 
00045 
00046 //======================================================================
00047 // Enums
00048 //======================================================================
00049 
00050 //======================================================================
00051 // d7a_fs_storage_t
00052 //----------------------------------------------------------------------
00053 /// File "Storage Class"
00054 //======================================================================
00055 typedef enum {
00056     /// No data is keeped. Write only!
00057     /// Ex: Use for commands.
00058     TRANSIENT = 0,
00059     /// Data is stocked in RAM and initialized at 0.
00060     /// Can not guarantee data integrity over time.
00061     /// Ex: Use for often updated data.
00062     VOLATILE,
00063     /// Data is stocked in RAM and initialized with the last flushed data from EEPROM.
00064     /// Can not guarantee data integrity over time.
00065     /// Ex: Use for temporary configurations.
00066     RESTORABLE,
00067     /// Data is stoked in EEPROM.
00068     /// Data integrity is guaranteed.
00069     /// Ex: Use for important configurations.
00070     /// /!\ Use sparingly as operations on these type of files are time and ressource consuming
00071     PERMANENT
00072 } d7a_fs_storage_t;
00073 
00074 //======================================================================
00075 // d7a_fs_perm_t
00076 //----------------------------------------------------------------------
00077 /// File permissions for USER/GUEST
00078 //======================================================================
00079 typedef enum {
00080     O_O                = 0b11000000,
00081     R_O                = 0b11100000,
00082     R_R                = 0b11100100,
00083     W_O                = 0b11010000,
00084     W_W                = 0b11010010,
00085     RW_O               = 0b11110000,
00086     RW_R               = 0b11110100,
00087     RW_W               = 0b11110010,
00088     RW_RW              = 0b11110110,
00089     RWX_O              = 0b11111000,
00090     RWX_RWX            = 0b11111111,
00091 } d7a_fs_perm_t;
00092 
00093 // =======================================================================
00094 // d7a_nls_t
00095 // -----------------------------------------------------------------------
00096 /// Enumerator of the NWL security modes
00097 // =======================================================================
00098 typedef enum
00099 {
00100     /// No security enabled
00101     D7A_NLS_NO = 0,
00102     /// Encryption only, Counter Mode
00103     D7A_NLS_AES_CTR,
00104     /// No encryption, Authentication, Cipher-block chaining with 128 bit MAC
00105     D7A_NLS_AES_CBC_MAC_128,
00106     /// No encryption, Authentication, Cipher-block chaining with 64 bit MAC
00107     D7A_NLS_AES_CBC_MAC_64,
00108     /// No encryption, Authentication, Cipher-block chaining with 32 bit MAC
00109     D7A_NLS_AES_CBC_MAC_32,
00110     /// Authentication with CBC-MAC-128 and Encryption with Counter Mode
00111     D7A_NLS_AES_CCM_128,
00112     /// Authentication with CBC-MAC-64 and Encryption with Counter Mode
00113     D7A_NLS_AES_CCM_64,
00114     /// Authentication with CBC-MAC-32 and Encryption with Counter Mode
00115     D7A_NLS_AES_CCM_32,
00116     /// QTY
00117     D7A_NLS_QTY
00118 
00119 } d7a_nls_t;
00120 
00121 
00122 // Mimic ALP Errors
00123 typedef enum
00124 {
00125     D7A_ERR_ITF_FULL                    =  2, // 0x02: For interfaces supporting buffering, indicates buffer reached maximum capacity (no data loss)
00126     D7A_ERR_PARTIAL_COMPLETION          =  1, // 0x01: Action received and partially completed at response.  To be completed after response
00127 
00128     D7A_ERR_NONE                        =  0, // 0x00: Action completed (OK)
00129     D7A_ERR_FILE_NOT_FOUND              = -1, // 0xFF: Error access file: File ID does not exist
00130     D7A_ERR_FILE_EXIST                  = -2, // 0xFE: Error create file: File ID already exists
00131     D7A_ERR_FILE_NOT_RESTORABLE         = -3, // 0xFD: Error restore file: File is not restorable
00132     D7A_ERR_PERMISSION_DENIED           = -4, // 0xFC: Error access file: Insufficient permissions
00133     D7A_ERR_LENGTH_OVERFLOW             = -5, // 0xFB: Error create file: Supplied length (in header) is beyond file limits
00134     D7A_ERR_ALLOC_OVERFLOW              = -6, // 0xFA: Error create file: Supplied allocation (in header) is beyond file limits
00135     D7A_ERR_OFFSET_OVERFLOW             = -7, // 0xF9: Error write: Supplied start offset is out of bounds of file allocation
00136     D7A_ERR_WRITE_OVERFLOW              = -8, // 0xF8: Error complete write: Supplied data goes beyond file allocation
00137     D7A_ERR_WRITE_ERROR                 = -9, // 0xF7: Error write: impossible to write in storage location
00138     D7A_ERR_OPERATION_UNKNOWN           = -10,// 0xF6: Error unknown Operation
00139     D7A_ERR_OPERAND_INCOMPLETE          = -11,// 0xF5: Error incomplete Operand
00140     D7A_ERR_OPERAND_WRONG_FORMAT        = -12,// 0xF4: Error wrong Operand format
00141     D7A_ERR_ITF_INVALID                 = -13,// 0xF3: Error invalid interface
00142     D7A_ERR_ITF_OVERFLOW                = -14,// 0xF2: Error interface overflown (i.e. ressources exhausted, buffer full with data discarded)
00143     D7A_ERR_QUERY_FAIL                  = -15,// 0xF1: (Group of) Query result was false (Informative error code).
00144 
00145     D7A_ERR_UNKNOWN                     = -128,// 0x80: Unknown error
00146     D7A_ERR_FS_TIMEOUT                  ,// 0x81: Internal FS Error
00147     D7A_ERR_ITF_UNKNOWN                 ,// 0x82: Unknown Interface
00148     
00149     // Modem errors
00150     D7A_ERR_NOT_READY                   ,// The modem is not ready to recieve commands
00151     D7A_ERR_COM_LINK                    ,// A serial link timeout occured
00152     D7A_ERR_ILLEGAL_FID                 ,// The FID specified is illegal
00153     D7A_ERR_ILLEGAL_FILE_DEF            ,// The FILE parameters specified are illegal
00154     D7A_ERR_CMD_TO                      ,// The command expired
00155     D7A_ERR_TX_FAILED                   ,// Transmission failed
00156     D7A_ERR_STATE                       ,// The device is not in the right state to execute the command
00157     
00158 } d7a_errors_t;
00159 
00160 
00161 
00162 TYPEDEF_STRUCT_PACKED {
00163     struct {
00164         /// Backoff time generator for retry attempts
00165         /// - if '0': No backoff
00166         /// - if '1': Linear backoff, retry every slot_time seconds
00167         /// - if '2': RFU
00168         /// - if '3': RFU
00169         uint8_t procedure    : 4;
00170         /// On transmission success or at the end of the retry procedure:
00171         /// - if '1': a response is generated to requester (source ITF)
00172         /// - if '0': nothing notified to the source
00173         uint8_t respond      : 1;
00174         /// On transmission success or at the end of the retry procedure:
00175         /// - if '1': Session fifo remains opened for further messaging
00176         /// - if '0': Session fifo is closed/released
00177         uint8_t persistant   : 1;
00178         /// When a payload is send to an ITF that implements buffering,
00179         /// if 'bulk' is set the ITF should not start actual transfer until
00180         /// buffer is full.
00181         uint8_t bulk         : 1;
00182 
00183         uint8_t rfu          : 1;
00184     } meta;
00185     /// Number of "pushed" messages that will be internally buffered
00186     /// until they are successfully sent. In case of overflow, the oldest
00187     /// message is lost.
00188     uint8_t depth;
00189     /// Maximum number of retry steps
00190     uint8_t retries;
00191     /// Unit of time (in second) used for Backoff time calculation
00192     uint8_t slot_time;
00193 } alp_retry_policy_t;
00194 
00195 
00196 /// Types of retry policies
00197 /// Respond: When finished the host will be notified
00198 /// Persist: When finished on error data is kept in the queue for next transmission
00199 /// Depth:   Number of commands kept in the queue
00200 /// Bulk:    Notifications sent only when the queue is full
00201 /// Retries: Number of retries after initial transmission (if 0 no backoff, else linear backoff)
00202 /// Slot:    Time between retries (sec)
00203 typedef enum {
00204     /// Respond: true
00205     /// Persist: false
00206     /// Depth:   1
00207     /// Bulk:    false
00208     /// Retries: 0
00209     /// Slot:    0
00210     ALP_RPOL_ONESHOT,
00211     
00212     /// Respond: true
00213     /// Persist: false
00214     /// Depth:   1
00215     /// Bulk:    false
00216     /// Retries: 3
00217     /// Slot:    2
00218     ALP_RPOL_SINGLE,
00219     
00220     /// Respond: true
00221     /// Persist: false
00222     /// Depth:   1
00223     /// Bulk:    false
00224     /// Retries: 3
00225     /// Slot:    2
00226     ALP_RPOL_REPORT,
00227     
00228     /// Respond: false
00229     /// Persist: true
00230     /// Depth:   4
00231     /// Bulk:    false
00232     /// Retries: 16
00233     /// Slot:    20
00234     ALP_RPOL_REPORT_CHECKED,
00235     
00236     /// Respond: true
00237     /// Persist: false
00238     /// Depth:   4
00239     /// Bulk:    true
00240     /// Retries: 0
00241     /// Slot:    1
00242     ALP_RPOL_BULK,
00243     
00244     ALP_RPOL_SPARE_5,
00245     ALP_RPOL_SPARE_6,
00246     
00247     /// Respond: false
00248     /// Persist: false
00249     /// Depth:   1
00250     /// Bulk:    false
00251     /// Retries: 0
00252     /// Slot:    1
00253     ALP_RPOL_BLINK,
00254 
00255     ALP_RPOL_QTY,
00256 } alp_rpol_t;
00257 
00258 
00259 /// Action when file notifying
00260 typedef enum {
00261     D7A_ACTION_NONE = 0,
00262     /// Notify the whole file
00263     D7A_NOTIFICATION_FULL = 100,
00264     /// Notify only part of the file
00265     D7A_NOTIFICATION_PART
00266 } d7a_action_t;
00267 
00268 
00269 // =======================================================================
00270 // d7a_id_t
00271 // -----------------------------------------------------------------------
00272 // Identifier types enumerator
00273 // =======================================================================
00274 typedef enum
00275 {
00276     // Void identifier (broadcast) 
00277     // with indication of number of reached devices
00278     D7A_ID_NBID = 0,
00279     // Void identifier (broadcast)
00280     D7A_ID_NOID = 1,
00281     // Unique Identifier
00282     D7A_ID_UID  = 2,
00283     // Virtual identifier
00284     D7A_ID_VID  = 3,
00285 
00286 } d7a_id_t;
00287 
00288 //======================================================================
00289 // Structures
00290 //======================================================================
00291 
00292 //======================================================================
00293 // d7a_com_config_t
00294 //----------------------------------------------------------------------
00295 /// Com port configuration structure
00296 //======================================================================
00297 typedef struct {
00298      /// Tx pin
00299      PinName tx;
00300      /// RX pin
00301      PinName rx;
00302      /// WKUP pin
00303      PinName rts;
00304      /// HST_WKUP pin
00305      PinName cts;
00306 } d7a_com_config_t;
00307 
00308 TYPEDEF_STRUCT_PACKED {
00309     uint8_t fid;
00310     uint32_t length;
00311     uint32_t offset;
00312     uint8_t buf[1];
00313 } d7a_data_t;
00314 
00315 // =======================================================================
00316 // d7a_msg_t
00317 // -----------------------------------------------------------------------
00318 /// Response data and meta-data from a device
00319 // =======================================================================
00320 typedef struct
00321 {
00322     /// Error code
00323     int8_t err;
00324     /// Responder's UID
00325     uint8_t id[D7A_UID_LEN];
00326     /// Transmission Link Budget
00327     int8_t lb;
00328     /// Transmission RSSI
00329     int8_t rxlev;
00330     /// Potential data
00331     d7a_data_t* data;
00332 } d7a_msg_t;
00333 
00334 
00335 typedef uint32_t (*WriteFileFunction)(  const uint8_t file_id,
00336                                         const uint16_t offset,
00337                                         const uint16_t size,
00338                                         const uint8_t* const content);
00339                                             
00340 typedef uint32_t (*ReadFileFunction)(   const uint8_t file_id,
00341                                         const uint16_t offset,
00342                                         const uint16_t size,
00343                                         uint8_t* buf);
00344 
00345 typedef void (*NotifDoneFunction)(      const uint8_t file_id,
00346                                         const uint8_t error);
00347                                         
00348 typedef void (*UnsolicitedMsgFunction)( d7a_msg_t** msg);
00349 
00350 //======================================================================
00351 // d7a_fs_callbacks_t
00352 //----------------------------------------------------------------------
00353 /// File system callbacks
00354 //======================================================================
00355 typedef struct {
00356     /// Write in local file
00357     WriteFileFunction   write_file;
00358     /// Read from local file
00359     ReadFileFunction    read_file;
00360     /// Is called when the notification is finished (depending on the retry policy)
00361     NotifDoneFunction   notif_done;
00362     /// This function is called when an unsolicited message is catched
00363     UnsolicitedMsgFunction unsolicited_msg;
00364 } d7a_callbacks_t;
00365 
00366 //======================================================================
00367 // fw_version_t
00368 //----------------------------------------------------------------------
00369 /// Firmware version Structure
00370 /// Used within the revision structure
00371 //======================================================================
00372 TYPEDEF_STRUCT_PACKED
00373 {
00374     /// Software identifier
00375     uint8_t  id;
00376     /// Version major
00377     uint8_t  major;
00378     /// Version minor
00379     uint8_t  minor;
00380     /// Version patch
00381     uint16_t patch;
00382     /// Version hash
00383     uint32_t hash;
00384 } fw_version_t;
00385 
00386 //======================================================================
00387 // d7a_revision_t
00388 //----------------------------------------------------------------------
00389 /// Revision Structure
00390 ///
00391 /// Usage within D7B server:
00392 /// An XML describing the File system of a device is associated to a
00393 /// couple manufacturer_id/device_id (==Device).
00394 /// Different versions of the Device's XML can exist and can be mapped
00395 /// according to fw_version id/major/minor
00396 //======================================================================
00397 TYPEDEF_STRUCT_PACKED
00398 {
00399     /// Manufacturer ID: provided by Wizzilab
00400     uint32_t manufacturer_id;
00401     /// Device ID: Arbitrary number, at user/customer choice
00402     uint32_t device_id;
00403     /// Hardware Board ID:
00404     uint32_t hw_version;
00405     /// Firmware Version: made of
00406     ///  - major,minor and patch indexes : comes from versioning tool
00407     ///  - fw_id : "build-flavour" : comes from build setup
00408     ///  FW_ID | MAJOR | MINOR | PATCH | HASH |
00409     ///    1B  |  1B   |  1B   |   2B  |  4B  |
00410     fw_version_t fw_version;
00411     /// "file-system" signature XXX: to be worked out
00412     uint32_t fs_crc;
00413 } d7a_revision_t;
00414 
00415 
00416 // =======================================================================
00417 // d7a_addressee_ctrl_t
00418 // -----------------------------------------------------------------------
00419 /// Bitfield structure of the Addressee control byte
00420 // =======================================================================
00421 typedef union
00422 {
00423     /// bit access fields
00424     struct {
00425         /// Network security method
00426         uint8_t nls      : 4;
00427         /// ID type
00428         uint8_t idf      : 2;
00429         /// RFU
00430         uint8_t rfu_6    : 1;
00431         uint8_t rfu_7    : 1;
00432     } bf;
00433 
00434     /// byte access
00435     uint8_t byte;
00436 
00437 } d7a_addressee_ctrl_t;
00438 
00439 // =======================================================================
00440 // d7a_xcl_t
00441 // -----------------------------------------------------------------------
00442 /// Bitfield structure of the Addressee Access Class
00443 // =======================================================================
00444 typedef union
00445 {
00446     /// bit access fields
00447     struct {
00448         /// Subclass mask
00449         uint8_t m    : 4;
00450         /// Specifier
00451         uint8_t s    : 4;
00452     } bf;
00453 
00454     /// byte access
00455     uint8_t byte;
00456 
00457 } d7a_xcl_t;
00458 
00459 // =======================================================================
00460 // d7a_addressee_t
00461 // -----------------------------------------------------------------------
00462 /// Structure of the D7ATP Addressee byte
00463 // =======================================================================
00464 TYPEDEF_STRUCT_PACKED
00465 {
00466     /// Addressee control byte
00467     d7a_addressee_ctrl_t ctrl;
00468     /// Access Class
00469     d7a_xcl_t xcl;
00470     /// UID
00471     uint8_t id[D7A_UID_LEN];
00472 
00473 } d7a_addressee_t;
00474 
00475 
00476 // =======================================================================
00477 // d7a_ctf_t
00478 // -----------------------------------------------------------------------
00479 // DLL compressed time format
00480 // =======================================================================
00481 typedef union
00482 {
00483     // bit access fields
00484     struct {
00485         // Mantissa
00486         uint8_t mant : 5;
00487         // Exponent
00488         uint8_t exp  : 3;
00489     } bf;
00490 
00491     // byte access
00492     uint8_t byte;
00493 
00494 } d7a_ctf_t;
00495 
00496 // =======================================================================
00497 // d7a_qos_t
00498 // -----------------------------------------------------------------------
00499 // Bitfield structure of the D7ASP Quality of Service control byte
00500 // =======================================================================
00501 typedef union
00502 {
00503     // bit access fields
00504     struct {
00505         // Response mode
00506         uint8_t resp         : 3;
00507         // Retry mode
00508         uint8_t retry        : 3;
00509         // Responder has to keep the ACK template (TPL status file)
00510         uint8_t record       : 1;
00511          // Stop D7ASP on not acknowledged request
00512         uint8_t stop_on_err  : 1;
00513 
00514     } bf;
00515 
00516     // byte access
00517     uint8_t byte;
00518 
00519 } d7a_qos_t;
00520 
00521 
00522 // =======================================================================
00523 // d7a_sp_cfg_t
00524 // -----------------------------------------------------------------------
00525 // Structure of the D7ASP Configuration
00526 // =======================================================================
00527 TYPEDEF_STRUCT_PACKED
00528 {
00529     // D7ASP QoS
00530     d7a_qos_t qos;
00531     // Dormant Timeout (0, no timeout)
00532     d7a_ctf_t to;
00533     // Response execution delay
00534     d7a_ctf_t te;
00535     // Addressee
00536     d7a_addressee_t addressee;
00537 
00538 } d7a_sp_cfg_t;
00539 
00540 // =======================================================================
00541 // d7a_itf_t
00542 // -----------------------------------------------------------------------
00543 // ALP/D7A Interface file TODO:should be in alp_d7a.h when/if it exists
00544 //                             but not in alp.h as it requires D7A
00545 // ====================================================================
00546 TYPEDEF_STRUCT_PACKED {
00547     uint8_t type;
00548     d7a_sp_cfg_t cfg;
00549 } d7a_itf_t;
00550 
00551 
00552 // =======================================================================
00553 // d7a_resp_t
00554 // -----------------------------------------------------------------------
00555 // Enumerator of the D7ASP Response types
00556 // =======================================================================
00557 typedef enum
00558 {
00559     // No response requested
00560     D7A_RESP_NO = 0,
00561     // Get all responses in response period
00562     D7A_RESP_ALL,
00563     // Get at least one acknowledgement per request during response period
00564     D7A_RESP_ANY,
00565     // RFU
00566     D7A_RESP_RFU_1,
00567     // No response requested, repeat 3 times
00568     D7A_RESP_NO_RPT,
00569     // Get all responses in response period, only Responders having not received packets respond
00570     D7A_RESP_ON_ERR,
00571     // Get at least one acknowledgement per request during response period. 
00572     // Stick to a single responder when possible
00573     D7A_RESP_PREFERRED,
00574     // RFU
00575     D7A_RESP_RFU_2,
00576 
00577 } d7a_resp_t;
00578 
00579 
00580 //======================================================================
00581 // Prototypes
00582 //======================================================================
00583 
00584 //======================================================================
00585 // d7a_open
00586 //----------------------------------------------------------------------
00587 /// @brief                      Open D7A driver and start the modem
00588 /// @param com_config           Com port configuration structure
00589 /// @param reset_pin            Reset pin
00590 /// @param callbacks            File system callbacks (You cannot use local files if this is not specified)
00591 /// @return d7a_errors_t        Error code
00592 //======================================================================
00593 d7a_errors_t d7a_open(const d7a_com_config_t* com_config, 
00594                       PinName reset_pin, 
00595                       const d7a_callbacks_t* callbacks);
00596 
00597 //======================================================================
00598 // d7a_close
00599 //----------------------------------------------------------------------
00600 /// @brief                      Close D7A driver and stop the modem
00601 /// @return d7a_errors_t        Error code
00602 //======================================================================
00603 d7a_errors_t d7a_close(void);
00604 
00605 //======================================================================
00606 // d7a_start
00607 //----------------------------------------------------------------------
00608 /// @brief                      Start the modem
00609 /// @return d7a_errors_t        Error code
00610 //======================================================================
00611 d7a_errors_t d7a_start(void);
00612 
00613 //======================================================================
00614 // d7a_stop
00615 //----------------------------------------------------------------------
00616 /// @brief                      Stop the modem (goes to low power)
00617 /// @return d7a_errors_t        Error code
00618 //======================================================================
00619 d7a_errors_t d7a_stop(void);
00620 
00621 //======================================================================
00622 // d7a_create
00623 //----------------------------------------------------------------------
00624 /// @brief                      Creates a file on the modem
00625 /// @param file_id              ID of the file to create
00626 /// @param prop                 Type of file
00627 /// @param perm                 Access permissions
00628 /// @param size                 Length of the created file
00629 /// @param alloc                Maximum size of the file
00630 /// @param action               Type of action to trigger
00631 /// @param interface            File ID of the interface file to use for notifications
00632 /// @return d7a_errors_t        Error code
00633 //======================================================================
00634 d7a_errors_t d7a_create(const uint8_t file_id,
00635                         d7a_fs_storage_t prop,
00636                         d7a_fs_perm_t perm, 
00637                         uint32_t size, 
00638                         uint32_t alloc, 
00639                         d7a_action_t action = D7A_ACTION_NONE,
00640                         const uint8_t interface = D7A_ITF_ONESHOT);
00641 
00642 //======================================================================
00643 // d7a_declare
00644 //----------------------------------------------------------------------
00645 /// @brief                      Declare a file stored on the host to the modem (need to have implemented the fs_callbacks)
00646 /// @param file_id              ID of the file to declare
00647 /// @param prop                 Type of file
00648 /// @param perm                 Access permissions
00649 /// @param size                 Length of the created file
00650 /// @param alloc                Maximum size of the file
00651 /// @param action               Type of action to trigger
00652 /// @param interface            File ID of the interface file to use for notifications
00653 /// @return d7a_errors_t        Error code
00654 //======================================================================
00655 d7a_errors_t d7a_declare(const uint8_t file_id, 
00656                          d7a_fs_storage_t prop, 
00657                          d7a_fs_perm_t perm, 
00658                          uint32_t size, 
00659                          uint32_t alloc, 
00660                          d7a_action_t action = D7A_ACTION_NONE, 
00661                          const uint8_t interface = D7A_ITF_ONESHOT);
00662 
00663 //======================================================================
00664 // d7a_read
00665 //----------------------------------------------------------------------
00666 /// @brief                      Read data from a file
00667 /// @param file_id              File ID of file to read
00668 /// @param offset               Offset from which to start reading
00669 /// @param size                 Size of data to read
00670 /// @param buf                  Buffer to retrieve data
00671 /// @param addressee            Addressee to an eventual distant device
00672 /// @param retry                Index to the retry policy to use
00673 /// @return d7a_errors_t        Error code
00674 //======================================================================
00675 d7a_msg_t** d7a_read(const uint8_t file_id, 
00676                       const uint32_t offset, 
00677                       const uint32_t size,
00678                       const uint8_t* root_key = NULL,
00679                       d7a_addressee_t* addressee = NULL, 
00680                       alp_rpol_t retry = ALP_RPOL_ONESHOT);
00681 
00682 //======================================================================
00683 // d7a_write
00684 //----------------------------------------------------------------------
00685 /// @brief                      Write data to a file
00686 /// @param file_id              File ID of file to write
00687 /// @param offset               Offset from which to start reading
00688 /// @param size                 Size of data to read
00689 /// @param buf                  Buffer to retrieve data
00690 /// @param addressee            Addressee to an eventual distant device
00691 /// @param retry                Index to the retry policy to use
00692 /// @param resp                 Wait to see if write is OK
00693 /// @return d7a_errors_t        Error code
00694 //======================================================================
00695 d7a_msg_t** d7a_write(const uint8_t file_id,
00696                        const uint32_t offset,
00697                        const uint32_t size,
00698                        const uint8_t* const buf,
00699                        const uint8_t* root_key = NULL,
00700                        d7a_addressee_t* addressee = NULL, 
00701                        alp_rpol_t retry = ALP_RPOL_ONESHOT, 
00702                        bool resp = true);
00703 
00704 d7a_msg_t** d7a_flush(const uint8_t file_id,
00705                         const uint8_t* root_key = NULL,
00706                         d7a_addressee_t* addressee = NULL,
00707                         alp_rpol_t retry = ALP_RPOL_ONESHOT,
00708                         bool resp = true);
00709 
00710 //======================================================================
00711 // d7a_notify
00712 //----------------------------------------------------------------------
00713 /// @brief                      Write data to a file
00714 /// @param file_id              File ID of file to write
00715 /// @param offset               Offset from which to start writing
00716 /// @param size                 Size of data to write
00717 /// @return d7a_errors_t        Error code
00718 //======================================================================
00719 d7a_errors_t d7a_notify(const uint8_t file_id, 
00720                         const uint32_t offset = 0, 
00721                         const uint32_t size = 0);
00722 
00723 //======================================================================
00724 // d7a_free_msg
00725 //----------------------------------------------------------------------
00726 /// @brief                      Free the message
00727 /// @param msg                  message to free
00728 //======================================================================
00729 void d7a_free_msg(d7a_msg_t** msg);
00730 
00731 //======================================================================
00732 // d7a_print_msg
00733 //----------------------------------------------------------------------
00734 /// @brief                      Prints the message
00735 /// @param msg                  message to print
00736 //======================================================================
00737 void d7a_print_msg(d7a_msg_t** msg);
00738 
00739 //======================================================================
00740 // d7a_modem_print_infos
00741 //----------------------------------------------------------------------
00742 /// @brief                      Prints the modem infos
00743 //======================================================================
00744 void d7a_modem_print_infos(void);
00745 
00746 //======================================================================
00747 // d7a_modem_print_infos
00748 //----------------------------------------------------------------------
00749 /// @brief                      Wait for modem to finish boot
00750 //======================================================================
00751 d7a_errors_t d7a_wait_ready(uint32_t millisec = osWaitForever);
00752 
00753 
00754 #endif // _D7A_H_