Skip to content
Snippets Groups Projects
Commit 1bcf5229 authored by schneider's avatar schneider
Browse files

hack(ble): Receive covid tracing beacons

parent e4c89923
Branches
Tags v1.3
No related merge requests found
Pipeline #4616 passed
...@@ -188,6 +188,15 @@ static const uint8_t bleAdvDataConn[] = ...@@ -188,6 +188,15 @@ static const uint8_t bleAdvDataConn[] =
DM_FLAG_LE_BREDR_NOT_SUP, DM_FLAG_LE_BREDR_NOT_SUP,
}; };
static const appMasterCfg_t scannerMasterCfg =
{
420, /*! The scan interval, in 0.625 ms units */
420, /*! The scan window, in 0.625 ms units */
0, /*! The scan duration in ms */
DM_DISC_MODE_NONE, /*! The GAP discovery mode */
DM_SCAN_TYPE_PASSIVE
/*!< The scan type (active or passive) */
};
/************************************************************************************************** /**************************************************************************************************
Client Characteristic Configuration Descriptors Client Characteristic Configuration Descriptors
...@@ -470,9 +479,13 @@ static void bleSetup(bleMsg_t *pMsg) ...@@ -470,9 +479,13 @@ static void bleSetup(bleMsg_t *pMsg)
AppAdvSetData(APP_ADV_DATA_CONNECTABLE, sizeof(bleAdvDataConn), (uint8_t *) bleAdvDataConn); AppAdvSetData(APP_ADV_DATA_CONNECTABLE, sizeof(bleAdvDataConn), (uint8_t *) bleAdvDataConn);
AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL); AppAdvSetData(APP_SCAN_DATA_CONNECTABLE, 0, NULL);
active = true; //active = true;
/* TODO: Sadly, not advertising leads to a higher current consumption... */ /* TODO: Sadly, not advertising leads to a higher current consumption... */
epic_ble_set_bondable(false); epic_ble_set_bondable(false);
//AppScanStart(scannerMasterCfg.discMode, scannerMasterCfg.scanType, scannerMasterCfg.scanDuration);
DmScanSetInterval(HCI_SCAN_PHY_LE_1M_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow);
DmScanStart(HCI_SCAN_PHY_LE_1M_BIT, scannerMasterCfg.discMode, &scannerMasterCfg.scanType, FALSE, scannerMasterCfg.scanDuration, 0);
} }
void epic_ble_set_bondable(bool bondable) void epic_ble_set_bondable(bool bondable)
...@@ -576,6 +589,46 @@ static void bleHandleNumericComparison(dmSecCnfIndEvt_t *pCnfInd) ...@@ -576,6 +589,46 @@ static void bleHandleNumericComparison(dmSecCnfIndEvt_t *pCnfInd)
trigger_event(1); trigger_event(1);
} }
static void hexdump(uint8_t *data, int len)
{
while(len--) printf("%02x ", *data++);
}
static void scannerScanReport(dmEvt_t *pMsg)
{
uint8_t *pData;
static bool c;
pData = DmFindAdType(0x16,
pMsg->scanReport.len, pMsg->scanReport.pData);
if(pData) {
uint8_t len= pData[0];
uint8_t uuid_1 = pData[2];
uint8_t uuid_2 = pData[3];
if(uuid_1 == 0x6f && uuid_2 == 0xfd) {
printf("COVID : %02x:%02x:%02x:%02x:%02x:%02x",
pMsg->scanReport.addr[5],
pMsg->scanReport.addr[4],
pMsg->scanReport.addr[3],
pMsg->scanReport.addr[2],
pMsg->scanReport.addr[1],
pMsg->scanReport.addr[0]);
printf(" rssi %d, data ", pMsg->scanReport.rssi);
hexdump(&pData[4], len - 4);
printf("\n");
epic_vibra_vibrate(30);
if(c) {
epic_leds_set(14, 255, 0, 0);
c = false;
} else {
epic_leds_set(14, 0, 255, 0);
c = true;
}
}
}
}
/*************************************************************************************************/ /*************************************************************************************************/
/*! /*!
* \brief Process messages from the event handler. * \brief Process messages from the event handler.
...@@ -720,6 +773,10 @@ static void bleProcMsg(bleMsg_t *pMsg) ...@@ -720,6 +773,10 @@ static void bleProcMsg(bleMsg_t *pMsg)
bleHandleNumericComparison(&pMsg->dm.cnfInd); bleHandleNumericComparison(&pMsg->dm.cnfInd);
break; break;
case DM_SCAN_REPORT_IND:
scannerScanReport((dmEvt_t *)pMsg);
break;
case DM_HW_ERROR_IND: case DM_HW_ERROR_IND:
LOG_ERR("ble", "HW Error"); LOG_ERR("ble", "HW Error");
break; break;
...@@ -750,6 +807,7 @@ static void BleHandlerInit(void) ...@@ -750,6 +807,7 @@ static void BleHandlerInit(void)
pAppSlaveCfg = (appSlaveCfg_t *) &bleSlaveCfg; pAppSlaveCfg = (appSlaveCfg_t *) &bleSlaveCfg;
pAppSecCfg = (appSecCfg_t *) &bleSecCfg; pAppSecCfg = (appSecCfg_t *) &bleSecCfg;
pAppUpdateCfg = (appUpdateCfg_t *) &bleUpdateCfg; pAppUpdateCfg = (appUpdateCfg_t *) &bleUpdateCfg;
pAppMasterCfg = (appMasterCfg_t *) &scannerMasterCfg;
/* Initialize application framework */ /* Initialize application framework */
AppSlaveInit(); AppSlaveInit();
...@@ -780,7 +838,7 @@ static void BleHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg) ...@@ -780,7 +838,7 @@ static void BleHandler(wsfEventMask_t event, wsfMsgHdr_t *pMsg)
if (pMsg->event >= DM_CBACK_START && pMsg->event <= DM_CBACK_END) if (pMsg->event >= DM_CBACK_START && pMsg->event <= DM_CBACK_END)
{ {
LOG_INFO("ble", "Ble got evt %d: %s", pMsg->event, dm_events[pMsg->event - DM_CBACK_START]); if(pMsg->event != DM_SCAN_REPORT_IND) LOG_INFO("ble", "Ble got evt %d: %s", pMsg->event, dm_events[pMsg->event - DM_CBACK_START]);
/* process advertising and connection-related messages */ /* process advertising and connection-related messages */
AppSlaveProcDmMsg((dmEvt_t *) pMsg); AppSlaveProcDmMsg((dmEvt_t *) pMsg);
......
...@@ -130,11 +130,7 @@ void StackInit(void) ...@@ -130,11 +130,7 @@ void StackInit(void)
.freeMemAvail = LL_MEMORY_FOOTPRINT .freeMemAvail = LL_MEMORY_FOOTPRINT
}; };
#ifdef DATS_APP_USE_LEGACY_API
memUsed = LlInitControllerExtInit(&ll_init_cfg); memUsed = LlInitControllerExtInit(&ll_init_cfg);
#else /* DATS_APP_USE_LEGACY_API */
memUsed = LlInitControllerExtInit(&ll_init_cfg);
#endif /* DATS_APP_USE_LEGACY_API */
if(memUsed != LL_MEMORY_FOOTPRINT) if(memUsed != LL_MEMORY_FOOTPRINT)
{ {
printf("Controller memory mismatch 0x%x != 0x%x\n", (unsigned int)memUsed, printf("Controller memory mismatch 0x%x != 0x%x\n", (unsigned int)memUsed,
...@@ -142,6 +138,11 @@ void StackInit(void) ...@@ -142,6 +138,11 @@ void StackInit(void)
} }
#endif #endif
SecInit();
SecRandInit();
SecAesInit();
SecCmacInit();
SecEccInit();
/* card10: /* card10:
* These calls register a queue for callbacks in the OS abstraction * These calls register a queue for callbacks in the OS abstraction
...@@ -153,14 +154,10 @@ void StackInit(void) ...@@ -153,14 +154,10 @@ void StackInit(void)
handlerId = WsfOsSetNextHandler(HciHandler); handlerId = WsfOsSetNextHandler(HciHandler);
HciHandlerInit(handlerId); HciHandlerInit(handlerId);
SecInit();
SecAesInit();
SecCmacInit();
SecEccInit();
handlerId = WsfOsSetNextHandler(DmHandler); handlerId = WsfOsSetNextHandler(DmHandler);
DmDevVsInit(0); DmDevVsInit(0);
DmAdvInit(); DmAdvInit();
DmScanInit();
DmConnInit(); DmConnInit();
DmConnSlaveInit(); DmConnSlaveInit();
DmSecInit(); DmSecInit();
......
...@@ -421,6 +421,7 @@ ble_compileargs = [ ...@@ -421,6 +421,7 @@ ble_compileargs = [
'-DINIT_BROADCASTER', '-DINIT_BROADCASTER',
'-DINIT_PERIPHERAL', '-DINIT_PERIPHERAL',
'-DINIT_ENCRYPTED', '-DINIT_ENCRYPTED',
'-DINIT_OBSERVER',
] ]
if get_option('ble_trace') if get_option('ble_trace')
......
...@@ -73,7 +73,7 @@ void AppScanStart(uint8_t mode, uint8_t scanType, uint16_t duration) ...@@ -73,7 +73,7 @@ void AppScanStart(uint8_t mode, uint8_t scanType, uint16_t duration)
{ {
DmScanSetInterval(HCI_SCAN_PHY_LE_1M_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow); DmScanSetInterval(HCI_SCAN_PHY_LE_1M_BIT, &pAppMasterCfg->scanInterval, &pAppMasterCfg->scanWindow);
DmScanStart(HCI_SCAN_PHY_LE_1M_BIT, mode, &scanType, TRUE, duration, 0); DmScanStart(HCI_SCAN_PHY_LE_1M_BIT, mode, &scanType, FALSE, duration, 0);
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment