Hello everyone, I’m thrilled to share my journey and insights on integrating BLE Mesh and NUS in Zephyr. This has been quite the adventure, and I hope my experiences can help others navigate the complexities of this integration. The Challenge: I set out to create a program that seamlessly integrates BLE Mesh and NUS, aiming to read sensor data from a server and transmit it via UART. My goal was to use a sensor_client to fetch data and send it to an external device. While referencing official examples like sensor_client, sensor_server, peripheral_uart, and ble_peripheral_lbs_coex, I encountered several hurdles. Initial Struggles: Despite maintaining the structure of the ble_peripheral_lbs_coex code, I faced issues with advertising initialization. Errors like ‘no BUFFER’, ‘no context’, and ‘No more contexts’ were frequent. This was perplexing, as the logic seemed sound. The Solution: After extensive research and experimentation, I realized the issue stemmed from resource allocation. The system was struggling to handle multiple contexts simultaneously. By optimizing the resource management and ensuring sufficient buffers, I managed to resolve these errors. Key Insights: 1. Resource Management: Ensure adequate buffer allocation for both BLE Mesh and NUS operations. 2. Context Handling: Properly manage and release contexts to prevent overflow. 3. Debugging: Utilize logging extensively to identify bottlenecks and resource leaks. Implementation Steps: - Initialization: Set up BLE Mesh and NUS services with proper configuration. - Advertising: Implement extended advertising with careful context management. - Data Handling: Ensure seamless data flow from sensors to UART transmission. Outcome: The integration now works flawlessly, allowing data to be read from the sensor_server and transmitted via UART. This achievement opens doors for various applications, from IoT monitoring to industrial automation. Final Thoughts: While challenging, this project reinforced the importance of meticulous resource management and thorough debugging. I’m excited to see how this integration can be applied in real-world scenarios and look forward to sharing more insights as I explore further. Happy coding! ![]()