Help with Writing Code for ESP32-C3 to Make it Discoverable and Connectable via Phone
Posted: Wed Dec 11, 2024 10:22 pm
Hi everyone,
I’m working on a project where I need to make my ESP32-C3 visible to my phone over Bluetooth Low Energy (BLE) and allow me to connect to it. I’ve been exploring the ESP-IDF documentation, but I’m struggling to write the necessary code that will make the ESP32-C3 discoverable and connectable.
Here’s what I’ve been trying to do:
I’ve set up basic BLE advertising using esp_ble_gap_start_advertising(), but I cannot see the ESP32-C3 in the Bluetooth devices list on my phone.
I’ve been using the BLE_ADDR_TYPE_PUBLIC and BLE_ADDR_TYPE_RANDOM address types, but neither seems to work for making the device show up.
I’m also unsure how to handle the connection once the device is visible, such as managing the pairing process or handling connection events.
What I want to achieve:
Make the ESP32-C3 visible to my phone using BLE.
Be able to connect to the ESP32-C3 from my phone.
Handle basic connection events like pairing and establishing a connection.
I’ve tried the following:
Initializing Bluetooth and enabling the controller.
Starting BLE advertising with default parameters.
Registering the GAP callback to handle scanning and advertising events.
Here are some specific questions I have:
1. How can I ensure that the ESP32-C3 shows up in the Bluetooth devices list on my phone?
2. What BLE address type should I use for the ESP32-C3 to make it discoverable?
3. How do I handle the connection process once the device is visible?
4. Is there any specific configuration for making the device connectable and pairing-friendly?
Any help or code examples would be greatly appreciated. Thanks in advance!
I’m working on a project where I need to make my ESP32-C3 visible to my phone over Bluetooth Low Energy (BLE) and allow me to connect to it. I’ve been exploring the ESP-IDF documentation, but I’m struggling to write the necessary code that will make the ESP32-C3 discoverable and connectable.
Here’s what I’ve been trying to do:
I’ve set up basic BLE advertising using esp_ble_gap_start_advertising(), but I cannot see the ESP32-C3 in the Bluetooth devices list on my phone.
I’ve been using the BLE_ADDR_TYPE_PUBLIC and BLE_ADDR_TYPE_RANDOM address types, but neither seems to work for making the device show up.
I’m also unsure how to handle the connection once the device is visible, such as managing the pairing process or handling connection events.
What I want to achieve:
Make the ESP32-C3 visible to my phone using BLE.
Be able to connect to the ESP32-C3 from my phone.
Handle basic connection events like pairing and establishing a connection.
I’ve tried the following:
Initializing Bluetooth and enabling the controller.
Starting BLE advertising with default parameters.
Registering the GAP callback to handle scanning and advertising events.
Here are some specific questions I have:
1. How can I ensure that the ESP32-C3 shows up in the Bluetooth devices list on my phone?
2. What BLE address type should I use for the ESP32-C3 to make it discoverable?
3. How do I handle the connection process once the device is visible?
4. Is there any specific configuration for making the device connectable and pairing-friendly?
Any help or code examples would be greatly appreciated. Thanks in advance!