Central device can not find 2 services(0x1001,0x0001)

asked 2017-09-11 10:51:12 +0100

Peripheral device has 2 services,but central can find only 1 service(0x1001). I want to find other service(0x0001) According to the message seems to be looking for 0x1001,but ! want to looking for every services.

I don not know why this program look for only 0x1001.

Incidentally Central program is based ble_app_uart_c.

Please tell me how to find every services.

I Hope to have a central sample program that handles multiple services

Message is Starting discovery of service with UUID 0x1001 on connection handle 0x0. Found service UUID 0x1001. Discovery of service with UUID 0x1001 completed with success on connection handle 0x0

edit retag flag offensive close delete report spam

Comments


uart_uuid.type = p_ble_nus_c -> uuid_type;
uart_uuid.uuid = 0x0001;
err_code = ble_db_discovery_evt_register (& uart_uuid);

Was added to the function ble_nus_c_init

A service of 0x0001 was also found

However, the message

"BLE_DB_DISC: DEBUG: Discovery of service wit [00000001] SDH: DEBUG: RAM start at 0x200020c8.

Reset is applied after.

Do not know why resetting will take place?

yamazaki seiji ( 2017-09-12 07:05:26 +0100 )editconvert to answer

Have you tested your peripheral with for example nRF Connect? Are you able to find both services there?

If you get a reset you probably have a call to APP_ERROR_CHECK() with an error code somewhere.

I'm not sure what SDK you are using, but you should turn off compiling optimizations, define DEBUG, and put a breakpoint in the app_error_handler(). Then you can see an error code, a line number and a file name.

See this for more information.

Petter Myhre ( 2017-09-12 10:58:03 +0100 )editconvert to answer

I found both services by LightBlue application of android. I will try to do your advise later. Thank you for your help.

yamazaki seiji ( 2017-09-12 11:12:35 +0100 )editconvert to answer

I knew the reason of reset. p_ble_nus_evt->handles is NULL in function ble_nus_c_evt_handler But I do not know why p_ble_nus_evt->handles is NULL.

yamazaki seiji ( 2017-09-13 11:18:54 +0100 )editconvert to answer

Exactly which function returns the error? ble_nus_c_handles_assign()?

Petter Myhre ( 2017-09-13 12:16:44 +0100 )editconvert to answer

Thank you for your reply. What I added is as follows.

■added

uart_uuid.type = p_ble_nus_c->uuid_type; uart_uuid.uuid = 0x0001;

err_code = ble_db_discovery_evt_register(&uart_uuid);

in function ble_nus_c_init

■added

else if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE &&
    p_evt->params.discovered_db.srv_uuid.uuid == 0x0001 &&
    p_evt->params.discovered_db.srv_uuid.type == p_ble_nus_c->uuid_type)
{
    .....

in function ble_nus_c_on_db_disc_evt

■added

uint16_t nus_rx_handle2;      /**< Handle of the NUS RX characteristic as provided by a discovery. */

to struct ble_nus_c_handles_t

I think there are other things I have to do, I do not know what it is.

Is there a sample source code for multiservice?

yamazaki seiji ( 2017-09-14 03:05:50 +0100 )editconvert to answer

I see. I'm not sure why it is NULL. It is a bit difficult to say without knowing what kind of modifications you have made to your code.

Petter Myhre ( 2017-09-14 14:19:36 +0100 )editconvert to answer

Would it be possible for you to share your complete project so I can test it here?

Petter Myhre ( 2017-09-15 10:00:33 +0100 )editconvert to answer

Yes, how can I send a file?

yamazaki seiji ( 2017-09-15 10:04:44 +0100 )editconvert to answer

Edit your question and use the paper clip icon. Please upload complete project. Also let me know which SDK and SoftDevice you are using.

Petter Myhre ( 2017-09-15 10:52:52 +0100 )editconvert to answer

Thank you for your help. SoftDevice is s132_nrf52_4.0.2_softdevice.hex. Please set ble_nus_c/ble_nus_c_toppan.[ch] to components\ble\ble_services . prg.zip

yamazaki seiji ( 2017-09-15 11:31:28 +0100 )editconvert to answer

Which SDK are you using?

Petter Myhre ( 2017-09-15 12:14:28 +0100 )editconvert to answer

I am using SDK is nRF5_SDK_13.0.0_04a0bfd.

I'm sorry, Correct the 186th line of the source code ble_nus_c_toppan.c as follows Please check.

#if 0
To
#if 1
yamazaki seiji ( 2017-09-19 03:09:26 +0100 )editconvert to answer

Thanks. Could you upload the complete project for the peripheral as well? So I can test them together?

Petter Myhre ( 2017-09-19 14:32:29 +0100 )editconvert to answer

I appreciate your help.

I will upload so please be kind.

yamazaki seiji ( 2017-09-20 03:13:23 +0100 )editconvert to answer

uload failed? I tryed again.But still fail. prg_peripheral.zip

yamazaki seiji ( 2017-09-25 03:08:37 +0100 )editconvert to answer

Seems to me you have to modify ble_nus_c_handles_assign() and ble_nus_c_tx_notif_enable(). BLE_NUS_C_EVT_DISCOVERY_COMPLETE will be received twice. Once with valid handles for

nus_tx_cccd_handle
nus_tx_handle
nus_rx_handle

Second for valid handle for

handles.nus_rx2_handle

So when calling ble_nus_c_handles_assign() the second time with only a valid rx2 handle, the other handles seems to be set to 0, and then you get an error when ble_nus_c_tx_notif_enable() is called the second time.

Petter Myhre ( 2017-09-26 16:20:46 +0100 )editconvert to answer

Thank you for your reply. Unfortunately it has become impossible to test now.

So,I ask you. What I have to change is

To the function ble_nus_c_handles_assign

p_ble_nus-> handles.nus_rx2_handle = p_peer_handles-> nus_rx2_handle;

With function ble_nus_c_tx_notif_enable

|| (p_ble_nus_c -> handles.nus_tx_cccd_handle == BLE_GATT_HANDLE_INVALID)

so

| ((p_ble_nus_c -> handles.nus_tx_cccd_handle == BLE_GATT_HANDLE_INVALID) && (p_ble_nus_c -> handles.nus_tx_cccd_handle == BLE_GATT_HANDLE_INVALID))

Change it

Is it right.

yamazaki seiji ( 2017-09-27 08:43:18 +0100 )editconvert to answer

Impossible to test? Why? I don't understand your change suggestions.

Petter Myhre ( 2017-09-27 08:46:57 +0100 )editconvert to answer

There is no equipment now. I will test as soon as possible. Upload the file to be changed this time.ble_nus_c_toppan.c

yamazaki seiji ( 2017-09-27 08:56:36 +0100 )editconvert to answer

The changes doesn't look correct at all. You will get two BLE_NUS_C_EVT_DISCOVERY_COMPLETE events.

One with valid handles for

nus_tx_cccd_handle
nus_tx_handle
nus_rx_handle

and invalid handle (0x0000) for handles.nus_rx2_handle

With this event you want to set:

    p_ble_nus->handles.nus_tx_cccd_handle = p_peer_handles->nus_tx_cccd_handle;
    p_ble_nus->handles.nus_tx_handle      = p_peer_handles->nus_tx_handle;
    p_ble_nus->handles.nus_rx_handle      = p_peer_handles->nus_rx_handle;

and call ble_nus_c_tx_notif_enable().

Second with valid handles for

handles.nus_rx2_handle

and invalid handles (0x000) for nus_tx_cccd_handle, nus_tx_handle, nus_rx_handle

With this event you want to set

p_ble_nus->handles.nus_rx2_handle      = p_peer_handles->nus_rx2_handle;
Petter Myhre ( 2017-09-27 09:06:46 +0100 )editconvert to answer

You do not want to set:

    p_ble_nus->handles.nus_tx_cccd_handle = p_peer_handles->nus_tx_cccd_handle;
    p_ble_nus->handles.nus_tx_handle      = p_peer_handles->nus_tx_handle;
    p_ble_nus->handles.nus_rx_handle      = p_peer_handles->nus_rx_handle;

and you do not call ble_nus_c_tx_notif_enable().

Petter Myhre ( 2017-09-27 09:06:51 +0100 )editconvert to answer

What you are writing is very difficult for me. What I want to do is to send data from central to peripheral for the two services. I am very thankful that there is a sample program.

yamazaki seiji ( 2017-09-27 09:36:44 +0100 )editconvert to answer

I'll try make some modifications, see if I can get it to work, but it might take a couple of days before I have time.

Petter Myhre ( 2017-09-27 10:01:55 +0100 )editconvert to answer

Thank you very very very much. Currently it is not so urgent. Thank you for your consideration.

yamazaki seiji ( 2017-09-27 10:21:07 +0100 )editconvert to answer