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

Avoid service discovery

I am using S130, SDK13 and NRF52832 both on my central and peripheral - custom boards.

I am trying to avoid service discovery on my peripheral. 

I have set the service_changed to 0 when configuring the softdevice.

On my central I do not run service-discovery, but my peripheral does not get a handle to the service even though I run this code when I connect:

void ble_lbs_status_update (ble_alarm_service_t* p_our_service, uint8_t *p_lock_state, uint16_t len) {

    uint32_t err_code = NRF_SUCCESS;

    ble_gatts_value_t gatts_value;

    // Initialize value struct.

    memset(&gatts_value, 0, sizeof(gatts_value));

    gatts_value.len     = sizeof(uint8_t)*len;

    gatts_value.offset  = 0;

    gatts_value.p_value = p_lock_state;

    // new

    // Update database.

    err_code = sd_ble_gatts_value_set (p_our_service->conn_handle, p_our_service->status_char_handles.value_handle, &gatts_value);

    if (err_code != NRF_SUCCESS)

    {

       return err_code;

    }

    //new

if (p_our_service->conn_handle != BLE_CONN_HANDLE_INVALID)

{

uint16_t               len = 5;

ble_gatts_hvx_params_t hvx_params;

memset(&hvx_params, 0, sizeof(hvx_params));

hvx_params.handle = p_our_service->status_char_handles.value_handle;

        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;

        hvx_params.offset = gatts_value.offset;

        hvx_params.p_len  = &gatts_value.len;

        hvx_params.p_data = gatts_value.p_value;

sd_ble_gatts_hvx(p_our_service->conn_handle, &hvx_params);

}

}

Do you have a check-list of how to avoid service discovery on a peripheral?

Regards
Jens

Parents Reply Children
  • I have installed the sniffer program on the PCA10040 board. LED is toggling. So it should be picking up BLE packets.

    But Wireshark is not showing nRF sniffer interface. 

    What could be wrong?

  • Hi Jens,

    So if I understood correctly you are expecting a write event which is not being sent? I agree with Runar and think you should check if you are actually sending the write and also if you are writing to the right characteristic.

    I am also not completely sure of what you are trying to implement. If you want to avoid service discovery, then the central (GATT client) needs to catch the peripheral's gatt server attribute table, this means you should do service discovery one time (first time) and then store the peripheral's gatt server attribute table (and handles) in you central. It does not make sense to me to hardcode the attribute handlers in the gatt server.... could you just explain a bit more about what you are trying to achieve and how?

    Did you read the user guide for the nRF sniffer? You need to install the nRF sniffer extension in Wireshark.

    Best regards,
    Marjeris

Related