I have managed to cobble together a program that demonstrates being a master, and a peripheral at the same time. Jeez this was a mammoth struggle! I’m now beginning to hate BLE.
I took two off-the-shelf demo programs and connected to both of them. Each app simulates the sensor it claims to be. Connecting the relay to two at once was not a requirement, but it clarified some other issues.
Then I made the relay offer the data it receives to a third party – the MCP in this case.
The black typescript is output from the Relay app, and it shows the RSC and HRS peripherals connecting, and reporting each update to the Relay
The white typescript is a snapshot of the MCP showing the HRS and RSC updates it is receiving from the Relay (shaded green).
The code clearly works, but it’s touchy to get it all going.
So the next step is to modify the relay app to talk to another relay app, one serving as a peripheral and the other as a master, and to make sure that either can initiate the connection.