Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
[TW#12193] GATT_Server and GATT_Client not running together at the same time. #404
I am trying to set-up and ESP32 with both a GATT Server and a GATT Clent running at the same time.
I have based this directly off the
I have tried doing this:
And gatt_server_main performs the following: (this replaces the app_main in the gatt_server example)
However whenever this program runs, the GATT_Client will startup and run correctly, but the GATT_Server does not seem start correctly, and does not advertise.
Similarly, when I reverse the initialization order, eg call `gatt_server_main' then 'gatt_client_main' the reverse happens. The gatt server will start correctly and advertise, while the gatt client doesnt seem to initialize properly and will not start scanning.
Is this the expected outcome of this setup?
Is there anything that i am missing or not doing correctly here?
Thanks in advance!
Do you mean the error is "can't advertising when scanning or can't scanning when advertising"?
If yes, then ESP32 do not support advertising and scanning at the same time. While not reporting error code when you start scan/adv when it's advertising/scanning is a bug.
If no, please let me know the error you meet.
When i call
I would be very good if the esp32 could support this feature in the future as i am very interested in this just like @HardwireIO
Hi, the GATT-SERVER and GATT-CLIENT could coexist simultaneously. But if the device is in advertising, it should stop advertising before it connect to other device. Controller do the limit(such as advertise and scan cannot send simultaneously). You can use them time-division. We will do more work about that.
I have only just started getting back into Client + Server running at the same time this week.
As @TianHao-Espressif stated above the client and servers seem to be ablr run simultaneously. The only limitation is that you can't advertise and scan for devices at the same time (IMO a reasonable limitation).
I have done a simple app based off the GATT_Client and GATT_Server examples int he esp-idf. essentially i start the client application, scan for devices. Then if a match the a pre-defined device is found, then I stop scanning. Initate a connection and then start the server application, which triggers the esp32 to start advertising. I can then connect to the esp32 using my phone and the esp32 doesn't seem to disconnect from the peripheral connected to the gatt_client app.
This all seems to work. however not much testing has gone into this to see how stable this is.
I am going to be doing some more testing over the next few days, likely just performing data passthrough between two peripheral esp32's connected to an esp32 that is acting as both a central and peripherl. Where the data from the two connected devices will be funneled though an esp32 acting as a hub, which will then forward the data to a phone.
Hi @lucashutchinson , have you made some progress in your work ? Connection between a central module and a peripheral module works fine, but I can't connect other peripherals. It seems that the central module can't launch a new scan after connecting with the smartphone. Did you find a solution ?
My use case is detecting the proximity of devices based on their GPS position. Each device should connectionlessly advertise its GPS over bluetooth, so I'm not interested in GATT, only GAP. I have this working with advertising and scanning in separate devices, but I need each device to simultaneously advertise and scan. I didn't see any code samples at #741. IIUC, I need to suspend scanning to send an advertisement. Could you advise what sequence of functions to call to do this?
Actually, just to check I'm not on the wrong track, my issue is setting up the callback with (I beleieve) all the advertising code commented out, I get...
I use just the general esp_ble_gap functions to start and stop scanning.
The general steps:
I do not believe you would need to set the scan params, or advertising param each time you start scanning or advertising. I believe you would only set these if you wish to update them.
Other than that I call the above functions to stop advertising then start scanning and vise versa.
Hopefully this helps~