-
Notifications
You must be signed in to change notification settings - Fork 715
Service not discovered in BLE_Client example #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi, |
From the original distribution (with git clone) |
Original distribution is https://github.com/nkolban/esp32-snippets |
So there are differences between espressif/arduino-esp32 and https://github.com/nkolban/esp32-snippets? Which one do you suggest? |
At the moment, until we dont get support c++ exceptions in arduino-esp32 i suggest to not change to esp32-snippets, and when we have c++ exceptions working in arduino-ide most likely library delivered with arduino-esp32, which you call original distribution, will be updated. Back to your issue, i will investigate it and back to you soon. In mean time, can you turn on verbose logging in arduino-ide and provide more logs? |
I switched it on and compiled the client file. Where should I post the log? |
pastebin or here |
It is here: |
Ok, ive found the problem. Those two examples are not prepared to work with each other without some changes. As you can see in this line https://github.com/nkolban/ESP32_BLE_Arduino/blob/f8fe9d7cdfb20caa54b70849826d1ac6e375ff78/examples/BLE_client/BLE_client.ino#L78 |
You can also change this line https://github.com/nkolban/ESP32_BLE_Arduino/blob/f8fe9d7cdfb20caa54b70849826d1ac6e375ff78/examples/BLE_client/BLE_client.ino#L78 and search device you want to connect to not by advertised UUID but ie by name, or served service etc |
Now it works. Very good! Thank you very much for your help. Now I can go on with my Polar H7 emulation... And with my new video where I need BLE UART functionality. So it is well possible that I have to come back because for the moment I can only transfer a few characters to my Smartphone... |
You can use both, BLEUUID(SERVICE_UUID) and (SERVICE_UUID) because this method is overloaded and can be used with BLEUUID or with string uuid. EDIT you can use both only in case if SERVICE_UUID is 128 bit uuid in string variable. In case you want to use 16 or 32 bit uuid only BLEUUID(SERVICE_UUID) works |
I try now to read the values sent by notify. In BLE_client I am able to see the values once during connect of the characteristics: But not during notifyCallback: static void notifyCallback( Serial.println("The characteristic value was: "); The whole code is here (strongly based on the notify example) And the notifier: https://pastebin.com/0ngKNkef (based on the Cadence and speed service) |
In my case with original BLE_notify and BLE_client i can receive notifications, but i will investigate custom code. |
I see the problem. Here you have created chracteristic with notify: This leads us to conclusion there is missing something. Every characteristic with notify and/or indicate needs to have descriptor 2902. There is special library which help to create and add this descriptor BLE2902. |
Thank you for your help. Sorry for coming back late. I was away. Now my H7 fake works and delivers values to nRF connect. I can switch notifications on and off using BLE2902. Great. I again watched Neils videos and understood them now much more. The next problem I have is on the client side and unfortunately, Neil did not explain in his client video is how to display the notified values in the client. I get them once the client connects to the server and, if I put a pRemoteCharacteristic->readValue(); in the loop() I get also the updates. But not in a callback, which would be much nicer to avoid getting the same value twice... |
No rush, we dont have timeline when you have to comeback and response. Thats strange, you should have get notifications and read value in notificationCallback. See this code: If you asking about turning on/off notifications, you need to read remoteDescriptor BLE2902 descriptor from pRemoteCharacteristic and then writeValue(bool):
|
Interesting things happen:
|
Nothing wrong happened, im glad it works. |
Sorry it takes so long, but honestly documentation on bluetooth.org sucks. This is the right solution to turn on notifications:
Explanation:
If something else requires explanation dont hesitate to ask. |
I tried now your code and get the following response in the Server: I put the statement in the loop after (connectToServer(*pServerAddress). If I put it at the end of init the esp crashes. Is there a particular place where it has to go? |
For comparision i will post my code. This is client code, which will switch on/off notifications:
Server code is BLE_notify |
Great! Now it works here too. I still get these messages from the server. E (311726) BT: GATTS_SendRsp conn_id: 3 waiting for op_code = 00 But who cares if it works ;-) |
Yes, im getting those messages too. But they are from esp-idf stack and sometimes even if they are suggesting its error (E) it is for information purpose only. PS thanks to you i learned some stuff too, especially about descriptors and switching remote notifications. |
Thanks. They do not appear if I switch notification off from nRF. So it seems to be a difference between the ESP sketch and the nRF. Minor thing... |
@chegewara I have the same problem in the BLE_uart.ino demo. But the serviceUUID seems not advertised as it should be (see screenshot): I am using version 0.4.13 of the library: When I connect manually, the UART service becomes available, but I can't scan on devices advertising this serviceUUID. Is there anything I can do? |
There is 2 options:
|
Thx. the first trick did the job! for the moment the advertising part are these lines:
|
Yes, but you have regular advertising packet and scan advertising packet, 31 bytes each. |
Can you explain that to me with an example? |
You can set two different set of advertising data: |
I am trying to understand it, but this does not seem te work with a devicename > 5 characters:
|
You need to leave with empty name |
gives an error now: BLE is driving me crazy ;) |
I'm not working with Arduino, but with a mobile framework. When writing data I was also receiving the error Upon writing to a characteristic, there are typically two options. WriteWithoutResponse or WriteWithRepsonse, make sure to WriteWithResponse to avoid any response errors on ESP. |
This worked for me! |
I use the BLE_notify example without changes and try to connect to it using the BLE_Client example. The only changes I did there was to copy the two UUID strings of the notify example to the client example to be sure they match.
NRF connect shows the service but BLE_Client does not show it and also does not connect.
Output: BLE Advertised Device found: Name: MyESP32, Address: 24:0a:c4:12:ef:a2, txPower: -21
I had this issue with many other examples but I am pretty sure it worked last week.
To be sure I also downloaded the newest ESP32 environment from GitHub, with no change
I also have a Xiaomi Flower care device around:
Output: BLE Advertised Device found: Name: Flower care, Address: c4:7c:8d:62:87:f7, serviceUUID: 0000fe95-0000-1000-8000-00805f9b34fb
If I copy this UUID to the client sketch, it connects.
The text was updated successfully, but these errors were encountered: