Exportable version of WizziLab's modem driver.

Dependents:   modem_ref_helper

Committer:
Jeej
Date:
Mon Jun 04 15:32:05 2018 +0000
Revision:
30:74aa36420c61
Parent:
25:14c01b9fc04d
Child:
31:517fc900afba
Updated to v5.1.174

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 19:701d5669f2e9 1 /// @copyright
Jeej 19:701d5669f2e9 2 /// ========================================================================={{{
Jeej 19:701d5669f2e9 3 /// Copyright (c) 2013-2016 WizziLab /
Jeej 19:701d5669f2e9 4 /// All rights reserved /
Jeej 19:701d5669f2e9 5 /// =========================================================================}}}
Jeej 19:701d5669f2e9 6 /// @endcopyright
Jeej 19:701d5669f2e9 7
Jeej 19:701d5669f2e9 8 // =======================================================================
Jeej 19:701d5669f2e9 9 /// @file modem_ref.h
Jeej 19:701d5669f2e9 10 /// @brief Wizzilab Modem Reference Driver Implementation
Jeej 19:701d5669f2e9 11 /// Source code should be disclosable and easily portable to
Jeej 19:701d5669f2e9 12 /// any architecture.
Jeej 19:701d5669f2e9 13 // =======================================================================
Jeej 19:701d5669f2e9 14
Jeej 19:701d5669f2e9 15 #ifndef __MODEM_REF_DRV_H__
Jeej 19:701d5669f2e9 16 #define __MODEM_REF_DRV_H__
Jeej 19:701d5669f2e9 17
Jeej 19:701d5669f2e9 18 #include "hal_types.h"
Jeej 19:701d5669f2e9 19
Jeej 19:701d5669f2e9 20 #include "alp_spec.h"
Jeej 19:701d5669f2e9 21 #include "alp_helpers.h"
Jeej 19:701d5669f2e9 22
Jeej 19:701d5669f2e9 23 // Stuff depending on implementation
Jeej 19:701d5669f2e9 24 #ifdef _ARCH_WIZZILAB_
Jeej 19:701d5669f2e9 25 // Map debug features on Wizzilab's kernel
Jeej 19:701d5669f2e9 26 #include "kal.h"
Jeej 19:701d5669f2e9 27 #define L_API (1 << 1)
Jeej 19:701d5669f2e9 28 #define L_URC (1 << 2)
Jeej 19:701d5669f2e9 29 #define L_SER (1 << 3)
Jeej 19:701d5669f2e9 30 #define ASSERT(c,...) kal_dbg_assert(c, ##__VA_ARGS__)
Jeej 19:701d5669f2e9 31 #define DPRINT(l,...) do {kal_dbg_cprintf(TLEV(7,l), ##__VA_ARGS__);} while(0)
Jeej 19:701d5669f2e9 32 #define MALLOC(s) kal_malloc(s)
Jeej 19:701d5669f2e9 33 #define FREE(s) kal_free(s)
Jeej 19:701d5669f2e9 34 #else
Jeej 19:701d5669f2e9 35 // TODO Map on host architecture
Jeej 19:701d5669f2e9 36 #endif
Jeej 19:701d5669f2e9 37
Jeej 19:701d5669f2e9 38 // Maximum number of concurrent 'users'
Jeej 19:701d5669f2e9 39 #define MAX_USER_NB (8)
Jeej 19:701d5669f2e9 40
Jeej 19:701d5669f2e9 41 // Depending on Host needs/capacities, choose variable-size buffer allocation style
Jeej 19:701d5669f2e9 42 #if 1 // Auto stack alloc
Jeej 19:701d5669f2e9 43 #define MAX_CMD_BUFFER_SIZE 256
Jeej 19:701d5669f2e9 44 #define ALLOC_BUFFER(_t,_b,_size) _t _b[MAX_CMD_BUFFER_SIZE];
Jeej 19:701d5669f2e9 45 //#define ALLOC_BUFFER(_t,_b,_size) _t _b[_size]; // If VLA available...
Jeej 19:701d5669f2e9 46 #define DEALLOC_BUFFER(_b)
Jeej 19:701d5669f2e9 47 #else // Dynamic alloc
Jeej 19:701d5669f2e9 48 #define ALLOC_BUFFER(_t,_b,_size) _t* _b = MALLOC(_size);
Jeej 19:701d5669f2e9 49 #define DEALLOC_BUFFER(_b) FREE(_b);
Jeej 19:701d5669f2e9 50 #endif
Jeej 19:701d5669f2e9 51
Jeej 19:701d5669f2e9 52 //======================================================================
Jeej 19:701d5669f2e9 53 // Modem Serial Link input/output functions
Jeej 19:701d5669f2e9 54 //==================================================================={{{
Jeej 19:701d5669f2e9 55 // ALP protocol is conveyed on serial link encapsulated in WizziCom (WC)
Jeej 19:701d5669f2e9 56 // packets.
Jeej 19:701d5669f2e9 57 // WC Serial protocol:
Jeej 19:701d5669f2e9 58 // +--------------+--------+--------+--------+---- - - - - - - - - - - --------+
Jeej 19:701d5669f2e9 59 // | SYNC | LEN | SEQ | FLOWID | PAYLOAD |
Jeej 19:701d5669f2e9 60 // +--------------+--------+--------+--------+---- - - - - - - - - - - --------+
Jeej 19:701d5669f2e9 61 // | 2 bytes | 1 byte | 1 byte | 1 byte | LEN bytes |
Jeej 19:701d5669f2e9 62 // |<------------>|<------>|<------>|<------>|<--- - - - - - - - - - - ------->|
Jeej 19:701d5669f2e9 63 #define WC_SYNC_BYTE_0 0x01
Jeej 19:701d5669f2e9 64 #define WC_SYNC_BYTE_1 0x1F
Jeej 19:701d5669f2e9 65 #define WC_HEADER_SIZE 5
Jeej 19:701d5669f2e9 66
Jeej 19:701d5669f2e9 67 #define WC_SYNC0_OFFSET 0
Jeej 19:701d5669f2e9 68 #define WC_SYNC1_OFFSET 1
Jeej 19:701d5669f2e9 69 #define WC_LEN_OFFSET 2
Jeej 19:701d5669f2e9 70 #define WC_SEQ_OFFSET 3
Jeej 19:701d5669f2e9 71 #define WC_FLOWID_OFFSET 4
Jeej 19:701d5669f2e9 72
Jeej 19:701d5669f2e9 73 // Input:Serial-traffic coming from Modem must be packetized in WC chuncks
Jeej 19:701d5669f2e9 74 // before being sent to modem-driver through 'modem_input'.
Jeej 19:701d5669f2e9 75 // An example deserializer can be found in "wc_deserialized.c".
Jeej 19:701d5669f2e9 76 //======================================================================
Jeej 19:701d5669f2e9 77 // modem_input
Jeej 19:701d5669f2e9 78 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 79 /// @brief Parse packets and handles calls to relevant callbacks.
Jeej 19:701d5669f2e9 80 /// @param flowid : WizziCom FlowID.
Jeej 19:701d5669f2e9 81 /// @param payload : pointer to payload buffer.
Jeej 19:701d5669f2e9 82 /// @param size : payload size in bytes.
Jeej 19:701d5669f2e9 83 //======================================================================
Jeej 19:701d5669f2e9 84 protected void modem_input(u8 flowid,u8* payload,u8 size);
Jeej 19:701d5669f2e9 85
Jeej 19:701d5669f2e9 86 // Output:Modem-driver sends data to Modem through calls to the 'send'
Jeej 19:701d5669f2e9 87 // function passed in 'modem_open'.
Jeej 19:701d5669f2e9 88 // 'send' must be provided by the host application.
Jeej 19:701d5669f2e9 89 //======================================================================
Jeej 19:701d5669f2e9 90 // fx_serial_send_t
Jeej 19:701d5669f2e9 91 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 92 /// @brief Send concatenation of 2 buffers of given size over serial link.
Jeej 19:701d5669f2e9 93 /// @param buffer1 : Pointer to the 1st data buffer to be sent
Jeej 19:701d5669f2e9 94 /// @param size1 : Size in bytes of the 1st buffer to be sent
Jeej 19:701d5669f2e9 95 /// @param buffer2 : Pointer to the 2nd data buffer to be sent
Jeej 19:701d5669f2e9 96 /// @param size2 : Size in bytes of the 2nd buffer to be sent
Jeej 19:701d5669f2e9 97 /// @return number of bytes sent.
Jeej 19:701d5669f2e9 98 /// @note either buffers can be of size zero.
Jeej 19:701d5669f2e9 99 /// @note buffer1 is used for WC header
Jeej 19:701d5669f2e9 100 /// @note buffer2 is used actual payload
Jeej 19:701d5669f2e9 101 //======================================================================
Jeej 19:701d5669f2e9 102 typedef int (fx_serial_send_t) (u8* buffer1, u8 size1,u8* buffer2, u8 size2);
Jeej 19:701d5669f2e9 103
Jeej 19:701d5669f2e9 104 //======================Low-Level-API================================}}}
Jeej 19:701d5669f2e9 105
Jeej 19:701d5669f2e9 106 //======================================================================
Jeej 19:701d5669f2e9 107 // High-level API that must be provided by the host application
Jeej 19:701d5669f2e9 108 //==================================================================={{{
Jeej 19:701d5669f2e9 109
Jeej 19:701d5669f2e9 110 //======================================================================
Jeej 19:701d5669f2e9 111 // fx_read_t
Jeej 19:701d5669f2e9 112 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 113 /// @brief Called when ALP-Read is requested by the modem.
Jeej 19:701d5669f2e9 114 /// Function must perform required actions to fullfil the request
Jeej 19:701d5669f2e9 115 /// then should call 'respond_read' (or 'respond' in case of error)
Jeej 19:701d5669f2e9 116 /// @param fid : File ID
Jeej 19:701d5669f2e9 117 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 118 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 119 /// @param id : ID of the request
Jeej 19:701d5669f2e9 120 //======================================================================
Jeej 19:701d5669f2e9 121 typedef void (fx_read_t) (u8 fid,u32 offset,u32 length, int id);
Jeej 19:701d5669f2e9 122
Jeej 19:701d5669f2e9 123 //======================================================================
Jeej 19:701d5669f2e9 124 // fx_write_t
Jeej 19:701d5669f2e9 125 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 126 /// @brief Called when ALP-Write is requested by the modem.
Jeej 19:701d5669f2e9 127 /// Function must perform required actions to fullfil the request
Jeej 19:701d5669f2e9 128 /// then should call 'respond'
Jeej 19:701d5669f2e9 129 /// @param fid : File ID
Jeej 19:701d5669f2e9 130 /// @param data : Pointer to the destination data buffer
Jeej 19:701d5669f2e9 131 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 132 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 133 /// @param id : ID of the request
Jeej 19:701d5669f2e9 134 //======================================================================
Jeej 19:701d5669f2e9 135 typedef void (fx_write_t) (u8 fid,void *data,u32 offset,u32 length, int id);
Jeej 19:701d5669f2e9 136
Jeej 19:701d5669f2e9 137 //======================================================================
Jeej 19:701d5669f2e9 138 // fx_read_fprop_t
Jeej 19:701d5669f2e9 139 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 140 /// @brief Called when ALP-Read-file-properties is requested by the modem.
Jeej 19:701d5669f2e9 141 /// Function must perform required actions to fullfil the request
Jeej 19:701d5669f2e9 142 /// then should call 'respond_fprop' (or 'respond' in case of error)
Jeej 19:701d5669f2e9 143 /// @param fid : File ID
Jeej 19:701d5669f2e9 144 /// @param id : ID of the request
Jeej 19:701d5669f2e9 145 //======================================================================
Jeej 19:701d5669f2e9 146 typedef void (fx_read_fprop_t) (u8 fid, int id);
Jeej 19:701d5669f2e9 147
Jeej 19:701d5669f2e9 148 //======================================================================
Jeej 19:701d5669f2e9 149 // fx_flush_t
Jeej 19:701d5669f2e9 150 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 151 /// @brief Called when ALP-Flush is requested by the modem.
Jeej 19:701d5669f2e9 152 /// Function must perform required actions to fullfil the request
Jeej 19:701d5669f2e9 153 /// then should call 'respond'
Jeej 19:701d5669f2e9 154 /// @param fid : File ID
Jeej 19:701d5669f2e9 155 /// @param id : ID of the request
Jeej 19:701d5669f2e9 156 //======================================================================
Jeej 19:701d5669f2e9 157 typedef void (fx_flush_t) (u8 fid, int id);
Jeej 19:701d5669f2e9 158
Jeej 19:701d5669f2e9 159 //======================================================================
Jeej 19:701d5669f2e9 160 // fx_delete_t
Jeej 19:701d5669f2e9 161 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 162 /// @brief Called when ALP-Delete is requested by the modem.
Jeej 19:701d5669f2e9 163 /// Function must perform required actions to fullfil the request
Jeej 19:701d5669f2e9 164 /// then should call 'respond'
Jeej 19:701d5669f2e9 165 /// @param fid : File ID
Jeej 19:701d5669f2e9 166 /// @param id : ID of the request
Jeej 19:701d5669f2e9 167 //======================================================================
Jeej 19:701d5669f2e9 168 typedef void (fx_delete_t) (u8 fid, int id);
Jeej 19:701d5669f2e9 169
Jeej 19:701d5669f2e9 170 //======================================================================
Jeej 19:701d5669f2e9 171 // fx_udata_t
Jeej 19:701d5669f2e9 172 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 173 /// @brief Called when Unsollicited Data is received by the Modem (i.e.
Jeej 19:701d5669f2e9 174 /// peer notifications etc).
Jeej 19:701d5669f2e9 175 /// When available/requested, ISTATUS data corresponding to this
Jeej 19:701d5669f2e9 176 /// reception are given as well.
Jeej 19:701d5669f2e9 177 /// @param fid : File ID
Jeej 19:701d5669f2e9 178 /// @param data : Pointer to the data buffer
Jeej 19:701d5669f2e9 179 /// @param offset : File Offset in bytes
Jeej 19:701d5669f2e9 180 /// @param length : Data Size in bytes
Jeej 19:701d5669f2e9 181 /// @param i_type : ISTATUS type (0: not available)
Jeej 19:701d5669f2e9 182 /// @param i_length : ISTATUS length in bytes
Jeej 19:701d5669f2e9 183 /// @param i_data : ISTATUS data pointer
Jeej 19:701d5669f2e9 184 /// @param id : ID of the request
Jeej 19:701d5669f2e9 185 //======================================================================
Jeej 19:701d5669f2e9 186 typedef void (fx_udata_t) (u8 fid,void *data,u32 offset,u32 length, u8 i_type, u8 i_length, u8* i_data);
Jeej 19:701d5669f2e9 187
Jeej 19:701d5669f2e9 188 //======================================================================
Jeej 19:701d5669f2e9 189 // fx_lqual_t
Jeej 19:701d5669f2e9 190 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 191 /// @brief Called when LQUAL URC is generated by the modem.
Jeej 19:701d5669f2e9 192 /// LQUAL URC is setup by the user through 'modem_enable_urc'.
Jeej 19:701d5669f2e9 193 /// LQUAL gives percentage of successfully sent packets on a
Jeej 19:701d5669f2e9 194 /// particular interface (IFID).
Jeej 19:701d5669f2e9 195 /// @param ifid : Interface File ID from which LQUAL is issued
Jeej 19:701d5669f2e9 196 /// @param per : Packet Error Rate in %
Jeej 19:701d5669f2e9 197 //======================================================================
Jeej 19:701d5669f2e9 198 typedef void (fx_lqual_t) (u8 ifid, int per);
Jeej 19:701d5669f2e9 199
Jeej 19:701d5669f2e9 200 //======================================================================
Jeej 19:701d5669f2e9 201 // fx_ldown_t
Jeej 19:701d5669f2e9 202 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 203 /// @brief Called when LDOWN URC is generated by the modem.
Jeej 19:701d5669f2e9 204 /// LDOWN URC is setup by the user through 'modem_enable_urc'
Jeej 19:701d5669f2e9 205 /// LDOWN is generated for a particular interface (IFID) after
Jeej 19:701d5669f2e9 206 /// a (configurable) number of consecutive transmission have failed.
Jeej 19:701d5669f2e9 207 /// @param ifid : Interface File ID from which LDOWN is issued
Jeej 19:701d5669f2e9 208 //======================================================================
Jeej 19:701d5669f2e9 209 typedef void (fx_ldown_t) (u8 ifid);
Jeej 19:701d5669f2e9 210
Jeej 19:701d5669f2e9 211 //======================================================================
Jeej 19:701d5669f2e9 212 // fx_reset_t
Jeej 19:701d5669f2e9 213 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 214 /// @brief Called when RESET URC is generated by the modem.
Jeej 19:701d5669f2e9 215 /// LDOWN URC is setup by the user through 'modem_enable_urc'
Jeej 19:701d5669f2e9 216 /// @param ifid : Interface File ID from which LDOWN is issued
Jeej 19:701d5669f2e9 217 //======================================================================
Jeej 19:701d5669f2e9 218 typedef void (fx_reset_t) (void);
Jeej 19:701d5669f2e9 219
Jeej 19:701d5669f2e9 220 //======================================================================
Jeej 19:701d5669f2e9 221 // fx_boot_t
Jeej 19:701d5669f2e9 222 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 223 /// @brief Called when BOOT URC is generated by the modem.
Jeej 19:701d5669f2e9 224 /// @param cause : Cause of the boot 'H':Pin/Hardware reset
Jeej 19:701d5669f2e9 225 /// 'P':POR reset
Jeej 19:701d5669f2e9 226 /// 'S':Software reset
Jeej 19:701d5669f2e9 227 /// 'L':Low-power reset
Jeej 19:701d5669f2e9 228 /// 'W':Watchdog reset
Jeej 19:701d5669f2e9 229 /// @param nb_boot : Number of boots since last POR
Jeej 19:701d5669f2e9 230 //======================================================================
Jeej 19:701d5669f2e9 231 typedef void (fx_boot_t) (u8 cause, u16 nb_boot);
Jeej 19:701d5669f2e9 232
Jeej 25:14c01b9fc04d 233 //======================================================================
Jeej 30:74aa36420c61 234 // fx_busy_t
Jeej 25:14c01b9fc04d 235 //----------------------------------------------------------------------
Jeej 25:14c01b9fc04d 236 /// @brief Called when BUSY URC is generated by the modem.
Jeej 25:14c01b9fc04d 237 /// @param busy : 0 if not busy, else busy
Jeej 25:14c01b9fc04d 238 //======================================================================
Jeej 25:14c01b9fc04d 239 typedef void (fx_busy_t) (u8 busy);
Jeej 25:14c01b9fc04d 240
Jeej 19:701d5669f2e9 241 // Set of functions passed together at modem openning
Jeej 19:701d5669f2e9 242 typedef struct {
Jeej 19:701d5669f2e9 243 // ALP File 'Action' callbacks
Jeej 19:701d5669f2e9 244 fx_read_t* read;
Jeej 19:701d5669f2e9 245 fx_write_t* write;
Jeej 19:701d5669f2e9 246 fx_read_fprop_t* read_fprop;
Jeej 19:701d5669f2e9 247 fx_flush_t* flush;
Jeej 19:701d5669f2e9 248 fx_delete_t* remove;
Jeej 19:701d5669f2e9 249 // 'URC' callbacks
Jeej 19:701d5669f2e9 250 fx_udata_t* udata;
Jeej 19:701d5669f2e9 251 fx_lqual_t* lqual;
Jeej 19:701d5669f2e9 252 fx_ldown_t* ldown;
Jeej 19:701d5669f2e9 253 fx_reset_t* reset;
Jeej 19:701d5669f2e9 254 fx_boot_t* boot;
Jeej 25:14c01b9fc04d 255 fx_busy_t* busy;
Jeej 19:701d5669f2e9 256 } modem_callbacks_t;
Jeej 19:701d5669f2e9 257 //======================High-Level-API===============================}}}
Jeej 19:701d5669f2e9 258
Jeej 19:701d5669f2e9 259 //======================================================================
Jeej 19:701d5669f2e9 260 // action_callback_t
Jeej 19:701d5669f2e9 261 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 262 /// @brief Type of function called on response(s) generated by an
Jeej 19:701d5669f2e9 263 /// 'action' function. Different functions of this kind can be
Jeej 19:701d5669f2e9 264 /// associated to different IDs through 'get_id'.
Jeej 19:701d5669f2e9 265 /// 'Action' function are subsequently called with relevant ID.
Jeej 19:701d5669f2e9 266 /// @param terminal : '1' at the last call for this ID, '0' otherwise
Jeej 19:701d5669f2e9 267 /// @param err : ALP Error code
Jeej 19:701d5669f2e9 268 /// @param id : ID of the request
Jeej 19:701d5669f2e9 269 //======================================================================
Jeej 19:701d5669f2e9 270 typedef void (action_callback_t) (u8 terminal, s8 err, u8 id);
Jeej 19:701d5669f2e9 271
Jeej 19:701d5669f2e9 272 //======================================================================
Jeej 19:701d5669f2e9 273 // modem_open
Jeej 19:701d5669f2e9 274 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 275 /// @brief Open Wizzilab Modem Driver
Jeej 19:701d5669f2e9 276 /// @param send : User function implementing serial output.
Jeej 19:701d5669f2e9 277 /// @param callbacks : Set of functions called by the driver upon
Jeej 19:701d5669f2e9 278 /// reception of commands
Jeej 19:701d5669f2e9 279 /// @return 0
Jeej 19:701d5669f2e9 280 //======================================================================
Jeej 19:701d5669f2e9 281 public void modem_open(fx_serial_send_t* send,modem_callbacks_t* callbacks);
Jeej 19:701d5669f2e9 282 public void modem_close(void);
Jeej 19:701d5669f2e9 283
Jeej 19:701d5669f2e9 284 //======================================================================
Jeej 19:701d5669f2e9 285 // modem_get_id
Jeej 19:701d5669f2e9 286 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 287 /// @brief Request an ID to perform modem operations
Jeej 19:701d5669f2e9 288 /// @param cb : Function called on responses generated for
Jeej 19:701d5669f2e9 289 /// this ID.
Jeej 19:701d5669f2e9 290 /// @return Positive ID value, -1 if no more IDs available.
Jeej 19:701d5669f2e9 291 //======================================================================
Jeej 19:701d5669f2e9 292 public int modem_get_id(action_callback_t* cb);
Jeej 19:701d5669f2e9 293
Jeej 19:701d5669f2e9 294 //======================================================================
Jeej 19:701d5669f2e9 295 // modem_free_id
Jeej 19:701d5669f2e9 296 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 297 /// @brief Release an ID
Jeej 19:701d5669f2e9 298 /// @param id : ID to release.
Jeej 19:701d5669f2e9 299 /// @return ID value, -1 if ID was not in use.
Jeej 19:701d5669f2e9 300 //======================================================================
Jeej 19:701d5669f2e9 301 public int modem_free_id(u8 id);
Jeej 19:701d5669f2e9 302
Jeej 19:701d5669f2e9 303 //======================================================================
Jeej 19:701d5669f2e9 304 // "Action" functions performing requests to the modem
Jeej 19:701d5669f2e9 305 //==================================================================={{{
Jeej 19:701d5669f2e9 306
Jeej 19:701d5669f2e9 307 //======================================================================
Jeej 19:701d5669f2e9 308 // modem_read_file
Jeej 19:701d5669f2e9 309 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 310 /// @brief Read a file on Modem
Jeej 19:701d5669f2e9 311 /// @param fid : File ID
Jeej 19:701d5669f2e9 312 /// @param data : Pointer to the destination data buffer
Jeej 19:701d5669f2e9 313 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 314 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 315 /// @param id : User ID
Jeej 19:701d5669f2e9 316 //======================================================================
Jeej 19:701d5669f2e9 317 public void modem_read_file(u8 fid, void *data, u32 offset, u32 length, u8 id);
Jeej 19:701d5669f2e9 318
Jeej 19:701d5669f2e9 319 //======================================================================
Jeej 19:701d5669f2e9 320 // modem_read_fprop
Jeej 19:701d5669f2e9 321 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 322 /// @brief Read a file-properties on Modem
Jeej 19:701d5669f2e9 323 /// @param fid : File ID
Jeej 19:701d5669f2e9 324 /// @param data : Pointer to the destination data buffer
Jeej 19:701d5669f2e9 325 /// @param id : User ID
Jeej 19:701d5669f2e9 326 //======================================================================
Jeej 19:701d5669f2e9 327 public void modem_read_fprop(u8 fid, alp_file_header_t* data, u8 id);
Jeej 19:701d5669f2e9 328
Jeej 19:701d5669f2e9 329 //======================================================================
Jeej 19:701d5669f2e9 330 // modem_read_fprop
Jeej 19:701d5669f2e9 331 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 332 /// @brief Read a file-properties on Modem with ROOT privileges
Jeej 19:701d5669f2e9 333 /// @param fid : File ID
Jeej 19:701d5669f2e9 334 /// @param data : Pointer to the destination data buffer
Jeej 19:701d5669f2e9 335 /// @param root_key : Pointer to the ROOT key
Jeej 19:701d5669f2e9 336 /// @param id : User ID
Jeej 19:701d5669f2e9 337 //======================================================================
Jeej 19:701d5669f2e9 338 public void modem_read_fprop_root(u8 fid, alp_file_header_t* data, u8* root_key, u8 id);
Jeej 19:701d5669f2e9 339
Jeej 19:701d5669f2e9 340 //======================================================================
Jeej 19:701d5669f2e9 341 // modem_write_fprop
Jeej 19:701d5669f2e9 342 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 343 /// @brief Write a file-properties on Modem
Jeej 19:701d5669f2e9 344 /// @param fid : File ID
Jeej 19:701d5669f2e9 345 /// @param data : Pointer to the header data
Jeej 19:701d5669f2e9 346 /// @param id : User ID
Jeej 19:701d5669f2e9 347 //======================================================================
Jeej 19:701d5669f2e9 348 public void modem_read_fprop(u8 fid, alp_file_header_t* data, u8 id);
Jeej 19:701d5669f2e9 349
Jeej 19:701d5669f2e9 350 //======================================================================
Jeej 19:701d5669f2e9 351 // modem_write_fprop_root
Jeej 19:701d5669f2e9 352 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 353 /// @brief Write a file-properties on Modem with ROOT privileges
Jeej 19:701d5669f2e9 354 /// @param fid : File ID
Jeej 19:701d5669f2e9 355 /// @param data : Pointer to the header data
Jeej 19:701d5669f2e9 356 /// @param root_key : Pointer to the ROOT key
Jeej 19:701d5669f2e9 357 /// @param id : User ID
Jeej 19:701d5669f2e9 358 //======================================================================
Jeej 19:701d5669f2e9 359 public void modem_read_fprop_root(u8 fid, alp_file_header_t* data, u8* root_key, u8 id);
Jeej 19:701d5669f2e9 360
Jeej 19:701d5669f2e9 361 //======================================================================
Jeej 19:701d5669f2e9 362 // modem_write_file
Jeej 19:701d5669f2e9 363 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 364 /// @brief Write a file on Modem
Jeej 19:701d5669f2e9 365 /// @note Writing can trigger a 'notification' depending on file properties.
Jeej 19:701d5669f2e9 366 /// @param fid : File ID
Jeej 19:701d5669f2e9 367 /// @param data : Pointer to the source data buffer
Jeej 19:701d5669f2e9 368 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 369 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 370 /// @param id : User ID
Jeej 19:701d5669f2e9 371 //======================================================================
Jeej 19:701d5669f2e9 372 public void modem_write_file(u8 fid, void *data, u32 offset, u32 length, u8 id);
Jeej 19:701d5669f2e9 373
Jeej 19:701d5669f2e9 374 //======================================================================
Jeej 19:701d5669f2e9 375 // modem_write_file_root
Jeej 19:701d5669f2e9 376 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 377 /// @brief Write a file on Modem with ROOT privileges
Jeej 19:701d5669f2e9 378 /// @note Writing can trigger a 'notification' depending on file properties.
Jeej 19:701d5669f2e9 379 /// @param fid : File ID
Jeej 19:701d5669f2e9 380 /// @param data : Pointer to the source data buffer
Jeej 19:701d5669f2e9 381 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 382 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 383 /// @param root_key : Pointer to the ROOT key
Jeej 19:701d5669f2e9 384 /// @param id : User ID
Jeej 19:701d5669f2e9 385 //======================================================================
Jeej 19:701d5669f2e9 386 public void modem_write_file_root(u8 fid, void *data, u32 offset, u32 length, u8* root_key, u8 id);
Jeej 19:701d5669f2e9 387
Jeej 19:701d5669f2e9 388 //======================================================================
Jeej 19:701d5669f2e9 389 // modem_flush_file
Jeej 19:701d5669f2e9 390 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 391 /// @brief Flush a file on Modem
Jeej 19:701d5669f2e9 392 /// @param fid : File ID
Jeej 19:701d5669f2e9 393 /// @param id : User ID
Jeej 19:701d5669f2e9 394 //======================================================================
Jeej 19:701d5669f2e9 395 public void modem_flush_file(u8 fid, u8 id);
Jeej 19:701d5669f2e9 396
Jeej 19:701d5669f2e9 397 //======================================================================
Jeej 19:701d5669f2e9 398 // modem_write_file_root
Jeej 19:701d5669f2e9 399 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 400 /// @brief Flush a file on Modem with ROOT privileges
Jeej 19:701d5669f2e9 401 /// @param fid : File ID
Jeej 19:701d5669f2e9 402 /// @param root_key : Pointer to the ROOT key
Jeej 19:701d5669f2e9 403 /// @param id : User ID
Jeej 19:701d5669f2e9 404 //======================================================================
Jeej 19:701d5669f2e9 405 public void modem_flush_file_root(u8 fid, u8* root_key, u8 id);
Jeej 19:701d5669f2e9 406
Jeej 19:701d5669f2e9 407 //======================================================================
Jeej 19:701d5669f2e9 408 // modem_declare_file
Jeej 19:701d5669f2e9 409 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 410 /// @brief Declare a local file to the Modem. Once declared, the file
Jeej 19:701d5669f2e9 411 /// becomes virtually part of Modem's file-system and can:
Jeej 19:701d5669f2e9 412 /// - be remotely accessed (depending on its permissions)
Jeej 19:701d5669f2e9 413 /// - be "Notified" through notify_file use
Jeej 19:701d5669f2e9 414 /// @note The file must exist locally.
Jeej 19:701d5669f2e9 415 /// @note Modem will access the file when needed using ALP commands.
Jeej 19:701d5669f2e9 416 /// @param fid : File ID
Jeej 19:701d5669f2e9 417 /// @param hdr : ALP File Header.
Jeej 19:701d5669f2e9 418 /// @param local : File is local.
Jeej 19:701d5669f2e9 419 /// @param id : User ID
Jeej 19:701d5669f2e9 420 //======================================================================
Jeej 19:701d5669f2e9 421 public void modem_declare_file(u8 fid, alp_file_header_t* hdr, u8 local, u8 id);
Jeej 19:701d5669f2e9 422
Jeej 19:701d5669f2e9 423 //======================================================================
Jeej 19:701d5669f2e9 424 // modem_create_file
Jeej 19:701d5669f2e9 425 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 426 /// @brief Creates a file on the Modem.
Jeej 19:701d5669f2e9 427 /// @param fid : File ID
Jeej 19:701d5669f2e9 428 /// @param hdr : ALP File Header.
Jeej 19:701d5669f2e9 429 /// @param id : User ID
Jeej 19:701d5669f2e9 430 //======================================================================
Jeej 19:701d5669f2e9 431 public void modem_create_file(u8 fid, alp_file_header_t* hdr, u8 id);
Jeej 19:701d5669f2e9 432
Jeej 19:701d5669f2e9 433 //======================================================================
Jeej 19:701d5669f2e9 434 // modem_delete_file
Jeej 19:701d5669f2e9 435 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 436 /// @brief Deletes a file on the Modem.
Jeej 19:701d5669f2e9 437 /// @param fid : File ID
Jeej 19:701d5669f2e9 438 /// @param id : User ID
Jeej 19:701d5669f2e9 439 //======================================================================
Jeej 19:701d5669f2e9 440 public void modem_delete_file(u8 fid, u8 id);
Jeej 19:701d5669f2e9 441
Jeej 19:701d5669f2e9 442 //======================================================================
Jeej 19:701d5669f2e9 443 // modem_notify_file
Jeej 19:701d5669f2e9 444 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 445 /// @brief "Notify" a local file using its D7AActP properties.
Jeej 19:701d5669f2e9 446 /// @note The file must exist locally and must have been 'declared'.
Jeej 19:701d5669f2e9 447 /// @param fid : File ID
Jeej 19:701d5669f2e9 448 /// @param offset : Access Offset in bytes
Jeej 19:701d5669f2e9 449 /// @param length : Access Size in bytes
Jeej 19:701d5669f2e9 450 /// @param id : User ID
Jeej 19:701d5669f2e9 451 //======================================================================
Jeej 19:701d5669f2e9 452 public void modem_notify_file(u8 fid, u32 offset, u32 length, u8 id);
Jeej 19:701d5669f2e9 453
Jeej 19:701d5669f2e9 454 //======================================================================
Jeej 19:701d5669f2e9 455 // modem_alp_raw
Jeej 19:701d5669f2e9 456 //----------------------------------------------------------------------
Jeej 19:701d5669f2e9 457 /// @brief Execute specific ALP payload on Modem.
Jeej 19:701d5669f2e9 458 /// @param payload : pointer to ALP Payload to be executed on Modem
Jeej 19:701d5669f2e9 459 /// @param length : ALP Payload size
Jeej 19:701d5669f2e9 460 /// @param id : User ID
Jeej 19:701d5669f2e9 461 //======================================================================
Jeej 19:701d5669f2e9 462 public void modem_send_raw_alp(u8* payload, u32 length, u8 id);
Jeej 19:701d5669f2e9 463
Jeej 19:701d5669f2e9 464 public void modem_send_file_content(u8* itf, u8 itf_length, void *istatus, u8 fid, void *data,u32 offset,u32 length, u8 id);
Jeej 19:701d5669f2e9 465
Jeej 19:701d5669f2e9 466 public void modem_remote_read_file(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8 id);
Jeej 19:701d5669f2e9 467
Jeej 19:701d5669f2e9 468 public void modem_remote_write_file(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8 id);
Jeej 19:701d5669f2e9 469
Jeej 19:701d5669f2e9 470 public void modem_enable_urc(u8 type, u8 ifid, u8 val, u8 enable, u8 id);
Jeej 19:701d5669f2e9 471
Jeej 19:701d5669f2e9 472 public void modem_activate_itf(u8 type, u8 nb_dev, u8 ifid, u8 flags, u8 enable, u8 id);
Jeej 19:701d5669f2e9 473
Jeej 19:701d5669f2e9 474 //==========================Action===================================}}}
Jeej 19:701d5669f2e9 475
Jeej 19:701d5669f2e9 476 //======================================================================
Jeej 19:701d5669f2e9 477 // "Response" functions to be called-back on requests from the modem
Jeej 19:701d5669f2e9 478 //==================================================================={{{
Jeej 19:701d5669f2e9 479 public void modem_respond(u8 action, s8 status, int id);
Jeej 19:701d5669f2e9 480 public void modem_respond_fprop(u8 fid, u8* hdr, int id);
Jeej 19:701d5669f2e9 481 public void modem_respond_read(u8 fid,void *data,u32 offset,u32 length, int id);
Jeej 19:701d5669f2e9 482 //==========================Response=================================}}}
Jeej 19:701d5669f2e9 483
Jeej 19:701d5669f2e9 484
Jeej 19:701d5669f2e9 485 //=======================================================================
Jeej 19:701d5669f2e9 486 // Modem File IDs are mapped from 64 to 127
Jeej 19:701d5669f2e9 487 // These files are mandatory when building an application that
Jeej 19:701d5669f2e9 488 // uses Wizzilab's D7A Stack, so it will be included in all "Modem"
Jeej 19:701d5669f2e9 489 // applications.
Jeej 19:701d5669f2e9 490 //=======================================================================
Jeej 30:74aa36420c61 491 // Modem Config/Status
Jeej 30:74aa36420c61 492 #define FID_WM_REV 2 // Match D7A one.
Jeej 30:74aa36420c61 493 #define FID_HOST_REV 65
Jeej 30:74aa36420c61 494 #define FID_WM_SCRATCH 66
Jeej 30:74aa36420c61 495 #define FID_WM_STATUS 67
Jeej 30:74aa36420c61 496 #define FID_WM_CFG 68
Jeej 30:74aa36420c61 497 #define FID_WM_HWCFG 69
Jeej 30:74aa36420c61 498 #define FID_WM_CTRL 70
Jeej 30:74aa36420c61 499 #define FID_WM_LED_CFG 71
Jeej 19:701d5669f2e9 500
Jeej 30:74aa36420c61 501 // LORAWAN "ITFs"
Jeej 30:74aa36420c61 502 #define FID_LWAN_ITF0 98
Jeej 30:74aa36420c61 503 #define FID_LWAN_ITF1 99
Jeej 30:74aa36420c61 504
Jeej 19:701d5669f2e9 505 // Action files
Jeej 30:74aa36420c61 506 #define FID_ACTP_RPT_FULL 100
Jeej 30:74aa36420c61 507 #define FID_ACTP_RPT_PART 101
Jeej 30:74aa36420c61 508
Jeej 30:74aa36420c61 509 // Reserved
Jeej 30:74aa36420c61 510 #define FID_RESERVED_102 102
Jeej 30:74aa36420c61 511 #define FID_RESERVED_103 103
Jeej 30:74aa36420c61 512 #define FID_RESERVED_104 104
Jeej 30:74aa36420c61 513 #define FID_RESERVED_105 105
Jeej 30:74aa36420c61 514 #define FID_RESERVED_106 106
Jeej 30:74aa36420c61 515 #define FID_RESERVED_107 107
Jeej 30:74aa36420c61 516
Jeej 19:701d5669f2e9 517 // Interface files
Jeej 30:74aa36420c61 518 #define IFID_ONESHOT_HOST 108
Jeej 30:74aa36420c61 519 #define IFID_ONESHOT_ACTP 109
Jeej 30:74aa36420c61 520 #define IFID_REPORT 110
Jeej 30:74aa36420c61 521 #define IFID_ITF3 111
Jeej 30:74aa36420c61 522 #define IFID_ITF4 112
Jeej 30:74aa36420c61 523 #define IFID_BLINKER 113
Jeej 19:701d5669f2e9 524
Jeej 30:74aa36420c61 525 // Reserved
Jeej 30:74aa36420c61 526 #define FID_RESERVED_114 114
Jeej 30:74aa36420c61 527 #define FID_RESERVED_115 115
Jeej 30:74aa36420c61 528 #define FID_RESERVED_116 116
Jeej 30:74aa36420c61 529 #define FID_RESERVED_117 117
Jeej 30:74aa36420c61 530 #define FID_RESERVED_118 118
Jeej 30:74aa36420c61 531 #define FID_RESERVED_119 119
Jeej 30:74aa36420c61 532 #define FID_RESERVED_120 120
Jeej 30:74aa36420c61 533 #define FID_RESERVED_121 121
Jeej 30:74aa36420c61 534 #define FID_RESERVED_122 122
Jeej 30:74aa36420c61 535 #define FID_RESERVED_123 123
Jeej 30:74aa36420c61 536
Jeej 30:74aa36420c61 537 // Modem Security protocols
Jeej 30:74aa36420c61 538 #define FID_WM_CHALLENGE 124
Jeej 30:74aa36420c61 539
Jeej 30:74aa36420c61 540 // Modem CUP
Jeej 30:74aa36420c61 541 #define FID_CUP_CFG_BCAST 125
Jeej 30:74aa36420c61 542 #define FID_CUP_CFG 126
Jeej 30:74aa36420c61 543 #define FID_CUP_CODE 127
Jeej 30:74aa36420c61 544
Jeej 30:74aa36420c61 545 // HST CUP
Jeej 30:74aa36420c61 546 #define FID_APP_CUP_CFG_BCAST 252
Jeej 30:74aa36420c61 547 #define FID_APP_CUP_CFG 253
Jeej 30:74aa36420c61 548 #define FID_APP_CUP_CODE 254
Jeej 30:74aa36420c61 549
Jeej 30:74aa36420c61 550 #endif
Jeej 30:74aa36420c61 551
Jeej 30:74aa36420c61 552 // vim:fdm=marker:fdc=2