Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: modem_ref_helper CRC DebouncedInterrupt
modem_callbacks.cpp
- Committer:
- Jeej
- Date:
- 2017-05-18
- Revision:
- 6:05e26c3a495a
- Parent:
- 4:999305b576c0
- Child:
- 8:db5679d113c2
File content as of revision 6:05e26c3a495a:
#include "modem_ref_helper.h"
// ============================================================}}}
// Callbacks to MODEM's ALP requests
// ============================================================{{{
void my_read(u8 fid, u32 offset, u32 length, int id)
{
u8 data[256];
if (ram_fs_read(fid, offset, length, data))
{
modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
}
else
{
modem_respond_read(fid, data, offset, length, id);
}
}
void my_write(u8 fid, void *data, u32 offset, u32 length, int id)
{
modem_respond(0, (ram_fs_write(fid, offset, length, (uint8_t*)data))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
}
void my_read_fprop(u8 fid, int id)
{
u8* hdr = (u8*)ram_fs_get_header(fid);
if (hdr != NULL)
{
modem_respond_fprop(fid, hdr, id);
}
else
{
modem_respond(0, ALP_ERR_FILE_NOT_FOUND, id);
}
}
void my_flush(u8 fid, int id)
{
// No flush in this file system
modem_respond(0, ALP_ERR_NONE, id);
}
void my_delete(u8 fid, int id)
{
modem_respond(0, (ram_fs_delete(fid))? ALP_ERR_FILE_NOT_FOUND : ALP_ERR_NONE, id);
}
void my_udata(u8 fid,void *data,u32 offset,u32 length, u8 i_type, u8 i_length, u8* i_data)
{
(void)data;
(void)i_length;
PRINT("Got UNS File[%3d]@%d %d Bytes\n",fid,offset,length);
if (i_type == ALP_ITF_TYPE_D7A)
{
static union {
u8 b[8];
u32 w[2];
} uid;
d7a_sp_res_t* istat = (d7a_sp_res_t*) i_data;
memcpy(uid.b,istat->addressee.id,8);
PRINT("From UID: %08X%08X (rxlev:%d lb:%d)\n",
HAL_U32_BYTE_SWAP(uid.w[0]), HAL_U32_BYTE_SWAP(uid.w[1]),
istat->rxlev, istat->lb);
}
}
void my_lqual(u8 ifid, int per)
{
PRINT("Interface File [%3d] LQUAL : %d%% PER\r\n", ifid, per);
}
void my_ldown(u8 ifid)
{
PRINT("Interface File [%3d] LDOWN\r\n", ifid);
}
void my_reset(void)
{
NVIC_SystemReset();
}
void my_boot(u8 cause, u16 number)
{
PRINT("Modem BOOT[%c] #%d\r\nRe-Init\r\n", cause, number);
// Modem re-booted, restart APP
my_reset();
}