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

BLE_CTS_C_EVT_CURRENT_TIME/INVALID_TIME events never thrown

Hi,

I am using SDK14.2, s132, with nRF Connect on Android.

I have used my own implementation of the CTS_C BLE service. The chip is able to detect, and request the current time, with nRF Connect showing that it sends the correct time over.

However, neither the BLE_CTS_C_EVT_CURRENT_TIME or BLE_CTS_C_EVT_INVALID_TIME events are triggered.

I have tried the ble_app_cts_c example hex, and it works fine.

EDIT: To further add to this: the event BLE_GATTC_EVT_READ_RSP is never called in ble_cts_c_on_ble_evt. The BLE_GAP_EVT_CONNECTED event is called, so the handler is definitely working.

Parents
  • Hello,

    The issue is that the m_cts_c, which was defined in tnd_ble_cts_c.h is never updated in tnd_ble_cts_c.c, so it doesn't get the updated pointer to the p_cts->evt_handler in current_time_read() in ble_cts_c.c. 

    The problem is that when you have this type variable in a header file, all the other files that include this header file and uses the variable will generate an own instance of the variable. The solution is to use declare this variable in a .c file, and use extern for all other files that need access to this parameter. 

    This is easy when you have it in the main.c file, because you don't need to pass this variable around. When you have it in a different file, you must use extern. Since it is a static, you can't use extern as it, so you might have to change the macro (BLE_CTS_C_DEF()).

    The easier solution is to move it to the main.c file, but if you want to separate it into a different file, you must work around this issue.

    Best regards,

    Edvin

Reply
  • Hello,

    The issue is that the m_cts_c, which was defined in tnd_ble_cts_c.h is never updated in tnd_ble_cts_c.c, so it doesn't get the updated pointer to the p_cts->evt_handler in current_time_read() in ble_cts_c.c. 

    The problem is that when you have this type variable in a header file, all the other files that include this header file and uses the variable will generate an own instance of the variable. The solution is to use declare this variable in a .c file, and use extern for all other files that need access to this parameter. 

    This is easy when you have it in the main.c file, because you don't need to pass this variable around. When you have it in a different file, you must use extern. Since it is a static, you can't use extern as it, so you might have to change the macro (BLE_CTS_C_DEF()).

    The easier solution is to move it to the main.c file, but if you want to separate it into a different file, you must work around this issue.

    Best regards,

    Edvin

Children
Related