Sending Message Failed in HTC Freestyle device | developer.brewmp.com Sending Message Failed in HTC Freestyle device | developer.brewmp.com

Developer

Sending Message Failed in HTC Freestyle device

Forums:

I have written code for sending a text message. I can receive successfully sent DEBGPRINTF messaes from Simulator.

Where as in device it is not able to send a message.

Here is the code:

boolean sendSMS(ameb *pMe, const char *mobileNo, const char *msg)
{
  SMSMsgOpt sOpts[10];
  byte		*buff, *buff1;
  int nErr;
  DBGPRINTF("In Send Sms");
  buff = (byte*)MALLOC(100);
  buff1 = (byte*)MALLOC(100);

  if(ISHELL_CreateInstance(pMe->piShell, AEECLSID_SMS, (void**)&pMe->m_SMSNotificationdata.pSms) != SUCCESS)
return FALSE;

  if(ISHELL_CreateInstance(pMe->piShell, AEECLSID_SMSMSG, (void**)&pMe->m_SMSNotificationdata.pSmsMsgRec) != SUCCESS)
return FALSE;

sOpts[0].nId = MSGOPT_COPYOPTS;
	sOpts[0].pVal = (void *)TRUE;

	sOpts[1].nId = MSGOPT_PAYLOAD_ENCODING;
	sOpts[1].pVal = (void *)AEE_ENC_ISOLATIN1; //(void *)pMe->m_payloadEncoding;//

	// Set the destination address on our outbound sms message
	sOpts[2].nId = MSGOPT_TO_DEVICE_SZ;
	sOpts[2].pVal = (void *)mobileNo;

	// priority
	sOpts[3].nId = MSGOPT_PRIORITY;
	sOpts[3].pVal = (void *)AEESMS_PRIORITY_URGENT;

	//append ur min no (last 10 digits)
	sOpts[4].nId = MSGOPT_FROM_DEVICE_SZ;
	sOpts[4].pVal = (void *)"9663867128";//pMe->m_SMSNotificationdata.myMobileNo;

	// encoding simple english
	sOpts[5].nId = MSGOPT_MOSMS_ENCODING;
	sOpts[5].pVal = (void *)AEESMS_ENC_ASCII; //(void *)pMe->m_moEncoding;//

	*((uint16*)buff1) = STRLEN(msg) - 2;
	STRCPY((char*)(buff1+2), (char*)msg);
	WEBOPT_SETVARBUFFER(buff, buff1, (STRLEN(msg) - 2));


	// text message
	//sOpts[6].nId = MSGOPT_PAYLOAD_BINARY;
	//sOpts[6].pVal = (void *)buff;

	sOpts[7].nId = MSGOPT_END;
	sOpts[7].pVal = NULL;

	nErr = ISMSMSG_AddOpt(pMe->m_SMSNotificationdata.pSmsMsgRec, (WebOpt *)&sOpts);
	if (nErr != SUCCESS)
	{
		DBGPRINTF("FAILED IN ADDING OPTS\n");
	}

	LISTENER_Init(&pMe->m_SMSNotificationdata.smsListner, smsListnerCB, pMe);

	ISMS_QueryInterface(pMe->m_SMSNotificationdata.pSms, AEEIID_MODEL, (void**)&pMe->m_SMSNotificationdata.pModel);

	IModel_AddListener(pMe->m_SMSNotificationdata.pModel, &pMe->m_SMSNotificationdata.smsListner);

	CALLBACK_Cancel(&pMe->m_SMSNotificationdata.sendingCB);
    CALLBACK_Init(&pMe->m_SMSNotificationdata.sendingCB, (PFNNOTIFY)smsSendCB, pMe);

	ISMS_SendMsg(pMe->m_SMSNotificationdata.pSms, pMe->m_SMSNotificationdata.pSmsMsgRec, &pMe->m_SMSNotificationdata.sendingCB, &pMe->m_SMSNotificationdata.sendStatus);
	
		return TRUE;

 

void smsListnerCB(ameb *pMe, ModelEvent *pEvent)
{
	IDISPLAY_ClearScreen(pMe->piDisplay);
	ISHELL_CancelTimer(pMe->piShell, (PFNNOTIFY)sendingScreen, pMe);


	switch(pEvent->evCode)
	{
	case EVT_MDL_SMS_MSG_SENT:
		if(pEvent->dwParam)
		{
		DBGPRINTF("SUCCESSFULLY SENT\n");	
		}

		break;
	case EVT_MDL_SMS_DUPLICATE_CB_PAGE:
		IDISPLAY_DrawText(pMe->piDisplay, AEE_FONT_BOLD, (AECHAR*)L"SMS_DUPLICATE_CB_PAGE", -1, 0, 0, NULL, IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM);
		DBGPRINTF("SMS_DUPLICATE_CB_PAGE");
		break;
	case EVT_MDL_SMS_CELL_CHANGE:
		IDISPLAY_DrawText(pMe->piDisplay, AEE_FONT_BOLD, (AECHAR*)L"SMS_CELL_CHANGE", -1, 0, 0, NULL, IDF_ALIGN_CENTER | IDF_ALIGN_BOTTOM);
		DBGPRINTF("SMS_CELL_CHANGE");
		break;
	default:
		DBGPRINTF("default");
		break;
	}
	IDISPLAY_Update(pMe->piDisplay);

void smsSendCB(ameb *pMe)
{
	uint16 errType = AEESMS_GETERRORTYPE(pMe->m_SMSNotificationdata.sendStatus);
	uint16 err = AEESMS_GETERROR(pMe->m_SMSNotificationdata.sendStatus);
switch(err) 
{
case AEESMS_ERROR_NONE:
{
DBGPRINTF("SMS_MSG_SENT ############################  SMS_MSG_SENT\n");
DBGPRINTF("SUCCESSFULLY SENT: %d \n", errType);

break;
case AEESMS_ERROR_SMS_DELIVERY_POSTPONED:
DBGPRINTF("SUCCESSFULLY SMS_DELIVERY_POSTPONED: %d \n", errType);
break;
case AEESMS_ERROR_NETWORK_NOT_READY:
DBGPRINTF("SUCCESSFULLY ERROR_NETWORK_NOT_READY: %d \n", errType);
break;
default:
DBGPRINTF("Error type: %d \n", errType);
DBGPRINTF("Error = %d \n", err);
// Insert code to handle uncommon error
break;

		
In simulator able to receive DBGPRINTF Messgaes as "Successfully sent"
In Device the errorType is 2 , Err = 147; Here i am not able to find the value for 147.
Please anyone can identify what the problem is, why it is failed in sending SMS?
What stands the error code 147?
Thanks

you will need to specify message option AEESMS_NUMBER_PLAN_TELEPHONY on some GSM/UMTS devices.
 
use the options as below & try:-
 
 
 
 
 
 
 
 

sOpts[0].nId = MSGOPT_TO_DEVICE_SZ;
sOpts[0].pVal = (
char*)"9899123366";
sOpts[1].nId = MSGOPT_MOSMS_ENCODING;
sOpts[1].pVal = (void*) AEESMS_ENC_GSM_7_BIT_DEFAULT;
sOpts[2].nId = MSGOPT_PAYLOAD_SZ;
sOpts[2].pVal = (void*)"My message";
sOpts[3].nId = MSGOPT_PAYLOAD_ENCODING;
sOpts[3].pVal = (void *)AEE_ENC_GSM_7_BIT_DEFAULT;
sOpts[4].nId = MSGOPT_TO_NUMBER_PLAN;
sOpts[4].pVal = (void*)AEESMS_NUMBER_PLAN_TELEPHONY;
sOpts[5].nId = MSGOPT_END;
 

nErr = ISMSMSG_AddOpt(pMe->pSmsMsgRec, (WebOpt *)&sOpts);
 

LISTENER_Init(&pMe->smsListner, smsListnerCB, pMe);

ISMS_QueryInterface(pMe->pSms, AEEIID_MODEL, (
void**)&pMe->pModel);
IModel_AddListener(pMe->pModel, &pMe->smsListner);
ISMS_SendMsg(pMe->pSms, pMe->pSmsMsgRec, &pMe->sendingCB, &pMe->sendStatus);
 

you will need to specify message option AEESMS_NUMBER_PLAN_TELEPHONY on some GSM/UMTS devices.
 
use the options as below & try:-
 
 
 
 
 
 
 
 

sOpts[0].nId = MSGOPT_TO_DEVICE_SZ;
sOpts[0].pVal = (
char*)"9899123366";
sOpts[1].nId = MSGOPT_MOSMS_ENCODING;
sOpts[1].pVal = (void*) AEESMS_ENC_GSM_7_BIT_DEFAULT;
sOpts[2].nId = MSGOPT_PAYLOAD_SZ;
sOpts[2].pVal = (void*)"My message";
sOpts[3].nId = MSGOPT_PAYLOAD_ENCODING;
sOpts[3].pVal = (void *)AEE_ENC_GSM_7_BIT_DEFAULT;
sOpts[4].nId = MSGOPT_TO_NUMBER_PLAN;
sOpts[4].pVal = (void*)AEESMS_NUMBER_PLAN_TELEPHONY;
sOpts[5].nId = MSGOPT_END;
 

nErr = ISMSMSG_AddOpt(pMe->pSmsMsgRec, (WebOpt *)&sOpts);
 

LISTENER_Init(&pMe->smsListner, smsListnerCB, pMe);

ISMS_QueryInterface(pMe->pSms, AEEIID_MODEL, (
void**)&pMe->pModel);
IModel_AddListener(pMe->pModel, &pMe->smsListner);
ISMS_SendMsg(pMe->pSms, pMe->pSmsMsgRec, &pMe->sendingCB, &pMe->sendStatus);