Hi,
I am using fcm UART1 and I want to send on UART1 periodically some data. I’ve inserted adl_fcmSendData(FCMHandler,“abc”,3); in timer handler, but it doesn’t work.
What’s wrong with this call in timer? Seems that it cannot work with fcm? How can I resolve this issue?
Code:
#include "adl_global.h"
/***************************************************************************/
/* Mandatory variables */
/*-------------------------------------------------------------------------*/
/* wm_apmCustomStackSize */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
const u16 wm_apmCustomStackSize = 1024;
s8 FCMHandler;
bool FcmCtrlHandler (adl_fcmEvent_e Event)
{
s8 s8r;
TRACE (( 1, "Ctrl Event %d", Event));
switch (Event)
{
case ADL_FCM_RET_ERROR_GSM_GPRS_ALREADY_OPENNED :
{
TRACE((1, "Flow GSM already Opened"));
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_FLOW_OPENNED\n\r");
break ;
}
case ADL_RET_ERR_PARAM :
{
TRACE((1, "Open Flow GPRS Parameters Error"));
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_FLOW_OPENNED\n\r");
break ;
}
case ADL_RET_ERR_ALREADY_SUBSCRIBED :
{
TRACE((1, "Flow GPRS already subscribed"));
adl_atSendResponse ( ADL_AT_UNS, "ADL_FCM_EVENT_FLOW_OPENNED\n\r");
break ;
}
case ADL_FCM_EVENT_FLOW_OPENNED :
{
TRACE((1, "ADL_FCM_EVENT_FLOW_OPENNED"));
adl_atSendResponse(ADL_AT_UNS,"fcmSubscribe openned\r\n");
adl_fcmSwitchV24State(FCMHandler,ADL_FCM_V24_STATE_DATA);
TRACE(( 1, "adl_fcmSwitchV24State Ret= %d", s8r));
break ;
}
case ADL_FCM_EVENT_FLOW_CLOSED :
{
adl_atSendResponse(ADL_AT_UNS,"fcmSubscribe openned\r\n");
TRACE((1, "ADL_FCM_EVENT_FLOW_CLOSED"));
break ;
}
case ADL_FCM_EVENT_RESUME :
{
adl_atSendResponse(ADL_AT_UNS,"fcmSubscribe openned\r\n");
TRACE((1, "ADL_FCM_EVENT_RESUME"));
break ;
}
case ADL_FCM_EVENT_MEM_RELEASE :
{
adl_atSendResponse(ADL_AT_UNS,"fcmSubscribe openned\r\n");
TRACE((1, "ADL_FCM_EVENT_MEM_RELEASE"));
break ;
}
case ADL_FCM_EVENT_V24_DATA_MODE:
{
TRACE((1, "ADL_FCM_EVENT_V24_DATA_MODE"));
adl_atSendResponse(ADL_AT_UNS,"now be data_mode\r\n");
s8r=adl_fcmSendData(FCMHandler,"abc",3);
TRACE(( 1, "adl_fcmSendData Ret= %d", s8r));
break ;
}
case ADL_FCM_EVENT_V24_AT_MODE:
{
TRACE((1, "ADL_FCM_EVENT_V24_DATA_MODE"));
adl_atSendResponse(ADL_AT_UNS,"now be at_mode\r\n");
break ;
}
default :
{
adl_atSendResponse(ADL_AT_UNS,"FCM_ControlHandler Event not processed\r\n");
TRACE((1, "Embedded : FCM_ControlHandler Event not processed"));
break ;
}
}
return TRUE;
}
bool FcmDataHandler (u16 DataLen, u8 * Data)
{
TRACE (( 1, "Data Event %d", DataLen));
char Buffer[150];
sprintf(Buffer," %u : ",DataLen);
adl_fcmSendData (FCMHandler,(u8*)&Buffer,(u16)strlen(Buffer));
adl_fcmSendData (FCMHandler,Data,DataLen);
return TRUE;
}
void HelloWorld_TimerHandler ( u8 ID )
{
TRACE (( 1, __TIME__ ));
TRACE (( 1, "Value of ID: %d",ID ));
adl_fcmSendData(FCMHandler,"abc",3);
}
/***************************************************************************/
/* Function : adl_main */
/*-------------------------------------------------------------------------*/
/* Object : Customer application initialisation */
/* */
/*-------------------------------------------------------------------------*/
/* Variable Name |IN |OUT|GLB| Utilisation */
/*--------------------+---+---+---+----------------------------------------*/
/* InitType | | | | Application start mode reason */
/*--------------------+---+---+---+----------------------------------------*/
/***************************************************************************/
void adl_main ( adl_InitType_e InitType )
{
TRACE (( 1, "Embedded : Appli Init" ));
if (adl_fcmIsAvailable(ADL_PORT_GSM_BASE)== TRUE)
{
TRACE (( 1, "ADL_PORT_GSM_BASE READY TO HANDLE" ));
adl_atSendResponse ( ADL_AT_UNS, "ADL_PORT_GSM_BASE READY TO HANDLE\32\r\n" );
}
else
{
TRACE (( 1, "NOT READY -> ADL_PORT_GSM_BASE" ));
adl_atSendResponse ( ADL_AT_UNS, "NOT READY -> ADL_PORT_GSM_BASE\32\r\n" );
}
if (adl_fcmIsAvailable(ADL_PORT_GPRS_BASE)== TRUE)
{
TRACE (( 1, "ADL_PORT_GPRS_BASE READY TO HANDLE" ));
adl_atSendResponse ( ADL_AT_UNS, "ADL_PORT_GPRS_BASE READY TO HANDLE\32\r\n" );
}
else
{
TRACE (( 1, "NOT READY -> ADL_PORT_GPRS_BASE" ));
adl_atSendResponse ( ADL_AT_UNS, "NOT READY -> ADL_PORT_GPRS_BASE\32\r\n" );
}
if (adl_fcmIsAvailable(ADL_PORT_UART1)== TRUE)
{
TRACE (( 1, "ADL_PORT_UART1 READY TO HANDLE" ));
adl_atSendResponse ( ADL_AT_UNS, "ADL_PORT_UART1 READY TO HANDLE\32\r\n" );
}
else
{
TRACE (( 1, "NOT READY -> ADL_PORT_UART1" ));
adl_atSendResponse ( ADL_AT_UNS, "NOT READY -> ADL_PORT_UART1\32\r\n" );
}
FCMHandler = adl_fcmSubscribe( ADL_PORT_UART1, FcmCtrlHandler , FcmDataHandler);
/* Set cyclic timer */
adl_tmrSubscribe ( TRUE, 60, ADL_TMR_TYPE_100MS, HelloWorld_TimerHandler );
}
In terminal I get:
Thanks in advance.
Tom