sforkowany z mirror/meshtastic-firmware
NRF52 BLE API now works!
rodzic
28aa48c8d2
commit
2a6df797ca
|
@ -127,15 +127,20 @@ static void authorizeRead(uint16_t conn_hdl)
|
||||||
*/
|
*/
|
||||||
void fromRadioAuthorizeCb(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_evt_read_t *request)
|
void fromRadioAuthorizeCb(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_evt_read_t *request)
|
||||||
{
|
{
|
||||||
|
if (request->offset == 0) {
|
||||||
|
// If the read is long, we will get multiple authorize invocations - we only populate data on the first
|
||||||
|
|
||||||
size_t numBytes = bluetoothPhoneAPI->getFromRadio(fromRadioBytes);
|
size_t numBytes = bluetoothPhoneAPI->getFromRadio(fromRadioBytes);
|
||||||
|
|
||||||
DEBUG_MSG("fromRadioAuthorizeCb numBytes=%u\n", numBytes);
|
// DEBUG_MSG("fromRadioAuthorizeCb numBytes=%u\n", numBytes);
|
||||||
if (numBytes >= 2)
|
// if (numBytes >= 2) DEBUG_MSG("fromRadio bytes %x %x\n", fromRadioBytes[0], fromRadioBytes[1]);
|
||||||
DEBUG_MSG("fromRadio bytes %x %x\n", fromRadioBytes[0], fromRadioBytes[1]);
|
|
||||||
|
|
||||||
// Someone is going to read our value as soon as this callback returns. So fill it with the next message in the queue
|
// Someone is going to read our value as soon as this callback returns. So fill it with the next message in the queue
|
||||||
// or make empty if the queue is empty
|
// or make empty if the queue is empty
|
||||||
fromRadio.write(fromRadioBytes, numBytes);
|
fromRadio.write(fromRadioBytes, numBytes);
|
||||||
|
} else {
|
||||||
|
// DEBUG_MSG("Ignoring successor read\n");
|
||||||
|
}
|
||||||
authorizeRead(conn_hdl);
|
authorizeRead(conn_hdl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,8 +193,7 @@ void setupMeshService(void)
|
||||||
fromRadio.setReadAuthorizeCallback(
|
fromRadio.setReadAuthorizeCallback(
|
||||||
fromRadioAuthorizeCb,
|
fromRadioAuthorizeCb,
|
||||||
false); // We don't call this callback via the adafruit queue, because we can safely run in the BLE context
|
false); // We don't call this callback via the adafruit queue, because we can safely run in the BLE context
|
||||||
// FIXME - add this back in
|
fromRadio.setBuffer(fromRadioBytes, sizeof(fromRadioBytes)); // we preallocate our fromradio buffer so we won't waste space
|
||||||
// fromRadio.setBuffer(fromRadioBytes, sizeof(fromRadioBytes)); // we preallocate our fromradio buffer so we won't waste space
|
|
||||||
// for two copies
|
// for two copies
|
||||||
fromRadio.begin();
|
fromRadio.begin();
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue