Why UART1 always be AT_MODE?


#1
#include "adl_global.h"

/***************************************************************************/
/*  Mandatory variables                                                    */
/*-------------------------------------------------------------------------*/
/*  wm_apmCustomStack                                                      */
/*  wm_apmCustomStackSize                                                  */
/*-------------------------------------------------------------------------*/
/***************************************************************************/
u32 wm_apmCustomStack [ 256 ];
const u16 wm_apmCustomStackSize = sizeof ( wm_apmCustomStack );


/***************************************************************************/
/*  Local variables                                                        */
/***************************************************************************/
s8 FCMHandler = -1;
s8 FCMReady = 0;

/***************************************************************************/
/*  Local functions                                                        */
/***************************************************************************/
bool FCM_ControlHandler(adl_fcmEvent_e Event)
{
	s8 s8r;
	switch (Event)
	{
	case ADL_FCM_RET_ERROR_GSM_GPRS_ALREADY_OPENNED :
		{
			TRACE((1, "Flow GSM already Opened"));
			break ;
		}
	case ADL_RET_ERR_PARAM :
		{
			TRACE((1, "Open Flow GPRS Parameters Error"));
			break ;
		}
	case ADL_RET_ERR_ALREADY_SUBSCRIBED :
		{
			TRACE((1, "Flow GPRS already subscribed"));
			break ;
		}
	case ADL_FCM_EVENT_FLOW_OPENNED :
		{
			TRACE((1, "ADL_FCM_EVENT_FLOW_OPENNED"));
			adl_atSendResponse(ADL_AT_UNS,"fcmSubscribe openned\r\n");
			s8r=adl_fcmSwitchV24State(FCMHandler,ADL_FCM_V24_STATE_DATA); 
			TRACE(( 1, "adl_fcmSwitchV24State Ret= %d", s8r)); 
			break ;
		}
	case ADL_FCM_EVENT_FLOW_CLOSED :
		{
			TRACE((1, "ADL_FCM_EVENT_FLOW_CLOSED"));
			break ;
		}
	case ADL_FCM_EVENT_RESUME :
		{
			TRACE((1, "ADL_FCM_EVENT_RESUME"));
			break ;
		}
	case ADL_FCM_EVENT_MEM_RELEASE :
		{
			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 :
		{
			TRACE((1, "Embedded : FCM_ControlHandler Event not processed"));
			break ;
		}
	}
	return TRUE ;
}

bool FCM_DataHandler(u16 DataLen, u8* Data)
{
	TRACE(( 1, "FCM_DataHandler"));
	DUMP( 1, Data, DataLen);
	return TRUE ;
}

/***************************************************************************/
/*  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 )
{
    bool b;
	TRACE (( 1, "Embedded Application : Main" ));
    
    // TO DO : Add your initialization code here

	b=adl_fcmIsAvailable(ADL_FCM_FLOW_V24_UART1);
	if (b)
		adl_atSendResponse(ADL_AT_UNS,"fcm available\r\n");
	else
		adl_atSendResponse(ADL_AT_UNS,"fcm unavailable\r\n");

	FCMHandler = adl_fcmSubscribe(ADL_FCM_FLOW_V24_UART1, FCM_ControlHandler, FCM_DataHandler);
	TRACE(( 1, "adl_fcmSubscribe Ret= %d", FCMHandler));
}

[b]My Settting:

at+wmfm?

+WMFM: 0,2,1,1
+WMFM: 0,2,2,0
+WMFM: 1,2,4,0
+WMFM: 1,2,4,1[/b]

Run Result:
fcm available
fcmSubscribe openned
now be data_mode
at
ok


#2

Because that is the default!

Think about it: when the unit powers up, it has to be able to accept AT commands from somewhere; not all products have more than 1 UART, so UART1 is the obvious place! 8)


#3

Hi
ascendlyd,

If you are trying your application with the Wavecom Terminal Emulator, it has two windows the AT window and the Data window.

It multiplexes the data you send, in a way that if you send AT commands through the AT window, the modem will answer that commands, and if you type any character in the Data window, it will recognize it as Data.

Maybe you can try it with hyperterminal and see what happens.

Regards,
Markheim