This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Rtc tutorial

Hi

how to configure rtc for nrf51dk and i want to update time from my phone then how to read the current time in device ?

Parents
  • Hi Gokul,

    You can have a look at the ble_app_cts_c Curent Time Service example. The documentation is here.

    Note that in the example, testing is done with the MCP on PC. If you want to use it with the phone, you would need to implement the GATT server on the phone with the CTS service.

    After you can send the current time from the phone to the nRF51 you can use RTC to continue counting.

  • Hi hung, i got struck up in update_current_time_value_in_sd()

    static uint32_t update_current_time_value_in_sd(ble_cts_t * p_cts){ uint16_t len; uint8_t encodedDateTime[ENC_DATE_TIME_LENGTH];

    // TODO: implement a function to get the time
    cts_getTime(&dateTime);
    
    len = (uint16_t) ble_date_time_encode(&dateTime, encodedDateTime);
    
    // write the new value into the softdevice
    return sd_ble_gatts_value_set(p_cts->current_time_handles.value_handle,  0, &len, encodedDateTime);
    

    }

    will u send some explanation for that

Reply
  • Hi hung, i got struck up in update_current_time_value_in_sd()

    static uint32_t update_current_time_value_in_sd(ble_cts_t * p_cts){ uint16_t len; uint8_t encodedDateTime[ENC_DATE_TIME_LENGTH];

    // TODO: implement a function to get the time
    cts_getTime(&dateTime);
    
    len = (uint16_t) ble_date_time_encode(&dateTime, encodedDateTime);
    
    // write the new value into the softdevice
    return sd_ble_gatts_value_set(p_cts->current_time_handles.value_handle,  0, &len, encodedDateTime);
    

    }

    will u send some explanation for that

Children
No Data
Related