Exportable version of WizziLab's modem driver.

Dependents:   modem_ref_helper

Committer:
Jeej
Date:
Thu Sep 06 10:41:51 2018 +0000
Revision:
35:ac940cf8ebe6
Parent:
34:137ae523ca43
Child:
37:f5424d109c6d
Updated for modem 5.2.184+

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 1:40ead20ecb14 1 #include "mbed.h"
Jeej 1:40ead20ecb14 2 #include "WizziDebug.h"
Jeej 1:40ead20ecb14 3
Jeej 0:027760f45e2c 4 #include "modem_ref.h"
Jeej 13:10589aaf8853 5 #include "kal_crypto.h"
Jeej 0:027760f45e2c 6
Jeej 5:32ccddf80952 7 #if 0
Jeej 4:8f031be3ff7d 8 #define REF_PRINT(...) PRINT(__VA_ARGS__)
Jeej 13:10589aaf8853 9 #define URC_PRINT(...) PRINT(__VA_ARGS__)
Jeej 4:8f031be3ff7d 10 #else
Jeej 4:8f031be3ff7d 11 #define REF_PRINT(...);
Jeej 13:10589aaf8853 12 #define URC_PRINT(...);
Jeej 4:8f031be3ff7d 13 #endif
Jeej 4:8f031be3ff7d 14
Jeej 0:027760f45e2c 15 typedef struct {
Jeej 0:027760f45e2c 16 action_callback_t* cb;
Jeej 0:027760f45e2c 17 u8* data;
Jeej 1:40ead20ecb14 18 u8* istatus;
Jeej 0:027760f45e2c 19 } modem_user_t;
Jeej 0:027760f45e2c 20
Jeej 0:027760f45e2c 21 typedef struct {
Jeej 8:97875739f11a 22 u8* data;
Jeej 8:97875739f11a 23 u8 type;
Jeej 8:97875739f11a 24 u8 length;
Jeej 8:97875739f11a 25 } modem_istatus_t;
Jeej 8:97875739f11a 26
Jeej 8:97875739f11a 27 typedef struct {
Jeej 0:027760f45e2c 28 fx_serial_send_t* send;
Jeej 0:027760f45e2c 29 modem_callbacks_t* cb;
Jeej 0:027760f45e2c 30 modem_user_t user[MAX_USER_NB];
Jeej 8:97875739f11a 31 modem_istatus_t istatus;
Jeej 0:027760f45e2c 32 u8 state;
Jeej 0:027760f45e2c 33 u8 tx_sequ;
Jeej 0:027760f45e2c 34 } modem_ctx_t;
Jeej 0:027760f45e2c 35 static modem_ctx_t g_modem;
Jeej 0:027760f45e2c 36
Jeej 0:027760f45e2c 37 #define STATE_OPEN 0xab
Jeej 0:027760f45e2c 38 #define STATE_CLOSED 0
Jeej 0:027760f45e2c 39
Jeej 13:10589aaf8853 40 #define ROOT_KEY_SIZE 16
Jeej 13:10589aaf8853 41
Jeej 0:027760f45e2c 42 #define SERIAL_SEND(_flow,_data,_size) do { \
Jeej 21:d5018a680915 43 ASSERT(_size<256, "SERIAL_SEND too big for serial protocol (%d/%dmax)", _size, 255);\
Jeej 0:027760f45e2c 44 u8 wch[WC_HEADER_SIZE] = {WC_SYNC_BYTE_0,WC_SYNC_BYTE_1,_size,g_modem.tx_sequ++,_flow};\
Jeej 0:027760f45e2c 45 g_modem.send(wch,WC_HEADER_SIZE,_data,_size);\
Jeej 0:027760f45e2c 46 }while(0)
Jeej 0:027760f45e2c 47
Jeej 0:027760f45e2c 48 // Flows
Jeej 0:027760f45e2c 49 #define WC_FLOWID_CMD 0x10
Jeej 0:027760f45e2c 50 #define WC_FLOWID_ALP 0x20
Jeej 0:027760f45e2c 51 #define WC_FLOWID_SYS 0x30
Jeej 0:027760f45e2c 52
Jeej 0:027760f45e2c 53 // Sub-Flows
Jeej 0:027760f45e2c 54 #define WC_FLOW_ALP_CMD 0x20
Jeej 0:027760f45e2c 55 #define WC_FLOW_ALP_RESP 0x21
Jeej 0:027760f45e2c 56 #define WC_FLOW_ALP_UNS 0x22
Jeej 0:027760f45e2c 57 #define WC_FLOW_SYS_RST 0x30
Jeej 0:027760f45e2c 58 #define WC_FLOW_SYS_PING 0x34
Jeej 0:027760f45e2c 59 #define WC_FLOW_SYS_PONG 0x35
Jeej 0:027760f45e2c 60 #define WC_FLOW_SYS_CFG 0x36
Jeej 0:027760f45e2c 61 #define WC_FLOW_SYS_XON 0x39
Jeej 0:027760f45e2c 62 #define WC_FLOW_SYS_XOFF 0x3a
Jeej 0:027760f45e2c 63 #define WC_FLOW_SYS_XACK 0x3b
Jeej 0:027760f45e2c 64
Jeej 0:027760f45e2c 65 // Misc CMD...
Jeej 0:027760f45e2c 66 #define WM_BOOT 0x81
Jeej 0:027760f45e2c 67
Jeej 0:027760f45e2c 68
Jeej 0:027760f45e2c 69 protected void modem_input(u8 flowid,u8* payload,u8 size)
Jeej 0:027760f45e2c 70 {
Jeej 0:027760f45e2c 71 int rem =size;
Jeej 0:027760f45e2c 72 u8* p = payload;
Jeej 0:027760f45e2c 73 alp_parsed_chunk_t r;
Jeej 0:027760f45e2c 74 int id = -1;
Jeej 0:027760f45e2c 75 s8 err = ALP_ERR_NONE;
Jeej 1:40ead20ecb14 76 u8 eop;
Jeej 34:137ae523ca43 77 uint32_t parsed;
Jeej 26:2c934a269914 78 //REF_PRINT("input 0x%x/%d Bytes\n",flowid,size);
Jeej 0:027760f45e2c 79 switch (flowid)
Jeej 0:027760f45e2c 80 {
Jeej 0:027760f45e2c 81 case WC_FLOW_ALP_UNS:
Jeej 0:027760f45e2c 82 case WC_FLOW_ALP_CMD:
Jeej 34:137ae523ca43 83 parsed = alp_parse_chunk(&p, &r);
Jeej 34:137ae523ca43 84 if (!parsed)
Jeej 34:137ae523ca43 85 {
Jeej 34:137ae523ca43 86 // Discard the payload in case of parsing error.
Jeej 34:137ae523ca43 87 REF_PRINT("Parsing error in %s:%d!\r\n", __FILE__, __LINE__);
Jeej 34:137ae523ca43 88 break;
Jeej 34:137ae523ca43 89 }
Jeej 34:137ae523ca43 90 rem -= parsed;
Jeej 26:2c934a269914 91 //REF_PRINT("Rem %d Bytes\n", rem);
Jeej 0:027760f45e2c 92 // This should always be a TAG'ed request in case of FS access...
Jeej 0:027760f45e2c 93 if (r.type == ALP_OPCODE_TAG)
Jeej 0:027760f45e2c 94 {
Jeej 0:027760f45e2c 95 id = r.meta.tag.id;
Jeej 8:97875739f11a 96 while(rem>0)
Jeej 0:027760f45e2c 97 {
Jeej 8:97875739f11a 98 // Parse File Operation
Jeej 34:137ae523ca43 99 parsed = alp_parse_chunk(&p, &r);
Jeej 34:137ae523ca43 100 if (!parsed)
Jeej 34:137ae523ca43 101 {
Jeej 34:137ae523ca43 102 // Discard the payload in case of parsing error.
Jeej 34:137ae523ca43 103 REF_PRINT("Parsing error in %s:%d!\r\n", __FILE__, __LINE__);
Jeej 34:137ae523ca43 104 break;
Jeej 34:137ae523ca43 105 }
Jeej 34:137ae523ca43 106 rem -= parsed;
Jeej 26:2c934a269914 107 //REF_PRINT("ALP OP[%d]\n",r.type);
Jeej 8:97875739f11a 108 switch (r.type)
Jeej 8:97875739f11a 109 {
Jeej 8:97875739f11a 110 case ALP_OPCODE_F_RD_DATA:
Jeej 31:517fc900afba 111 if (g_modem.cb->read)
Jeej 31:517fc900afba 112 {
Jeej 31:517fc900afba 113 g_modem.cb->read(r.meta.f_data.fid,r.meta.f_data.offset,r.meta.f_data.length,id);
Jeej 31:517fc900afba 114 }
Jeej 8:97875739f11a 115 break;
Jeej 8:97875739f11a 116 case ALP_OPCODE_F_WR_DATA:
Jeej 31:517fc900afba 117 if (g_modem.cb->write)
Jeej 31:517fc900afba 118 {
Jeej 31:517fc900afba 119 g_modem.cb->write(r.meta.f_data.fid,r.data,r.meta.f_data.offset,r.meta.f_data.length,id);
Jeej 31:517fc900afba 120 }
Jeej 8:97875739f11a 121 break;
Jeej 8:97875739f11a 122 case ALP_OPCODE_F_RD_PROP:
Jeej 31:517fc900afba 123 if (g_modem.cb->read_fprop)
Jeej 31:517fc900afba 124 {
Jeej 31:517fc900afba 125 g_modem.cb->read_fprop(r.meta.f_data.fid,id);
Jeej 31:517fc900afba 126 }
Jeej 8:97875739f11a 127 break;
Jeej 8:97875739f11a 128 case ALP_OPCODE_F_DELETE:
Jeej 31:517fc900afba 129 if (g_modem.cb->remove)
Jeej 31:517fc900afba 130 {
Jeej 31:517fc900afba 131 g_modem.cb->remove(r.meta.f_data.fid,id);
Jeej 31:517fc900afba 132 }
Jeej 8:97875739f11a 133 break;
Jeej 8:97875739f11a 134 case ALP_OPCODE_F_FLUSH:
Jeej 31:517fc900afba 135 if (g_modem.cb->flush)
Jeej 31:517fc900afba 136 {
Jeej 31:517fc900afba 137 g_modem.cb->flush(r.meta.f_data.fid,id);
Jeej 31:517fc900afba 138 }
Jeej 8:97875739f11a 139 break;
Jeej 8:97875739f11a 140 default:
Jeej 8:97875739f11a 141 ASSERT(false,"ASSERT: Unsupported ALP File Operation: %d\n",r.type);
Jeej 8:97875739f11a 142 break;
Jeej 8:97875739f11a 143 }
Jeej 26:2c934a269914 144 //REF_PRINT("ALP Parsing done. rem %d\n", rem);
Jeej 0:027760f45e2c 145 }
Jeej 26:2c934a269914 146 //REF_PRINT("ALP Packet done.\n");
Jeej 0:027760f45e2c 147 }
Jeej 0:027760f45e2c 148 else
Jeej 0:027760f45e2c 149 {
Jeej 0:027760f45e2c 150 // ... or a 'real' URC (or ISTATUS if enabled on modem)
Jeej 8:97875739f11a 151 g_modem.istatus = (modem_istatus_t){0};
Jeej 9:2f921fe9c519 152 do
Jeej 0:027760f45e2c 153 {
Jeej 8:97875739f11a 154 switch (r.type)
Jeej 8:97875739f11a 155 {
Jeej 8:97875739f11a 156 case ALP_OPCODE_RSP_URC:
Jeej 25:14c01b9fc04d 157 if (ALP_URC_TYPE_LQUAL == r.meta.urc.type)
Jeej 8:97875739f11a 158 g_modem.cb->lqual(r.meta.urc.ifid,r.meta.urc.per);
Jeej 25:14c01b9fc04d 159 else if (ALP_URC_TYPE_LDOWN == r.meta.urc.type)
Jeej 8:97875739f11a 160 g_modem.cb->ldown(r.meta.urc.ifid);
Jeej 25:14c01b9fc04d 161 else if (ALP_URC_TYPE_BUSY == r.meta.urc.type)
Jeej 25:14c01b9fc04d 162 g_modem.cb->busy(r.meta.urc.ifid);
Jeej 8:97875739f11a 163 else
Jeej 8:97875739f11a 164 ASSERT(false,"ASSERT: Unsupported ALP URC: %d\n",r.meta.urc.type);
Jeej 8:97875739f11a 165 break;
Jeej 8:97875739f11a 166 default:
Jeej 35:ac940cf8ebe6 167 // This could be anything
Jeej 35:ac940cf8ebe6 168 // Let user deal with the payload
Jeej 31:517fc900afba 169 if (g_modem.cb->udata)
Jeej 31:517fc900afba 170 {
Jeej 31:517fc900afba 171 g_modem.cb->udata(payload, size);
Jeej 31:517fc900afba 172 }
Jeej 31:517fc900afba 173 rem = 0;
Jeej 8:97875739f11a 174 break;
Jeej 8:97875739f11a 175 }
Jeej 13:10589aaf8853 176
Jeej 9:2f921fe9c519 177 int tem = alp_parse_chunk(&p, &r);
Jeej 9:2f921fe9c519 178 if (!tem)
Jeej 9:2f921fe9c519 179 {
Jeej 9:2f921fe9c519 180 break;
Jeej 9:2f921fe9c519 181 }
Jeej 9:2f921fe9c519 182 rem -= tem;
Jeej 9:2f921fe9c519 183 } while (rem>=0);
Jeej 0:027760f45e2c 184 }
Jeej 0:027760f45e2c 185 break;
Jeej 0:027760f45e2c 186 case WC_FLOW_ALP_RESP:
Jeej 0:027760f45e2c 187 // This should always be a TAG'ed response as we tag our requests
Jeej 34:137ae523ca43 188 parsed = alp_parse_chunk(&p, &r);
Jeej 34:137ae523ca43 189 if (!parsed)
Jeej 34:137ae523ca43 190 {
Jeej 34:137ae523ca43 191 // Discard the payload in case of parsing error.
Jeej 34:137ae523ca43 192 REF_PRINT("Parsing error in %s:%d!\r\n", __FILE__, __LINE__);
Jeej 34:137ae523ca43 193 break;
Jeej 34:137ae523ca43 194 }
Jeej 34:137ae523ca43 195 rem -= parsed;
Jeej 34:137ae523ca43 196
Jeej 0:027760f45e2c 197 ASSERT((r.type == ALP_OPCODE_RSP_TAG),"ASSERT: expecting RESP_TAG got %d\n",r.type);
Jeej 1:40ead20ecb14 198 id = r.meta.tag.id;
Jeej 1:40ead20ecb14 199 eop = r.meta.tag.eop;
Jeej 0:027760f45e2c 200 ASSERT(g_modem.user[id].cb != NULL,"ASSERT: NULL Callback for ID %d\n",id);
Jeej 0:027760f45e2c 201 // Empty response
Jeej 0:027760f45e2c 202 if (rem <= 0)
Jeej 0:027760f45e2c 203 {
Jeej 0:027760f45e2c 204 // TODO: still no info on error...
Jeej 20:17852941b19e 205 REF_PRINT("ERROR\n");
Jeej 0:027760f45e2c 206 err = r.meta.tag.err ? ALP_ERR_UNKNOWN : ALP_ERR_NONE;
Jeej 1:40ead20ecb14 207 g_modem.user[id].cb(eop,err,id);
Jeej 0:027760f45e2c 208 return;
Jeej 0:027760f45e2c 209 }
Jeej 0:027760f45e2c 210
Jeej 1:40ead20ecb14 211 // Actual response(s)
Jeej 1:40ead20ecb14 212 while(rem>0)
Jeej 0:027760f45e2c 213 {
Jeej 34:137ae523ca43 214 parsed = alp_parse_chunk(&p, &r);
Jeej 34:137ae523ca43 215 if (!parsed)
Jeej 34:137ae523ca43 216 {
Jeej 34:137ae523ca43 217 // Discard the payload in case of parsing error.
Jeej 34:137ae523ca43 218 REF_PRINT("Parsing error in %s:%d!\r\n", __FILE__, __LINE__);
Jeej 34:137ae523ca43 219 break;
Jeej 34:137ae523ca43 220 }
Jeej 34:137ae523ca43 221 rem -= parsed;
Jeej 34:137ae523ca43 222
Jeej 1:40ead20ecb14 223 switch (r.type)
Jeej 1:40ead20ecb14 224 {
Jeej 14:a9c324663732 225 case ALP_OPCODE_RSP_TAG:
Jeej 20:17852941b19e 226 REF_PRINT("RSP_TAG[%d]\n", r.meta.tag.id);
Jeej 14:a9c324663732 227 break;
Jeej 1:40ead20ecb14 228 case ALP_OPCODE_RSP_F_DATA:
Jeej 20:17852941b19e 229 REF_PRINT("RSP_F_DATA[%d]\n", r.meta.f_data.length);
Jeej 20:17852941b19e 230 ASSERT(g_modem.user[id].data != NULL,"ASSERT: NULL Data Buffer for RD on ID %d\n",id);
Jeej 20:17852941b19e 231 memcpy(g_modem.user[id].data,r.data,r.meta.f_data.length);
Jeej 20:17852941b19e 232 break;
Jeej 6:581caeee80e8 233 case ALP_OPCODE_RSP_F_PROP:
Jeej 20:17852941b19e 234 REF_PRINT("RSP_F_PROP[%d]\n", r.meta.f_data.length);
Jeej 1:40ead20ecb14 235 ASSERT(g_modem.user[id].data != NULL,"ASSERT: NULL Data Buffer for RD on ID %d\n",id);
Jeej 1:40ead20ecb14 236 memcpy(g_modem.user[id].data,r.data,r.meta.f_data.length);
Jeej 1:40ead20ecb14 237 break;
Jeej 1:40ead20ecb14 238 case ALP_OPCODE_RSP_STATUS:
Jeej 20:17852941b19e 239 REF_PRINT("RSP_STATUS[%d]\n", r.meta.status.code);
Jeej 1:40ead20ecb14 240 err = r.meta.status.code;
Jeej 1:40ead20ecb14 241 break;
Jeej 1:40ead20ecb14 242 case ALP_OPCODE_RSP_ISTATUS:
Jeej 20:17852941b19e 243 REF_PRINT("RSP_ISTATUS[%d]\n", r.meta.itf.length);
Jeej 1:40ead20ecb14 244 ASSERT(g_modem.user[id].istatus != NULL,"ASSERT: NULL ISTAT Buffer for RD on ID %d\n",id);
Jeej 1:40ead20ecb14 245 memcpy(g_modem.user[id].istatus,r.data,r.meta.itf.length);
Jeej 1:40ead20ecb14 246 break;
Jeej 1:40ead20ecb14 247 default:
Jeej 1:40ead20ecb14 248 ASSERT(false,"ASSERT: Unsupported ALP Response: %d\n",r.type);
Jeej 1:40ead20ecb14 249 break;
Jeej 1:40ead20ecb14 250 }
Jeej 0:027760f45e2c 251 }
Jeej 1:40ead20ecb14 252 if(eop)
Jeej 1:40ead20ecb14 253 { // This is mainly for debug, catch old pointers
Jeej 2:bcf269540633 254 //g_modem.user[id].data = NULL;
Jeej 2:bcf269540633 255 //g_modem.user[id].istatus= NULL;
Jeej 20:17852941b19e 256 REF_PRINT("EOP\n");
Jeej 1:40ead20ecb14 257 }
Jeej 6:581caeee80e8 258 // User Callback
Jeej 31:517fc900afba 259 if (g_modem.user[id].cb)
Jeej 31:517fc900afba 260 {
Jeej 31:517fc900afba 261 g_modem.user[id].cb(eop,err,id);
Jeej 31:517fc900afba 262 }
Jeej 0:027760f45e2c 263 break;
Jeej 0:027760f45e2c 264 case WC_FLOW_SYS_RST:
Jeej 0:027760f45e2c 265 // 'Software' reset request
Jeej 31:517fc900afba 266 if (g_modem.cb->reset)
Jeej 31:517fc900afba 267 {
Jeej 31:517fc900afba 268 g_modem.cb->reset();
Jeej 31:517fc900afba 269 }
Jeej 0:027760f45e2c 270 break;
Jeej 0:027760f45e2c 271 case WC_FLOWID_CMD:
Jeej 0:027760f45e2c 272 if (*p == WM_BOOT)
Jeej 0:027760f45e2c 273 {
Jeej 0:027760f45e2c 274 u16 nb_boot;
Jeej 0:027760f45e2c 275 u8 cause;
Jeej 0:027760f45e2c 276 p++;
Jeej 0:027760f45e2c 277 cause = p[0];
Jeej 0:027760f45e2c 278 nb_boot = HAL_TO_U16(p[3],p[2]);
Jeej 31:517fc900afba 279 if (g_modem.cb->boot)
Jeej 31:517fc900afba 280 {
Jeej 31:517fc900afba 281 g_modem.cb->boot(cause,nb_boot);
Jeej 31:517fc900afba 282 }
Jeej 0:027760f45e2c 283 }
Jeej 0:027760f45e2c 284 else
Jeej 0:027760f45e2c 285 {
Jeej 4:8f031be3ff7d 286 REF_PRINT("Unsupported CMD :0x%x\n",*p);
Jeej 0:027760f45e2c 287 }
Jeej 0:027760f45e2c 288 break;
Jeej 0:027760f45e2c 289 default:
Jeej 4:8f031be3ff7d 290 REF_PRINT("Unsupported WC Flowid:0x%x / %d Bytes\n",flowid,size);
Jeej 0:027760f45e2c 291 break;
Jeej 0:027760f45e2c 292 }
Jeej 0:027760f45e2c 293 }
Jeej 0:027760f45e2c 294
Jeej 13:10589aaf8853 295 private u32 modem_add_root_permission(u8* p, u8* root_key, u8* action, u32 action_size)
Jeej 13:10589aaf8853 296 {
Jeej 13:10589aaf8853 297 u8 hash[32];
Jeej 13:10589aaf8853 298
Jeej 13:10589aaf8853 299 // Calculate hash on action
Jeej 13:10589aaf8853 300 kal_sha256_init();
Jeej 13:10589aaf8853 301 kal_sha256_update(action, action_size);
Jeej 13:10589aaf8853 302 kal_sha256_update(root_key, ROOT_KEY_SIZE);
Jeej 13:10589aaf8853 303 kal_sha256_final(hash);
Jeej 13:10589aaf8853 304 // Prepend Permission-request...
Jeej 13:10589aaf8853 305 ALP_ACTION_PERM_REQ(p, false, ALP_PERM_REQ_ROOT);
Jeej 13:10589aaf8853 306 // ... and hash
Jeej 13:10589aaf8853 307 memcpy(p, hash, ALP_WIZZILAB_AUTH_PROTOCOL_TOKEN_SIZE);
Jeej 13:10589aaf8853 308
Jeej 13:10589aaf8853 309 return ALP_ACTION_PERM_REQ_OFFSET;
Jeej 13:10589aaf8853 310 }
Jeej 13:10589aaf8853 311
Jeej 0:027760f45e2c 312 public int modem_get_id(action_callback_t* cb)
Jeej 0:027760f45e2c 313 {
Jeej 0:027760f45e2c 314 int i;
Jeej 0:027760f45e2c 315 for(i=0;i<MAX_USER_NB;i++)
Jeej 0:027760f45e2c 316 {
Jeej 0:027760f45e2c 317 if (g_modem.user[i].cb == NULL)
Jeej 0:027760f45e2c 318 {
Jeej 0:027760f45e2c 319 g_modem.user[i].cb = cb;
Jeej 13:10589aaf8853 320 //REF_PRINT("Get ID:%d/0x%08x\n",i,cb);
Jeej 0:027760f45e2c 321 return i;
Jeej 0:027760f45e2c 322 }
Jeej 0:027760f45e2c 323 }
Jeej 0:027760f45e2c 324 ASSERT(i < MAX_USER_NB,"ASSERT: out of users\n");
Jeej 0:027760f45e2c 325 return -1;
Jeej 0:027760f45e2c 326 }
Jeej 0:027760f45e2c 327
Jeej 0:027760f45e2c 328 public int modem_free_id(u8 id)
Jeej 0:027760f45e2c 329 {
Jeej 0:027760f45e2c 330 if (id < MAX_USER_NB)
Jeej 0:027760f45e2c 331 {
Jeej 0:027760f45e2c 332 g_modem.user[id].cb = NULL;
Jeej 0:027760f45e2c 333 g_modem.user[id].data = NULL;
Jeej 1:40ead20ecb14 334 g_modem.user[id].istatus= NULL;
Jeej 13:10589aaf8853 335 //REF_PRINT("Free ID:%d\n",id);
Jeej 0:027760f45e2c 336 return id;
Jeej 0:027760f45e2c 337 }
Jeej 0:027760f45e2c 338 return -1;
Jeej 0:027760f45e2c 339 }
Jeej 0:027760f45e2c 340
Jeej 0:027760f45e2c 341 public void modem_open(fx_serial_send_t* send,modem_callbacks_t* callbacks)
Jeej 0:027760f45e2c 342 {
Jeej 0:027760f45e2c 343 if (g_modem.state != STATE_OPEN)
Jeej 0:027760f45e2c 344 {
Jeej 0:027760f45e2c 345 g_modem.send= send;
Jeej 0:027760f45e2c 346 g_modem.cb = callbacks;
Jeej 0:027760f45e2c 347 memset(g_modem.user,0,(MAX_USER_NB * sizeof(modem_user_t)));
Jeej 0:027760f45e2c 348
Jeej 4:8f031be3ff7d 349 REF_PRINT("Open Modem - Max users:%d\n",MAX_USER_NB);
Jeej 0:027760f45e2c 350
Jeej 0:027760f45e2c 351 g_modem.state = STATE_OPEN;
Jeej 0:027760f45e2c 352 }
Jeej 0:027760f45e2c 353 }
Jeej 0:027760f45e2c 354
Jeej 0:027760f45e2c 355 public void modem_close(void)
Jeej 0:027760f45e2c 356 {
Jeej 0:027760f45e2c 357 if (g_modem.state == STATE_OPEN)
Jeej 0:027760f45e2c 358 {
Jeej 0:027760f45e2c 359 g_modem.state = STATE_CLOSED;
Jeej 0:027760f45e2c 360 }
Jeej 0:027760f45e2c 361 }
Jeej 0:027760f45e2c 362
Jeej 0:027760f45e2c 363 public void modem_reset(void)
Jeej 0:027760f45e2c 364 {
Jeej 0:027760f45e2c 365 SERIAL_SEND(WC_FLOW_SYS_RST,NULL,0);
Jeej 0:027760f45e2c 366 }
Jeej 0:027760f45e2c 367
Jeej 13:10589aaf8853 368 public void modem_read_file(u8 fid, void *data, u32 offset, u32 length, u8 id)
Jeej 0:027760f45e2c 369 {
Jeej 0:027760f45e2c 370 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_RD_DATA_SIZE_MAX];
Jeej 0:027760f45e2c 371 u8* p = tmp;
Jeej 4:8f031be3ff7d 372 REF_PRINT("RD[%d]@%d %d Bytes\n",fid,offset,length);
Jeej 0:027760f45e2c 373 g_modem.user[id].data = (u8*)data;
Jeej 0:027760f45e2c 374 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 375 ALP_ACTION_F_RD_DATA(p,true,fid,offset,length);
Jeej 0:027760f45e2c 376 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 377 }
Jeej 0:027760f45e2c 378
Jeej 6:581caeee80e8 379 public void modem_read_fprop(u8 fid, alp_file_header_t* data, u8 id)
Jeej 6:581caeee80e8 380 {
Jeej 6:581caeee80e8 381 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_RD_PROP_SIZE];
Jeej 6:581caeee80e8 382 u8* p = tmp;
Jeej 11:a077da5fe68f 383 REF_PRINT("RD PROPS[%d]\n",fid);
Jeej 6:581caeee80e8 384 g_modem.user[id].data = (u8*)data;
Jeej 6:581caeee80e8 385 ALP_ACTION_TAG(p,id,true);
Jeej 6:581caeee80e8 386 ALP_ACTION_F_RD_PROP(p,true,fid);
Jeej 6:581caeee80e8 387 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 6:581caeee80e8 388 }
Jeej 6:581caeee80e8 389
Jeej 13:10589aaf8853 390 public void modem_read_fprop_root(u8 fid, alp_file_header_t* data, u8* root_key, u8 id)
Jeej 13:10589aaf8853 391 {
Jeej 13:10589aaf8853 392 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_SIZE(ALP_ACTION_F_RD_PROP_SIZE)];
Jeej 13:10589aaf8853 393 u8* p = tmp;
Jeej 13:10589aaf8853 394 u8* lastp;
Jeej 13:10589aaf8853 395 REF_PRINT("RD PROPS (ROOT)[%d]\n",fid);
Jeej 13:10589aaf8853 396 ASSERT(root_key != NULL, "Missing ROOT KEY\n");
Jeej 13:10589aaf8853 397 g_modem.user[id].data = (u8*)data;
Jeej 13:10589aaf8853 398 ALP_ACTION_TAG(p, id, true);
Jeej 13:10589aaf8853 399 // Actual Operation will take place after PERM_REQ
Jeej 13:10589aaf8853 400 p = &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET];
Jeej 13:10589aaf8853 401 ALP_ACTION_F_RD_PROP(p,true,fid);
Jeej 13:10589aaf8853 402 lastp = p;
Jeej 13:10589aaf8853 403 modem_add_root_permission(&tmp[ALP_ACTION_TAG_SIZE], root_key,
Jeej 13:10589aaf8853 404 &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET],
Jeej 13:10589aaf8853 405 ALP_ACTION_F_RD_PROP_SIZE);
Jeej 13:10589aaf8853 406 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(lastp-tmp));
Jeej 13:10589aaf8853 407 }
Jeej 13:10589aaf8853 408
Jeej 13:10589aaf8853 409 public void modem_write_fprop(u8 fid, alp_file_header_t* data, u8 id)
Jeej 13:10589aaf8853 410 {
Jeej 13:10589aaf8853 411 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_WR_PROP_SIZE_MAX];
Jeej 13:10589aaf8853 412 u8* p = tmp;
Jeej 13:10589aaf8853 413 DPRINT(L_API, "WR PROPS[%d]\n",fid);
Jeej 13:10589aaf8853 414 ALP_ACTION_TAG(p,id,true);
Jeej 13:10589aaf8853 415 ALP_ACTION_F_WR_PROP(p,true,fid,0,sizeof(alp_file_header_t),data);
Jeej 13:10589aaf8853 416 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 13:10589aaf8853 417 }
Jeej 13:10589aaf8853 418
Jeej 13:10589aaf8853 419 public void modem_write_fprop_root(u8 fid, alp_file_header_t* data, u8* root_key, u8 id)
Jeej 13:10589aaf8853 420 {
Jeej 13:10589aaf8853 421 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_SIZE(ALP_ACTION_F_WR_PROP_SIZE_MAX)];
Jeej 13:10589aaf8853 422 u8* p = tmp;
Jeej 13:10589aaf8853 423 u8* lastp;
Jeej 13:10589aaf8853 424 DPRINT(L_API, "WR PROPS (ROOT)[%d]\n",fid);
Jeej 13:10589aaf8853 425 ASSERT(root_key != NULL, "Missing ROOT KEY\n");
Jeej 13:10589aaf8853 426 ALP_ACTION_TAG(p, id, true);
Jeej 13:10589aaf8853 427 // Actual Operation will take place after PERM_REQ
Jeej 13:10589aaf8853 428 p = &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET];
Jeej 13:10589aaf8853 429 ALP_ACTION_F_WR_PROP(p,true,fid,0,sizeof(alp_file_header_t),data);
Jeej 13:10589aaf8853 430 lastp = p;
Jeej 13:10589aaf8853 431 modem_add_root_permission(&tmp[ALP_ACTION_TAG_SIZE], root_key,
Jeej 13:10589aaf8853 432 &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET],
Jeej 13:10589aaf8853 433 ALP_ACTION_F_WR_PROP_SIZE_MAX);
Jeej 13:10589aaf8853 434 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(lastp-tmp));
Jeej 13:10589aaf8853 435 }
Jeej 13:10589aaf8853 436
Jeej 14:a9c324663732 437 public void modem_write_file(u8 fid, void *data, u32 offset, u32 length, u8 id)
Jeej 0:027760f45e2c 438 {
Jeej 0:027760f45e2c 439 ALLOC_BUFFER(u8,tmp,(ALP_ACTION_TAG_SIZE + ALP_ACTION_F_WR_DATA_SIZE_MAX(length)));
Jeej 0:027760f45e2c 440
Jeej 0:027760f45e2c 441 u8* p = tmp;
Jeej 4:8f031be3ff7d 442 REF_PRINT("WR[%d]@%d %d Bytes\n",fid,offset,length);
Jeej 0:027760f45e2c 443 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 444 ALP_ACTION_F_WR_DATA(p,true,fid,offset,length,data);
Jeej 0:027760f45e2c 445 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 446 DEALLOC_BUFFER(tmp);
Jeej 0:027760f45e2c 447 }
Jeej 0:027760f45e2c 448
Jeej 14:a9c324663732 449 public void modem_write_file_root(u8 fid, void *data, u32 offset, u32 length, u8* root_key, u8 id)
Jeej 13:10589aaf8853 450 {
Jeej 13:10589aaf8853 451 ALLOC_BUFFER(u8,tmp,(ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_SIZE(ALP_ACTION_F_WR_DATA_SIZE_MAX(length))));
Jeej 13:10589aaf8853 452
Jeej 13:10589aaf8853 453 u8* p = tmp;
Jeej 13:10589aaf8853 454 u8* lastp;
Jeej 13:10589aaf8853 455 REF_PRINT("WR (ROOT)[%d]@%d %d Bytes\n",fid,offset,length);
Jeej 13:10589aaf8853 456 ASSERT(root_key != NULL, "Missing ROOT KEY\n");
Jeej 13:10589aaf8853 457 ALP_ACTION_TAG(p, id, true);
Jeej 13:10589aaf8853 458 // Actual Operation will take place after PERM_REQ
Jeej 13:10589aaf8853 459 p = &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET];
Jeej 13:10589aaf8853 460 ALP_ACTION_F_WR_DATA(p,true,fid,offset,length,data);
Jeej 13:10589aaf8853 461 lastp = p;
Jeej 13:10589aaf8853 462 modem_add_root_permission(&tmp[ALP_ACTION_TAG_SIZE], root_key,
Jeej 13:10589aaf8853 463 &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET],
Jeej 13:10589aaf8853 464 ALP_ACTION_F_WR_DATA_SIZE(offset,length));
Jeej 13:10589aaf8853 465 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(lastp-tmp));
Jeej 13:10589aaf8853 466 DEALLOC_BUFFER(tmp);
Jeej 13:10589aaf8853 467 }
Jeej 13:10589aaf8853 468
Jeej 13:10589aaf8853 469 public void modem_flush_file(u8 fid, u8 id)
Jeej 13:10589aaf8853 470 {
Jeej 13:10589aaf8853 471 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_FLUSH_SIZE];
Jeej 13:10589aaf8853 472 u8* p = tmp;
Jeej 13:10589aaf8853 473 REF_PRINT("FLUSH[%d]\n",fid);
Jeej 13:10589aaf8853 474 ALP_ACTION_TAG(p,id,true);
Jeej 13:10589aaf8853 475 ALP_ACTION_F_FLUSH(p,true,fid);
Jeej 13:10589aaf8853 476 SERIAL_SEND(WC_FLOW_ALP_UNS, tmp, (u8)(p-tmp));
Jeej 13:10589aaf8853 477 }
Jeej 13:10589aaf8853 478
Jeej 13:10589aaf8853 479 public void modem_flush_file_root(u8 fid, u8* root_key, u8 id)
Jeej 13:10589aaf8853 480 {
Jeej 13:10589aaf8853 481 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_SIZE(ALP_ACTION_F_FLUSH_SIZE)];
Jeej 13:10589aaf8853 482 u8* p = tmp;
Jeej 13:10589aaf8853 483 u8* lastp;
Jeej 13:10589aaf8853 484 REF_PRINT("FLUSH (ROOT)[%d]\n",fid);
Jeej 13:10589aaf8853 485 ASSERT(root_key != NULL, "Missing ROOT KEY\n");
Jeej 13:10589aaf8853 486 ALP_ACTION_TAG(p, id, true);
Jeej 13:10589aaf8853 487 // Actual Operation will take place after PERM_REQ
Jeej 13:10589aaf8853 488 p = &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET];
Jeej 13:10589aaf8853 489 ALP_ACTION_F_FLUSH(p,true,fid);
Jeej 13:10589aaf8853 490 lastp = p;
Jeej 13:10589aaf8853 491 modem_add_root_permission(&tmp[ALP_ACTION_TAG_SIZE], root_key,
Jeej 13:10589aaf8853 492 &tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_PERM_REQ_OFFSET],
Jeej 13:10589aaf8853 493 ALP_ACTION_F_FLUSH_SIZE);
Jeej 13:10589aaf8853 494 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(lastp-tmp));
Jeej 13:10589aaf8853 495 }
Jeej 13:10589aaf8853 496
Jeej 11:a077da5fe68f 497 public void modem_declare_file(u8 fid, alp_file_header_t* hdr, u8 local, u8 id)
Jeej 0:027760f45e2c 498 {
Jeej 0:027760f45e2c 499 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_DECLARE_SIZE];
Jeej 0:027760f45e2c 500 u8* p = tmp;
Jeej 0:027760f45e2c 501
Jeej 4:8f031be3ff7d 502 REF_PRINT("DECLARE[%d]\n",fid);
Jeej 0:027760f45e2c 503 ALP_ACTION_TAG(p,id,true);
Jeej 11:a077da5fe68f 504 ALP_ACTION_F_DECLARE(p,true,fid,hdr,local);
Jeej 0:027760f45e2c 505 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 506 }
Jeej 0:027760f45e2c 507
Jeej 0:027760f45e2c 508 public void modem_create_file(u8 fid, alp_file_header_t* hdr, u8 id)
Jeej 0:027760f45e2c 509 {
Jeej 0:027760f45e2c 510 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_CREATE_SIZE];
Jeej 0:027760f45e2c 511 u8* p = tmp;
Jeej 0:027760f45e2c 512
Jeej 4:8f031be3ff7d 513 REF_PRINT("CREATE[%d]\n",fid);
Jeej 0:027760f45e2c 514 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 515 ALP_ACTION_F_CREATE(p,true,fid,hdr);
Jeej 0:027760f45e2c 516 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 517 }
Jeej 0:027760f45e2c 518
Jeej 14:a9c324663732 519 public void modem_notify_file(u8 fid, u32 offset, u32 length, u8 id)
Jeej 0:027760f45e2c 520 {
Jeej 0:027760f45e2c 521 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_TOUCH_SIZE_MAX];
Jeej 0:027760f45e2c 522 u8* p = tmp;
Jeej 0:027760f45e2c 523
Jeej 4:8f031be3ff7d 524 REF_PRINT("NOTIFY[%d]@%d %d Bytes\n",fid,offset,length);
Jeej 0:027760f45e2c 525 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 526 ALP_ACTION_F_TOUCH(p,true,fid,offset,length);
Jeej 0:027760f45e2c 527 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 528 }
Jeej 0:027760f45e2c 529
Jeej 14:a9c324663732 530 public void modem_delete_file(u8 fid, u8 id)
Jeej 0:027760f45e2c 531 {
Jeej 0:027760f45e2c 532 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_F_DELETE_SIZE];
Jeej 0:027760f45e2c 533 u8* p = tmp;
Jeej 0:027760f45e2c 534
Jeej 4:8f031be3ff7d 535 REF_PRINT("DELETE[%d]\n",fid);
Jeej 0:027760f45e2c 536 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 537 ALP_ACTION_F_DELETE(p,true,fid);
Jeej 0:027760f45e2c 538 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 539 }
Jeej 0:027760f45e2c 540
Jeej 0:027760f45e2c 541 public void modem_send_raw_alp(u8* payload, u32 length, u8 id)
Jeej 0:027760f45e2c 542 {
Jeej 0:027760f45e2c 543 ALLOC_BUFFER(u8,tmp,ALP_ACTION_TAG_SIZE + length);
Jeej 0:027760f45e2c 544 u8* p = tmp;
Jeej 0:027760f45e2c 545
Jeej 4:8f031be3ff7d 546 REF_PRINT("ALP RAW %d Bytes\n",length);
Jeej 0:027760f45e2c 547 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 548 // User Payload
Jeej 0:027760f45e2c 549 memcpy(p,payload,length);p+=length;
Jeej 0:027760f45e2c 550 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 551 DEALLOC_BUFFER(tmp);
Jeej 0:027760f45e2c 552 }
Jeej 0:027760f45e2c 553
Jeej 14:a9c324663732 554 public void modem_send_file_content(u8* itf, u8 itf_length, void *istatus, u8 fid, void *data, u32 offset, u32 length, u8 id)
Jeej 0:027760f45e2c 555 {
Jeej 0:027760f45e2c 556 ALLOC_BUFFER(u8,tmp,ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_RSP_F_DATA_SIZE_MAX(length));
Jeej 0:027760f45e2c 557 u8* p = tmp;
Jeej 6:581caeee80e8 558 g_modem.user[id].istatus= (u8*)istatus;
Jeej 0:027760f45e2c 559
Jeej 4:8f031be3ff7d 560 REF_PRINT("SEND FILE[%d] CONTENTS @%d %d Bytes (itf %d Bytes)\n",fid,offset,length,itf_length);
Jeej 0:027760f45e2c 561 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 562 ALP_ACTION_FORWARD(p,itf,itf_length);
Jeej 17:b4ea2a912fd3 563 if (istatus)
Jeej 17:b4ea2a912fd3 564 {
Jeej 17:b4ea2a912fd3 565 // NOP action to get istats on ACKs
Jeej 17:b4ea2a912fd3 566 ALP_ACTION_NOP(p,true);
Jeej 17:b4ea2a912fd3 567 }
Jeej 0:027760f45e2c 568 ALP_ACTION_RSP_F_DATA(p,fid,offset,length,data);
Jeej 0:027760f45e2c 569 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 570 DEALLOC_BUFFER(tmp);
Jeej 0:027760f45e2c 571 }
Jeej 0:027760f45e2c 572
Jeej 18:a11302a76e96 573 public void modem_remote_read_file(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8 id)
Jeej 1:40ead20ecb14 574 {
Jeej 1:40ead20ecb14 575 ALLOC_BUFFER(u8,tmp,ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_F_RD_DATA_SIZE_MAX);
Jeej 1:40ead20ecb14 576 u8* p = tmp;
Jeej 18:a11302a76e96 577 g_modem.user[id].data = (u8*)data;
Jeej 18:a11302a76e96 578 g_modem.user[id].istatus = (u8*)istatus;
Jeej 1:40ead20ecb14 579
Jeej 4:8f031be3ff7d 580 REF_PRINT("RMT RD FILE[%d]@%d %d Bytes (itf %d Bytes)\n",fid,offset,length,itf_length);
Jeej 1:40ead20ecb14 581 ALP_ACTION_TAG(p,id,true);
Jeej 1:40ead20ecb14 582 ALP_ACTION_FORWARD(p,itf,itf_length);
Jeej 1:40ead20ecb14 583 ALP_ACTION_F_RD_DATA(p,true,fid,offset,length);
Jeej 1:40ead20ecb14 584 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 1:40ead20ecb14 585 DEALLOC_BUFFER(tmp);
Jeej 1:40ead20ecb14 586 }
Jeej 1:40ead20ecb14 587
Jeej 18:a11302a76e96 588 public void modem_remote_write_file(u8* itf, u8 itf_length, void *istatus , u8 fid, void *data, u32 offset, u32 length, u8 id)
Jeej 18:a11302a76e96 589 {
Jeej 18:a11302a76e96 590 ALLOC_BUFFER(u8,tmp,ALP_ACTION_TAG_SIZE + ALP_ACTION_FORWARD_SIZE(itf_length) + ALP_ACTION_F_WR_DATA_SIZE_MAX(length));
Jeej 18:a11302a76e96 591 u8* p = tmp;
Jeej 18:a11302a76e96 592 g_modem.user[id].istatus = (u8*)istatus;
Jeej 18:a11302a76e96 593
Jeej 18:a11302a76e96 594 REF_PRINT("RMT WR FILE[%d]@%d %d Bytes (itf %d Bytes)\n",fid,offset,length,itf_length);
Jeej 18:a11302a76e96 595 ALP_ACTION_TAG(p,id,true);
Jeej 18:a11302a76e96 596 ALP_ACTION_FORWARD(p,itf,itf_length);
Jeej 18:a11302a76e96 597 ALP_ACTION_F_WR_DATA(p,true,fid,offset,length,data);
Jeej 18:a11302a76e96 598 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 18:a11302a76e96 599 DEALLOC_BUFFER(tmp);
Jeej 18:a11302a76e96 600 }
Jeej 18:a11302a76e96 601
Jeej 0:027760f45e2c 602 public void modem_enable_urc(u8 type, u8 ifid, u8 val, u8 enable, u8 id)
Jeej 0:027760f45e2c 603 {
Jeej 0:027760f45e2c 604 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_URCC_SIZE(ALP_URC_TYPE_LQUAL)];
Jeej 0:027760f45e2c 605 u8* p = tmp;
Jeej 4:8f031be3ff7d 606 REF_PRINT("URC[%d] Type %d ifid %d\n",enable,type,ifid);
Jeej 0:027760f45e2c 607
Jeej 0:027760f45e2c 608 ALP_ACTION_TAG(p,id,true);
Jeej 0:027760f45e2c 609 // Actual Operation
Jeej 0:027760f45e2c 610 if (enable)
Jeej 0:027760f45e2c 611 {
Jeej 0:027760f45e2c 612 ALP_ACTION_URCC_EN(p,true,type,ifid,val);
Jeej 0:027760f45e2c 613 }
Jeej 0:027760f45e2c 614 else
Jeej 0:027760f45e2c 615 {
Jeej 0:027760f45e2c 616 ALP_ACTION_URCC_DIS(p,true,type,ifid,val);
Jeej 0:027760f45e2c 617 }
Jeej 0:027760f45e2c 618 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 619 }
Jeej 0:027760f45e2c 620
Jeej 1:40ead20ecb14 621 public void modem_activate_itf(u8 type, u8 nb_dev, u8 ifid, u8 flags, u8 enable, u8 id)
Jeej 1:40ead20ecb14 622 {
Jeej 1:40ead20ecb14 623 u8 tmp[ALP_ACTION_TAG_SIZE + ALP_ACTION_ACTIVATE_ITF_SIZE];
Jeej 1:40ead20ecb14 624 u8* p = tmp;
Jeej 1:40ead20ecb14 625
Jeej 4:8f031be3ff7d 626 REF_PRINT("ACTIVATE ITFTYPE[%x]:%d\n",type,enable);
Jeej 1:40ead20ecb14 627 ALP_ACTION_TAG(p,id,true);
Jeej 11:a077da5fe68f 628 ALP_ACTION_ACTIVATE_ITF(p,true,enable,type,nb_dev,ifid,flags);
Jeej 1:40ead20ecb14 629 SERIAL_SEND(WC_FLOW_ALP_UNS,tmp, (u8)(p-tmp));
Jeej 1:40ead20ecb14 630 }
Jeej 1:40ead20ecb14 631
Jeej 0:027760f45e2c 632 public void modem_respond(u8 action, s8 status, int id)
Jeej 0:027760f45e2c 633 {
Jeej 0:027760f45e2c 634 u8 tmp[ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_STATUS_SIZE];
Jeej 0:027760f45e2c 635 u8* p = tmp;
Jeej 4:8f031be3ff7d 636 REF_PRINT("RESP[%d]:%d\n",action,status);
Jeej 0:027760f45e2c 637
Jeej 0:027760f45e2c 638 if (id>=0) { ALP_ACTION_RSP_TAG(p,id,true,(status<0)?true:false); }
Jeej 0:027760f45e2c 639 ALP_ACTION_RSP_STATUS(p,action,status);
Jeej 0:027760f45e2c 640 SERIAL_SEND(WC_FLOW_ALP_RESP,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 641 }
Jeej 0:027760f45e2c 642
Jeej 0:027760f45e2c 643 public void modem_respond_fprop(u8 fid, u8* hdr, int id)
Jeej 0:027760f45e2c 644 {
Jeej 0:027760f45e2c 645 u8 tmp[ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_F_PROP_SIZE];
Jeej 0:027760f45e2c 646 u8* p = tmp;
Jeej 4:8f031be3ff7d 647 REF_PRINT("RESP FPROP[%d]\n",fid);
Jeej 0:027760f45e2c 648
Jeej 0:027760f45e2c 649 if (id>=0) { ALP_ACTION_RSP_TAG(p,id,true,false); }
Jeej 0:027760f45e2c 650 ALP_ACTION_RSP_F_PROP(p,fid,hdr);
Jeej 0:027760f45e2c 651 SERIAL_SEND(WC_FLOW_ALP_RESP,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 652 }
Jeej 0:027760f45e2c 653
Jeej 14:a9c324663732 654 public void modem_respond_read(u8 fid,void *data, u32 offset, u32 length, int id)
Jeej 0:027760f45e2c 655 {
Jeej 0:027760f45e2c 656 ALLOC_BUFFER(u8,tmp,ALP_ACTION_RSP_TAG_SIZE + ALP_ACTION_RSP_F_DATA_SIZE_MAX(length));
Jeej 0:027760f45e2c 657 u8* p = tmp;
Jeej 4:8f031be3ff7d 658 REF_PRINT("F_DATA[%d]@%d %d Bytes\n",fid,offset,length);
Jeej 0:027760f45e2c 659 if (id>=0) { ALP_ACTION_RSP_TAG(p,id,true,false); }
Jeej 0:027760f45e2c 660 ALP_ACTION_RSP_F_DATA(p,fid,offset,length,data);
Jeej 0:027760f45e2c 661 SERIAL_SEND(WC_FLOW_ALP_RESP,tmp, (u8)(p-tmp));
Jeej 0:027760f45e2c 662 DEALLOC_BUFFER(tmp);
Jeej 13:10589aaf8853 663 }