Data reception demo.

Dependencies:   modem_ref_helper

Committer:
Jeej
Date:
Mon May 15 15:55:09 2017 +0000
Revision:
2:6652be2d061f
Parent:
0:02418479dcf7
Child:
3:e9ea4d325c01
Added Keep alive report.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Jeej 0:02418479dcf7 1 #include "mbed.h"
Jeej 0:02418479dcf7 2 #include "rtos.h"
Jeej 0:02418479dcf7 3 #include "WizziDebug.h"
Jeej 0:02418479dcf7 4
Jeej 0:02418479dcf7 5 #include "alp_spec.h"
Jeej 0:02418479dcf7 6 #include "alp_helpers.h"
Jeej 0:02418479dcf7 7 #include "modem_ref.h"
Jeej 0:02418479dcf7 8
Jeej 0:02418479dcf7 9 #include "ram_fs.h"
Jeej 0:02418479dcf7 10 #include "hal_types.h"
Jeej 0:02418479dcf7 11
Jeej 0:02418479dcf7 12 extern Queue<void, 8> g_file_modified;
Jeej 0:02418479dcf7 13
Jeej 0:02418479dcf7 14 // ============================================================}}}
Jeej 0:02418479dcf7 15
Jeej 0:02418479dcf7 16 // Callbacks to MODEM's ALP requests
Jeej 0:02418479dcf7 17 // ============================================================{{{
Jeej 0:02418479dcf7 18 void my_read(u8 fid, u32 offset, u32 length, int id)
Jeej 0:02418479dcf7 19 {
Jeej 0:02418479dcf7 20 u8 data[256];
Jeej 0:02418479dcf7 21
Jeej 0:02418479dcf7 22 if (ram_fs_read(fid, offset, length, data))
Jeej 0:02418479dcf7 23 {
Jeej 0:02418479dcf7 24 modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
Jeej 0:02418479dcf7 25 }
Jeej 0:02418479dcf7 26 else
Jeej 0:02418479dcf7 27 {
Jeej 0:02418479dcf7 28 modem_respond_read(fid, data, offset, length, id);
Jeej 0:02418479dcf7 29 }
Jeej 0:02418479dcf7 30 }
Jeej 0:02418479dcf7 31
Jeej 0:02418479dcf7 32 void my_write(u8 fid, void *data, u32 offset, u32 length, int id)
Jeej 0:02418479dcf7 33 {
Jeej 0:02418479dcf7 34 modem_respond(0, (ram_fs_write(fid, offset, length, (uint8_t*)data))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
Jeej 0:02418479dcf7 35
Jeej 0:02418479dcf7 36 g_file_modified.put((void*)fid);
Jeej 0:02418479dcf7 37 }
Jeej 0:02418479dcf7 38
Jeej 0:02418479dcf7 39 void my_read_fprop(u8 fid, int id)
Jeej 0:02418479dcf7 40 {
Jeej 0:02418479dcf7 41 u8* hdr = (u8*)ram_fs_get_header(fid);
Jeej 0:02418479dcf7 42
Jeej 0:02418479dcf7 43 if (hdr != NULL)
Jeej 0:02418479dcf7 44 {
Jeej 0:02418479dcf7 45 modem_respond_fprop(fid, hdr, id);
Jeej 0:02418479dcf7 46 }
Jeej 0:02418479dcf7 47 else
Jeej 0:02418479dcf7 48 {
Jeej 0:02418479dcf7 49 modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
Jeej 0:02418479dcf7 50 }
Jeej 0:02418479dcf7 51 }
Jeej 0:02418479dcf7 52
Jeej 0:02418479dcf7 53 void my_flush(u8 fid, int id)
Jeej 0:02418479dcf7 54 {
Jeej 0:02418479dcf7 55 // No flush in this file system
Jeej 0:02418479dcf7 56 modem_respond(0, ALP_ERR_NONE, id);
Jeej 0:02418479dcf7 57 }
Jeej 0:02418479dcf7 58
Jeej 0:02418479dcf7 59 void my_delete(u8 fid, int id)
Jeej 0:02418479dcf7 60 {
Jeej 0:02418479dcf7 61 modem_respond(0, (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
Jeej 0:02418479dcf7 62 }
Jeej 0:02418479dcf7 63
Jeej 0:02418479dcf7 64 void my_lqual(u8 ifid, int per)
Jeej 0:02418479dcf7 65 {
Jeej 2:6652be2d061f 66 PRINT("Interface File [%3d] LQUAL : %d%% PER\r\n", ifid, per);
Jeej 0:02418479dcf7 67 }
Jeej 0:02418479dcf7 68
Jeej 0:02418479dcf7 69 void my_ldown(u8 ifid)
Jeej 0:02418479dcf7 70 {
Jeej 2:6652be2d061f 71 PRINT("Interface File [%3d] LDOWN\r\n", ifid);
Jeej 0:02418479dcf7 72 }
Jeej 0:02418479dcf7 73
Jeej 0:02418479dcf7 74 void my_reset(void)
Jeej 0:02418479dcf7 75 {
Jeej 0:02418479dcf7 76 NVIC_SystemReset();
Jeej 0:02418479dcf7 77 }
Jeej 0:02418479dcf7 78
Jeej 0:02418479dcf7 79 void my_boot(u8 cause, u16 number)
Jeej 0:02418479dcf7 80 {
Jeej 2:6652be2d061f 81 PRINT("Modem BOOT[%c] #%d\r\nRe-Init\r\n", cause, number);
Jeej 0:02418479dcf7 82
Jeej 0:02418479dcf7 83 // Modem re-booted, restart APP
Jeej 0:02418479dcf7 84 my_reset();
Jeej 0:02418479dcf7 85 }