NRF52 reads now work, but not long reads

1.2-legacy
geeksville 2020-07-17 10:40:03 -07:00
rodzic 582f77e4ec
commit 28aa48c8d2
1 zmienionych plików z 13 dodań i 6 usunięć

Wyświetl plik

@ -130,10 +130,12 @@ void fromRadioAuthorizeCb(uint16_t conn_hdl, BLECharacteristic *chr, ble_gatts_e
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)
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
chr->write(fromRadioBytes, numBytes); fromRadio.write(fromRadioBytes, numBytes);
authorizeRead(conn_hdl); authorizeRead(conn_hdl);
} }
@ -182,10 +184,13 @@ void setupMeshService(void)
fromRadio.setProperties(CHR_PROPS_READ); fromRadio.setProperties(CHR_PROPS_READ);
fromRadio.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); // FIXME secure this! fromRadio.setPermission(SECMODE_OPEN, SECMODE_NO_ACCESS); // FIXME secure this!
fromRadio.setMaxLen(512); fromRadio.setMaxLen(sizeof(fromRadioBytes));
fromRadio.setReadAuthorizeCallback(fromRadioAuthorizeCb); fromRadio.setReadAuthorizeCallback(
fromRadio.setBuffer(fromRadioBytes, fromRadioAuthorizeCb,
sizeof(fromRadioBytes)); // we preallocate our fromradio buffer so we won't waste space for two copies 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
// for two copies
fromRadio.begin(); fromRadio.begin();
toRadio.setProperties(CHR_PROPS_WRITE); toRadio.setProperties(CHR_PROPS_WRITE);
@ -193,7 +198,9 @@ void setupMeshService(void)
toRadio.setFixedLen(0); toRadio.setFixedLen(0);
toRadio.setMaxLen(512); toRadio.setMaxLen(512);
toRadio.setBuffer(toRadioBytes, sizeof(toRadioBytes)); toRadio.setBuffer(toRadioBytes, sizeof(toRadioBytes));
toRadio.setWriteCallback(toRadioWriteCb); toRadio.setWriteCallback(
toRadioWriteCb,
false); // We don't call this callback via the adafruit queue, because we can safely run in the BLE context
toRadio.begin(); toRadio.begin();
} }