Getting errors related to logging

The application seems to stop at an instance where I invoke a Send call to send data over to a ble central, and the callstack looks as follows. Any way to narrow down the cause?



I tried the program later and I got the following stack. Thing is: nothing useful gets printed in the debug console

Parents
  • Hi Morpho, 

    It looks like it got an assertion and app_error_handler () was called. 

    If you haven't, please include DEBUG in the preprocessor symbols in project setting. You can add  a breakpoint inside app_error_handler and check which file name, which line of code and which error code was returned. 

  • the filename: 0x0003a1dc, error code: 8, line number: 63

  • HI Morpho,

    What I meant was not about a specific time delay but more about wait for the write command that enable CCCD before you send the notification. 

    If you have a look into the ble_hrs.c file you can find that the on_write() function is called when BLE_GATTS_EVT_WRITE is received (in ble_hrs_on_ble_evt). 
    In side on_write() it will call on_hrm_cccd_write() if it's the write command to the cccd handle. 

    ble_srv_is_notification_enabled() will check if the value written to the CCCD handle is to enable or disable Notification (not Indication)

    You can implement something similar in your ble event handler of your service. 

  • so I verified that as soon as I tap on the CCCD button in the nRF app, if (p_evt_write->handle == p_hrs->hrm_handles.cccd_handle) condition becomes true.

    I'm developing a custom service. Where/What exactly is hrm_handles.cccd_handle set to?

  • I assume you were testing with the ble_app_hrm example ? The cccd_handle got it value when you call characteristic_add(). The handle is the location of the characteristic inside the attribute table in the softdevice. So when you declare a characteristic it will get a handle value from the softdevice assigned to. 
    Please have a look at characteristic_add() call inside ble_hrs_init(). 

    If you are developing a custom service, I would suggest to have a look at the ble_app_uart example. 

  • Yes I have mostly referred to ble_app_uart that uses ble NUS for reference, and am familiar with it more than HRS.


    After playing around, I realized taking the traditional approach that uses notification_enabled flag may not work since my Send() function doesn't really take in conn_handle for instance, and blcm_link_ctx_get() returned with an error of 14.

    So I tried just getting rid of APP_ERROR_CHECK() from my Send() function to avoid assertions, however now I just don't seem to be getting any event  (ble_cus_on_ble_evt isn't firing) upon pressing the Enable Notification button on the nRF Connect app,

    And its Value field remains N/A 


    Actually, for some weird reason, it seems to be picking up NUS as opposed to my custom service. This seems odd. Do you see what may be happening? I tried reinstalling the app to noa vail

  • Hi Morpho, 
    Skipping APP_ERROR_CHECK() might not be a good idea. It won't allow you to detect if there is any error. 
    When you receive an error you would need to check what it tells you. For example error 14 means NRF_ERROR_NULL (check nrf_error.h) and if you read the description of blcm_link_ctx_get() you can find:

    * @retval NRF_ERROR_NULL If \p p_link_ctx_storage is NULL or contains a NULL pointer, or if
    * \p pp_ctx_data is NULL.

    You would need to check if p_link_ctx_storage  or pp_ctx_data  is NULL. 

    From the screenshot you provided I don't see your proprietary service, only the NUS service. 

Reply
  • Hi Morpho, 
    Skipping APP_ERROR_CHECK() might not be a good idea. It won't allow you to detect if there is any error. 
    When you receive an error you would need to check what it tells you. For example error 14 means NRF_ERROR_NULL (check nrf_error.h) and if you read the description of blcm_link_ctx_get() you can find:

    * @retval NRF_ERROR_NULL If \p p_link_ctx_storage is NULL or contains a NULL pointer, or if
    * \p pp_ctx_data is NULL.

    You would need to check if p_link_ctx_storage  or pp_ctx_data  is NULL. 

    From the screenshot you provided I don't see your proprietary service, only the NUS service. 

Children
  • From the screenshot you provided I don't see your proprietary service, only the NUS service. 

    Exactly. In the first screenshot, you could my service but for some reason, I no longer see it even though I reverted my changes to the older revision. Do you really why would this be?

    Skipping APP_ERROR_CHECK() might not be a good idea. It won't allow you to detect if there is any error. 

    Oh, I thought that's what you initially meant when you mentioned "you can modify the code to ignore the NRF_ERROR_INVALID_STATE and not assert it. "

  • Hi Morpho, 

    Please do it step by step. 
    Step one you can try to remove the UART service in the example and flash and check what you have in the ATT table when doing service discovery. Try not to bond to the device because the phone may cache the att table and don't update it if it's bonded. 

    Step two you can add your own service (without any functionality) just to check if the service is listed in the att table. 

    After you can find it in the att table you can start implementing the code as we discussed earlier. 

  • Sir, I just don't understand how's UART service even being initialized when i'm not even doing so in my code? Or maybe if you could point me to a specific point in the code that shoud really tell whether UART service is being used or not. In the first screenshot you can see the custom service that's initialized. Just not sure how i'm no longer seeing it.

    that's what I have. 

    I do see my service under Advertised Services however not quite under Attribute Table

    #define CUSTOM_SERVICE_UUID_BASE {0xBC, 0x8A, 0xBF, 0x45, 0xCA, 0x05, 0x50, 0xBA, \
    0x40, 0x42, 0xB0, 0x00, 0xC9, 0xAD, 0x64, 0xF3}
    
    ble_uuid128_t baseUuid = {CUSTOM_SERVICE_UUID_BASE};
    errorCode =  sd_ble_uuid_vs_add(&baseUuid, &pSrvInfo->uuidType);

  • Hi, 
    Please be aware that the advertising data and the attribute table may not be related. They are belong to two different profiles and is configured independently. 

    What you add to advertising packet is only for advertising/connecting and has nothing to do when you are connected. 

    What is added to the attribute table is with these call sd_ble_gatts_service_add and sd_ble_gatts_characteristic_add



    Please have a look at this guide 

  • the advertising data is only useful when the peripheral is connected to the central though no? is sending data when the peripheral isn't even connected any good? but just advertising a base UUID has nothing to do with connection; from what I understand, it just allows the central to see the advertised peripheral in the scan list.

    and you only see the attribute table after the connection is established, and i'm indeed using my custom service characteristics  which are passed to sd_ble_gatts_characteristic_add as well as sd_ble_gatts_service_add for adding a custom service.


    Are you fully certain it has nothing to do with the nRF Connect app which has previously been found to be buggy?

Related