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
  • Hi,

    handling of the MTU request does not have an effect. Still if I do service discovery, everything works fine. My custom central can control my custom peripheral.

    The sniffer is a bit cumbersome. I have used Wireshark, but I need to start a DOS prompt first and find the device and then hope for Wireshark to start up correctly - seldomly happens. Do you have another and better way of sniffing?

Children
  • Hi,

    It seems you have been using the old sniffer, could you try and see if it works better for you with the nRFSniffer v2? User guide here and download link here.

  • I am getting connect & disconnect events both in my custom service event handler and the main function.

    However in the main ble event handler and the custom service event handler I do NOT get the write event! What could be the reason for not receiving any write events in the ble event handler?

    When I connect the ble event handler is called! 

  • 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