Error on sending sms (again)


#1

hi, i have a sample as follow

#include "adl_global.h"
const u16 wm_apmCustomStackSize = 1024;
s8 handle;
adl_tmr_t *timeid;
bool isInited;

bool smsHandler(ascii *smsTel, ascii* smsTimeLength, ascii* smsText) {
	ascii buffer[200];
	wm_sprintf(buffer, "receive message from %s", smsTel);
	TRACE((1,buffer));
	wm_sprintf(buffer, "time=%s", smsTimeLength);
	TRACE((1,buffer));
	wm_sprintf(buffer, "content=%s", smsText);
	TRACE((1,buffer));
	return TRUE;
}

void smsCtlHandler(u8 event, u16 nb) {
	switch (event) {
	case ADL_SMS_EVENT_SENDING_OK:
		TRACE((1,"sms sending ok"));
		break;
	case ADL_SMS_EVENT_SENDING_ERROR:
		TRACE((1,"sms sending error, code=%d",nb));
		break;
	case ADL_SMS_EVENT_SENDING_MR:
		TRACE((1,"sms sending ok, refer=%d ",nb));
		break;
	}
}
void sendSmsDelay(u8 ID) {
	if (isInited) {
		handle = adl_smsSubscribe(smsHandler, smsCtlHandler, ADL_SMS_MODE_TEXT);
		TRACE((1,"subscribed code %d",handle));
		s8 ret = adl_smsSend(handle, "0948138008", "hi~hi~", ADL_SMS_MODE_TEXT);
		TRACE((1,"sending message is %d",ret));
		adl_tmrUnSubscribe(timeid, sendSmsDelay, ADL_TMR_TYPE_100MS);
	} else {
		adl_simState_e st = adl_simGetState();
		TRACE((1,"wait for full init, state %d",st));
	}
}
void simHandler(u8 event) {
	switch (event) {
	case ADL_SIM_EVENT_PIN_OK:
		TRACE((1,"sim event pin ok"));
		break;
	case ADL_SIM_EVENT_REMOVED:
		TRACE((1,"sim event removed"));
		break;
	case ADL_SIM_EVENT_INSERTED:
		TRACE((1,"sim event inserted"));
		break;
	case ADL_SIM_EVENT_FULL_INIT:
		TRACE((1,"sim event full init"));
		isInited = TRUE;
		break;
	case ADL_SIM_EVENT_PIN_ERROR:
		TRACE((1,"event pin error"));
		break;
	case ADL_SIM_EVENT_PIN_NO_ATTEMPT:
		TRACE((1,"event pin no attempt"));
		break;
	case ADL_SIM_EVENT_PIN_WAIT:
		TRACE((1,"event pin wait"));
		break;
	}
}
void adl_main(adl_InitType_e InitType) {
	TRACE (( 1, "project 10 sms : Main" ));
	isInited = FALSE;
	s32 ret = adl_simSubscribe(simHandler,NULL);
	TRACE((1,"Subscribed %d",ret));
	timeid = adl_tmrSubscribe(TRUE, 50, ADL_TMR_TYPE_100MS, sendSmsDelay);
}

when i start this sample, the simHandler did not receive ADL_SIM_EVENT_FULL_INIT event, adl_getSimState() function always return 0 (still init process, i think), if i call adl_smsSend() at this time, it return ADL_RET_ERR_BAD_STATE. the problem is that i wait for sim init procgress for long long time but simHandler still does not receive a ADL_SIM_EVENT_FULL_INIT.

  1. at this time, if i use AT+CMGS command to send sms, it send ok, so i think sim init progress must finished.
  2. but, if i remove the sim and insert back, this time simHandler receive ADL_SIM_EVENT_FULL_INIT event, and it work fine.

so i need remove & insert the sim everytime i run this sample , but where it was wrong? thanks.


#2

Do a search on “ADL_SIM_EVENT_FULL_INIT” - this kind of thing has been discussed before.

In particular, when running in RTE (Remote) mode, early events are often missed.

You could also try subscribing WIND events…


#3

thanks, in old topic i didn’t see this.