DATE and TIME


#1

I’m feeling like my brain is out to lunch, but I don’t see anything in the api or the Open AT Basic Development Guide, or the API from the ADL User Guide, regarding date and time. Is there no API call for this? Does anyone have any example code for this, or some code they are willing to distribute?

I get the feeling this may require a call to an AT command.

/* This will continually show the compiled date and time */
//standard stuff
#include "adl_global.h"
const u16 wm_apmCustomStackSize =       1024;
const u32 wm_apmIRQLowLevelStackSize =  1024;
const u32 wm_apmIRQHighLevelStackSize = 1024;

bool repeat = TRUE;
#define TIME 2 //in 100ms or 1/10 of second
void timer_function(u8);

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Timer: Main" ));
    adl_tmr_t * timer = adl_tmrSubscribe( repeat, TIME, ADL_TMR_TYPE_100MS, timer_function );
}


void timer_function(u8 p)
{
    adl_atSendResponse(ADL_AT_RSP, "Timer\r\n");
    adl_atSendResponse(ADL_AT_RSP, __DATE__);
    adl_atSendResponse(ADL_AT_RSP, "\r\n");
    adl_atSendResponse(ADL_AT_RSP, __TIME__);
    adl_atSendResponse(ADL_AT_RSP, "\r\n");   
}

#2

RTC = Real Time Clock…


#3

Thought someone else might appreciate this:

//standard stuff
#include "adl_global.h"
const u16 wm_apmCustomStackSize =       1024;
const u32 wm_apmIRQLowLevelStackSize =  1024;
const u32 wm_apmIRQHighLevelStackSize = 1024;

//local variables
bool repeat = TRUE;
#define TIME 20 //in 100ms or 1/10 of second

//function prototypes
void timer_function(u8);
bool Res_Cmd_Handler(adl_atResponse_t *paras);

void adl_main ( adl_InitType_e InitType )
{
    TRACE (( 1, "Timer: Main" ));
    adl_tmr_t * timer = adl_tmrSubscribe( repeat, TIME, ADL_TMR_TYPE_100MS, timer_function );
}


void timer_function(u8 p)
{
    adl_atSendResponse(ADL_AT_RSP, "Timer\r\n");
    adl_atCmdCreate ( "AT+CCLK?\r", TRUE, Res_Cmd_Handler, "*", NULL);
}

//  Return     : sReturn to or not to forward the Event                   
bool Res_Cmd_Handler(adl_atResponse_t *paras)
{
    ascii   *StringCopy;    
    TRACE (( 1, "Res_Cmd_Handler"));
    
    StringCopy = adl_memGet ( ( u16 ) ( wm_strlen ( paras->StrData ) + 1 ) );
    wm_strcpy ( StringCopy, paras->StrData );
    adl_atSendResponse(ADL_AT_RSP, StringCopy );
    adl_memRelease ( StringCopy );
    
    return TRUE;
}

#4

But there is no blocking call to get the current date and time?
I’m trying to use the clock for logging. With psuedo code something like

log (error)
{
____get_date&time();
____write_to_flash(date&time + error);
}


#5

Won’t the RTC do the job?


#6

“3.24.1 Required Header File
The header file for the RTC functions is:
adl_rtc.h”

I really really don’t know how I overlooked that section. I knew my brain was out to lunch, and I swear when I searched for rtc in the api file it didn’t find it. I apologize for wasting your time and feel like an idiot right now.