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

Can't discover custom service

Hi!

I'm working with nRF51DK with s110 soft device on it. I'm trying to write simple custom service which reads some data from sensors and send it over BLE to Android app. I wrote my service on the base of ble_app_template_s110_pca10028 and ble_lbs examples. I thought that I included all functions which are required to custom service working correctly, but when I run Master Control Panel on my smartphone, I can see that my application is advertising, but when i try to connect, according to logs, it hangs on discovering services for a few seconds and then it disconnects. Logs from Master Control Panel:

13:01:03.413 Connecting to EE:12:48:CC:D9:98...
13:01:03.418 gatt = device.connectGatt(autoConnect = false)
13:01:03.458 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
13:01:03.467 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
13:01:03.472 Connected to EE:12:48:CC:D9:98
13:01:03.478 wait(600ms)
13:01:04.099 Discovering Services...
13:01:04.107 gatt.discoverServices()
13:01:16.338 [Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
13:01:16.350 [Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED
13:01:16.356 Disconnected
13:01:16.378 gatt.refresh() 

It is my first time when i write application which uses bluetooth, so it is possible that i am making some major mistake, for example not implementing some basic function. So I would be greatful if someone could tell me what functions are required minimum to correctly discover custom service (for now i don't need this application to be optimalized, i just need it to work.)

I am using s110_nRF51_8.0.0 Soft Device and SDK_9.0.0. I attach my project:ekg_proj.rar

Thank You in advance, Ina

Parents
  • I don't think there is anything wrong with your service setup, but I see the same behaviour as you testing your code.

    This is because nrf_drv_twi_tx() returns an error and APP_ERROR_CHECK() resets the chip.

    If I comment out the below section it works perfectly.

    //err_code = nrf_drv_twi_tx(&twi, ACCADDRESS, &tx_data, sizeof(tx_data), true);
    //APP_ERROR_CHECK(err_code);
    
    //err_code = nrf_drv_twi_rx(&twi, ACCADDRESS, rx_data, sizeof(rx_data), false);
    //APP_ERROR_CHECK(err_code);
    

    I guess you have your twi connected to something, while I don't. Anyways, you could use the debugger and see if the functions above return any errors. Remember to turn off optimizations. Maybe you could handle the error instead of calling APP_ERROR_CHECK(), depends on what the error is of course.

  • Thank You very much! Now I know that my services are implemented correctly, i was afraid they are not.

    Regards, Ina

Reply Children
No Data
Related