Connecting to a bluetooth lightbulb and writing to character attribute (gattc)
Posted: Sat Apr 21, 2018 4:10 pm
I'm trying to turn on a light that I have significant documentation for. I have been able to do this with a raspberry pi and pygatt libraries using some python code i was able to find. The bulb is documented here: http://www.yeelight.com/download/yeelig ... e_v1.0.pdf
My difficulty comes in understanding the examples of the IDF for bluetooth callbacks. The project I have conceptualized is to attach a pir sensor to the esp32 and turn the yeelights into a hallway light when the sensor detects motion.
I can think this through functionally as follows:
1. Motion on PIR Sensor pin
2. Connect to Hardcoded BT address #1
3. Write 18 character control sequence on handle 18 of 4 character shortened UUID characteristic for primary service
4. Repeat step 2-3 for BT address #2
5. Start countdown until 5 min or some delay without interruption from step 1
6. Run through steps 2-4 but with 18 character sequence to turn off lights
This seems like a simple thing to do, but I have not delved in C++ for some time, and can not find which callback constants would be appropriate to use in this case for a gattc callback or a gap callback. Or how to re-factor these steps w/ a callback based program.
Any ideas would be much appreciated. In the meantime, I'm reading Koban's ESP32 notes and poking around the gattc_demo.c in eclipse.
Thanks
My difficulty comes in understanding the examples of the IDF for bluetooth callbacks. The project I have conceptualized is to attach a pir sensor to the esp32 and turn the yeelights into a hallway light when the sensor detects motion.
I can think this through functionally as follows:
1. Motion on PIR Sensor pin
2. Connect to Hardcoded BT address #1
3. Write 18 character control sequence on handle 18 of 4 character shortened UUID characteristic for primary service
4. Repeat step 2-3 for BT address #2
5. Start countdown until 5 min or some delay without interruption from step 1
6. Run through steps 2-4 but with 18 character sequence to turn off lights
This seems like a simple thing to do, but I have not delved in C++ for some time, and can not find which callback constants would be appropriate to use in this case for a gattc callback or a gap callback. Or how to re-factor these steps w/ a callback based program.
Any ideas would be much appreciated. In the meantime, I'm reading Koban's ESP32 notes and poking around the gattc_demo.c in eclipse.
Thanks