Hey,
I have 2 tracker edge devices (with deviceOS 4.0.0) that run the following code.
#include "BLE.h"
#include "thread_info.h"
#include "yoda/time.h"
#include "yoda/status.h"
#include "yoda/BLE_logging.h"
BleLogging<BLE_LOGGING_STACK_SIZE> bleLogHandler(LOG_LEVEL_INFO);
static Logger Loglib("yoda.ble");
os_queue_t BLE_action_q;
void cb_BLE_connected (const BlePeerDevice& peer, void* context)
{
Loglib.info("BLE device connected");
return;
}
void onPairingEvent(const BlePairingEvent& event, void* context) {
Log.info("OnPairing event type %d received", (int) event.type);
if (event.type == BlePairingEventType::REQUEST_RECEIVED) {
Log.info("onPairingEvent REQUEST_RECEIVED");
}
else
if (event.type == BlePairingEventType::PASSKEY_DISPLAY) {
char passKeyStr[BLE_PAIRING_PASSKEY_LEN + 1];
memcpy(passKeyStr, event.payload.passkey, BLE_PAIRING_PASSKEY_LEN);
passKeyStr[BLE_PAIRING_PASSKEY_LEN] = 0;
Log.info("onPairingEvent PASSKEY_DISPLAY %s", passKeyStr);
}
else
if (event.type == BlePairingEventType::STATUS_UPDATED) {
Log.info("onPairingEvent STATUS_UPDATED status=%d lesc=%d bonded=%d",
event.payload.status.status,
(int)event.payload.status.lesc,
(int)event.payload.status.bonded);
}
else
if (event.type == BlePairingEventType::NUMERIC_COMPARISON) {
Log.info("onPairingEvent NUMERIC_COMPARISON");
}
}
void parse_device_id(uint8_t* buf) {
for (uint8_t byte_index = 0; byte_index < 12; byte_index++) {
uint8_t byte = strtoul(System.deviceID().substring(byte_index * 2, byte_index * 2 + 2), NULL, 16);
buf[byte_index] = byte;
}
}
int yoda::ble::setup()
{
//first 2 bytes in manufacturer data are reserved for the company identifier, 0xffff => no Company Id
uint8_t manufacturer_data[14]={0xff,0xff};
parse_device_id(&manufacturer_data[2]);
BLE.setDeviceName("Yoda BLE");
BLE.on();
BleAdvertisingData advertising_data;
advertising_data.appendLocalName("Yoda");
advertising_data.appendCustomData(manufacturer_data,sizeof(manufacturer_data));
BLE.setPairingIoCaps(BlePairingIoCaps::NONE);
BLE.setPairingAlgorithm(BlePairingAlgorithm::LESC_ONLY);
BLE.onPairingEvent(onPairingEvent);
BLE.advertise(&advertising_data);
os_queue_create(&BLE_action_q, sizeof(user_action_t), 2, 0);
return 0;
}
On one device the bluetooth works perfectly fine, but on the other I'm unable to connect over bluetooth and I see the following errors in the logs ( -170 = SYSTEM_ERROR_NOT_FOUND):
0000017452 [system.ctrl.ble] ERROR: Channel error: -170
0000018042 [yoda.ble] INFO: BLE device connected
0000018117 [system.ctrl.ble] ERROR: Channel error: -170
0000018769 [yoda.ble] INFO: BLE device connected
0000018847 [system.ctrl.ble] ERROR: Channel error: -170
0000019539 [yoda.ble] INFO: BLE device connected
0000019613 [system.ctrl.ble] ERROR: Channel error: -170
and in the nRF Connect app I see following logs:
What is strange is that the bluetooth used to work fine on both devices and rolling back to previous version of my code from before the occurrence of the error now also generate this error.