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

Health Thermometer not working

Hi,

I'm new with a) the Nordic Softdevice environment and b) using the nRF52. So there are a few questions...

As a starting point I've used the template project (...\SDK\nRF52_SDK_0.9.2_dbc28c9\examples\ble_peripheral\ble_app_template) and added a few services, i.e. the Device Information, Battery and Health Thermometer service (and also our own mds service). I find that I can communicate with the DIS, BAS and our service.

However, I'm unable to transmit temperatures over the HTS. In fact, the software crashes when calling temperature_measurement_send ().

The code for DIS, BAS and HTS are original Nordic, taken also from the SDK. So while DIS and BAS are working, HTS isn't? What am I doing wrong?

Thans for any help

stack.c

  • Hi. Can you check what error code ble_hts_measurement_send returns ?

  • Hi.

    The error code is BLE_ERROR_GATTS_SYS_ATTR_MISSING. This means that the softdevice does not know the system attributes for that characteristic. The system attributes are in practice only the cccd (Client Characteristic Configuration Descriptor). value. This is 1 when notifications are enabled, and zero otherwise.

    You are returned this error because the softdevice does not know the state of the System Attributes. It will communicate this to you by returning this error, but also by sending you the BLE event BLE_GATTS_EVT_SYS_ATTR_MISSING. If you have not stored the system attributes from a previous connection (normal when bonding), you can handle this event by adding this to on_ble_evt:

    case BLE_GATTS_EVT_SYS_ATTR_MISSING:
            // No system attributes have been stored.
            err_code = sd_ble_gatts_sys_attr_set(m_conn_handle, NULL, 0, 0);
            APP_ERROR_CHECK(err_code);
            break;
    

    See the documentation for sd_ble_gatts_sys_attr_set here.

    I see that in the ble_app_template project, this is already implemented.

    The solution for you will be to check if notifications are enabled on the characteristic, before attempting to send data on it.

    err_code = ble_hts_is_indication_enabled(&m_hts, &is_indication_enabled);
    APP_ERROR_CHECK(err_code);
    if (is_indication_enabled)
    {
        temperature_measurement_send();
    }
    

    UPDATE 1: I tried this myself using the hts example from the SDK. When i click the up/down arrow, it works for a while. Then i see that it says Value: Indications enabled under "Descriptors". When i press button_0, i receive a temperature. Are you sure that temperature_measurement_sendis called in your application?

    image description

  • Hi, thanks for your reply. So, for my tests I'm using HTS-capable Apps (e.g. nRF Toolbox, BLE Scanner and others) which enable indications on relevant characteristics. Still doesn't work...

Related