This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LAUNCHXL-CC2640R2: BLE does not advertise, Unknown error

Part Number: LAUNCHXL-CC2640R2

Hi,

I was developing a custom application on CC2640R2 using Project Zero example code. I developed a custom get_rtc(char *date_time) and set_rtc(char *date_time). The function take in timestamp in the format of ddmmyyhhmmss, calculate the unix_epoh and set the RTC via the Seconds module. The get_rtc function takes the unix epoch time from the seconds module and prints it on the argument in ascii text.

Here's the implementation:

void set_rtc(char *date_time)
{
    unsigned int sec=0,min=0,hour=0,mon=0,day=0,year=0;
    char temp[3] = {0};
    char *l_ptr = (char *)date_time;

    /*  get date */
    strncpy(temp, l_ptr, 2);
    day = atoi(temp);
    l_ptr += 2;

    strncpy(temp, l_ptr, 2);
    mon = atoi(temp);
    l_ptr += 2;
    mon-=1;

    strncpy(temp, l_ptr, 2);
    year = atoi(temp);
    l_ptr += 2;
    /* get time */
    strncpy(temp, l_ptr, 2);
    hour = atoi(temp);
    l_ptr += 2;

    strncpy(temp, l_ptr, 2);
    min = atoi(temp);
    l_ptr += 2;

    strncpy(temp, l_ptr, 2);
    sec = atoi(temp);

    /* calculate unix_time(epoch) */
    uint32_t unix_epoch = maketime(sec,min,hour,day,mon,year);
    Seconds_set(unix_epoch);
}

void get_rtc(char *date_time)
{
    time_t t1;
    struct tm *ltm;
    //char *curTime;
    char *curTime = ICall_malloc(100);

    t1 = time(NULL);
    ltm = localtime(&t1);

    curTime = asctime(ltm);

    if(curTime != NULL)
    strncpy(date_time, curTime, 12);
    *(date_time + 12) = 0x00;

    ICall_free(curTime);

}

In order to test these functions I called them in ProjectZero Init function.

char dtime[] = "290220112639";

/*
 * @brief   Called before the task loop and contains application-specific
 *          initialization of the BLE stack, hardware setup, power-state
 *          notification if used, and BLE profile/service initialization.
 *
 * @param   None.
 *
 * @return  None.
 */
static void ProjectZero_init(void)
{
    char curTime1[40] = {0};
  // ******************************************************************
  // NO STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp
  // ******************************************************************
  // Register the current thread as an ICall dispatcher application
  // so that the application can send and receive messages via ICall to Stack.
  ICall_registerApp(&selfEntity, &syncEvent);
  //...
  Seconds_set(0);
  set_rtc((char *)dtime);
    get_rtc(curTime1);
    //...
}

But when I do this, later in the code, BLE does not start advertising.  I'm assuming there is some error that is stopping the bluetooth.

My SDK version is 4.20 and TI compiler version is TI v16.9.1.LTS .

What could be the error and how to solve it?