ESP32- HID over GATT, and data server simultaneously

497 views
Skip to first unread message

Gal Zaidenstein

unread,
Apr 5, 2018, 1:54:19 AM4/5/18
to btstack-dev
HI,
I'm a complete beginner, and I'm trying to get an ESP32 to connect to a PC as an HID device, while simultaneously receiving data from another ESP32.
So far, I've managed to run each example separately, and modify them to my needs, but I can't seem to figure out how to make both work together.
Is there an example for running to separate BLE services on one device? 

Thank you.

Matthias Ringwald

unread,
Apr 5, 2018, 2:07:09 AM4/5/18
to btsta...@googlegroups.com
Hi Gal

The HOG Keyboard demo already contains 3 services: battery service, device id, and HID. If you want to add another one, you'd first have to add the new service  to the .gatt file. After re-creating the .h file (automatically done by make), you should get new defines for the attributes in the new service. Now, you need to register att_read_ and att_write_callbacks like in the le_couter example. That should be it.

Cheers
  Matthias

--
You received this message because you are subscribed to the Google Groups "btstack-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to btstack-dev...@googlegroups.com.
To post to this group, send email to btsta...@googlegroups.com.
Visit this group at https://groups.google.com/group/btstack-dev.
For more options, visit https://groups.google.com/d/optout.

Gal Zaidenstein

unread,
Apr 5, 2018, 2:56:05 AM4/5/18
to btstack-dev
Thank you for the quick reply, 
What is needed for establishing connection to two different devices (the PC as HID, and the other ESP32 as a data server)?
I'm trying to combine these examples:

Connection to another esp32:

Connection to pc:

I can run them together from the same code, but I cant get them to run simultaneously (meaning that whichever device it manages to connect to first starts communicating with the controller alone).
To my understanding, Bluetooth stops sending Advertisements after its connected, but I need it to connect to 2 different devices before stopping.

I tried combining the examples (1) and example (2) in several ways:
*Combining both packet handlers together to one.
*Defining two different packet handlers one for each connection.
*Using  hci_send_cmd(&hci_le_set_advertise_enable, 1) after the last case in the the HOG_DEMO packet handler, and applying the packet handler from the le server example afterwards.

here's an example to one of my attempts:

Thank you very much
Gal


Matthias Ringwald

unread,
Apr 5, 2018, 8:33:10 AM4/5/18
to btsta...@googlegroups.com
Hi Gal

Being Peripheral in multiple connections is not supported by all controllers although the ESP32 can handle it. You can tell BTstack to enable multiple Peripheral roles by calling gap_set_max_number_peripheral_connections() with the value 2. if it doesn't work, please provide a packet log with hci_dump_open enabled in main().

Best
 Matthias

Gal Zaidenstein

unread,
Apr 5, 2018, 8:40:40 AM4/5/18
to btstack-dev
It works!
Thank you very much for the help! 
Reply all
Reply to author
Forward
0 new messages