Flash memory read/write

Hello all.

I’m trying to save some data into the flash memory of a wismo gprs modem, but i’m having some trouble. When I do “adl_flhExist(APNHandle, T2R_MYAPN_ID)” I get -23 as an answer (which I think it’s a “WM_BUS_NO_MORE_HANDLE_FREE” error).
If I delete this line and try to subscribe the handler using "adl_flhSubscribe (APNHandle, 1) " I get a -4 (“ADL_RET_ERR_ALREADY_SUBSCRIBED” I think). Can someone lend me a hand with this? I’m writing parts of the code just below.

#define T2R_MYAPN_ID 1
ascii MyAPN[50];
ascii APNHandle[4] = “APN\0”; //I already tried with ascii *APNHandle = “APN”
void Cmdt2rusr_Handler ( adl_atCmdPreParser_t *param );

void adl_main (adl_InitType_e InitType){

s32 length;

if (!adl_flhExist(APNHandle, T2R_MYAPN_ID)) //Here i get the -23
adl_flhSubscribe (APNHandle, 1); //Here the -4 if i comment the “if” above

if ((length = adl_flhExist (APNHandle, T2R_MYAPN_ID)) > 0)
//length is -23 again
adl_flhRead ( APNHandle, T2R_MYAPN_ID, length, MyAPN );

adl_atCmdSubscribe (“AT+T2RUSR”, Cmdt2rusr_Handler,

void Cmdt2rusr_Handler (adl_atCmdPreParser_t *param){

u16 length = 0;
ascii localAPN[50];
ascii *cmdStr;

if (param->Type == ADL_CMD_TYPE_PARA){
cmdStr = param->StrData;
wm_strGetParameterString ( localAPN, cmdStr, 1 );
strcpy ( MyAPN, localAPN );
if ((length = adl_flhExist (APNHandle, T2R_MYAPN_ID)) > 0){
//Here length is 65513 :S
adl_flhWrite (APNHandle, T2R_MYAPN_ID, length, localAPN);
//adl_flhWrite returns another -23…

Thanks in advance for your help :slight_smile:


First, When using “adl_flhSubscribe(handle, NbOfObject)”, you must specified the maximum of object that this handle handling.

Second, When using adl_flh_Exist(handle, ObjectID), you must specified the OjectID include between 0 and (NbOfObject - 1) range. (adl_flhRead() is the same behaviour)

So, in your case :

#define NbOfObject         1
#define T2R_MYAPN_ID   0

if (!adl_flhExist(APNHandle, T2R_MYAPN_ID))      
adl_flhSubscribe (APNHandle, NbOfObject         );

adl_flhRead ( APNHandle, T2R_MYAPN_ID, length, MyAPN ); 

So, it should be running properly. But, i think that you should use adl_flhSubscribe() before using adl_flhExist() function…

Hope it would help !


I understand your solution, and i’m going to try it. I think i’ll get an “Handler already installed” (-4) from the subscriptor, but that doesn’t matter, does it? :slight_smile: Thank you very much for your answer. If it doesn’t work, i’ll post again ^_^.

I have the same problem I also get -23 :frowning:

Handler already installed doesn’t matter. This only means that you have alredy previously subscribed after the last clearing the flash (e.g. with AT+WOPEN=3)

Best Regards,