Acomplishments
The past 2 weeks, I worked on and completed the P2P BLE setup between the STM32 and the ESP32 microcontrollers. In our BLE communication architecture, the STM32 is a GATT server, and the ESP32 is a GATT client. At a high level, as a GATT client, the STM32 advertises and exposes its services; the ESP32 scans and connects to the server and writes/reads data. Both devices initialize the BLE stack on their second CPU core, which support a variety of low power modes. This is ideal, given that our filtering/processing tasks are likely going to consume a significant amount of power.
As for our implementation/process, we ended up not using an RTOS on our STM32. The BLE setup code included on STM32CubeIDE uses a sequencer for BLE that conflicts with some of the tasks on FreeRTOS for example. While we found a workaround for it, we thought it would be more productive to simply not use an RTOS, instead of going through the hassle of fixing linker errors and carefully managing task priorities between sequencer and RTOS tasks. Additionally, there are relatively few subroutines that the STM32 has to execute compared to the ESP32. We were, however, able to get BLE working on its own FreeRTOS task on the ESP32. Fortunately, not much new code had to be written for both microcontrollers. Most time was spent properly configuring the IOC config file for the STM32 and editing a few things like UUID and advertising name. For the ESP32, I was able to reuse most of the GATT Client example code from Espressif. I simply had to modify it so that it would scan for the server with the proper device/characteristic UUIDs and the correct remote device name.
For verification, I used multiple debug logs and redirected them to UART for verification of the existence of the successful case logs. I was also able to set a supervision timeout of 2000 ms for the connection and got the correct disconnection status codes when I disconnected the ESP32 from power.
Progress / Schedule
I’m currently on track with my schedule. The next step would be to integrate Caitlyn’s work with the IMU sensor data, and to test the BLE code once Nick is able to verify the PCBs. During the following days, I will be using an oscilloscope to test BLE latency and taking measurements, so we have something to compare against once we start implementing optimizations.
Deliverables / Next Steps
- Take latency measurements for BLE and SPI/I2C.
- Flash code into PCBs once they’re verified.
- Write mock code to simulate sensor activity and communication.
