Other Parts Discussed in Thread: SYSCONFIG, CC2640, , BOOSTXL-SHARP128
As the title says, Micro BLE/uBLE does not advertise after the uGAP is supposedly running. I have attached part of my code that starts everything, but it does not appear to work. Below is the bulk of my test code.
static void main_task(UArg a0, UArg a1) { volatile uint32 keyHwi; bStatus_t status = FAILURE; uint16_t advInterval = 160; uint16_t advCount = 0; int8 txStrength = 4; int8 advType = UBLE_ADVTYPE_ADV_NC; // uint8_t beaconLength = 30; uint8_t bleAddress[B_ADDR_LEN]; static uint8_t beacon[] = { 0x02, 0x01, 0x06, 0x09, 0x09, 'S', 'u', 's', 's', 'u', 'r', 'o', 0x04, 0xFF, 0xC0, 0xFF, 0xEE // 0x4C, 0x00, // Company identifier code (0x004C == Apple) // 0x02, 0x15, // iBeacon advertisement indicator // 0xe2, 0xc5, 0x6d, 0xb5, 0xdf, 0xfb, 0x48, 0xd2, 0xb0, 0x60, 0xd0, 0xf5, 0xa7, 0x10, 0x96, 0xe0, // ProximityUUID // 0x00, 0x00, // Major // 0x00, 0x00, // Minor // 0xc5 // The 2's complement of the MeasuredPower }; ugapBcastCBs_t pCBs = { beacon_bcast_stateChangeCB, beacon_bcast_advPrepareCB, beacon_bcast_advDoneCB }; // Create an RTOS event used to wake up this application to process events. syncEvent = Event_create(NULL, NULL); // Create an RTOS queue for message from profile to be sent to app. mainAppMsgQueueHandle = Util_constructQueue(&mainAppMsgQueue); // Default is not to switch antenna uble_registerAntSwitchCB(NULL); status = uble_stackInit( UBLE_ADDRTYPE_PUBLIC, // Use the stored public address for testing NULL, // No static address to set myPostEvtProxyCB, // Callback to process the message in this context RF_TIME_CRITICAL // Don't do it; when you want to go do it ); if(status != SUCCESS) { System_printf("uble_stackInit returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } uble_setParameter(UBLE_PARAM_ADVINTERVAL, sizeof(uint16), &advInterval); if(status != SUCCESS) { System_printf("uble_setParameter returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } uble_setParameter(UBLE_PARAM_TXPOWER, sizeof(int8), &txStrength); if(status != SUCCESS) { System_printf("uble_setParameter returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } uble_setParameter(UBLE_PARAM_ADVTYPE, sizeof(int8), &advType); if(status != SUCCESS) { System_printf("uble_setParameter returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } uble_setParameter(UBLE_PARAM_ADVDATA, sizeof(beacon), beacon); if(status != SUCCESS) { System_printf("uble_setParameter returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } uble_getAddr(UBLE_ADDRTYPE_PUBLIC, bleAddress); System_printf("BLE Address %02x:%02x:%02x:%02x:%02x:%02x\n", bleAddress[0], bleAddress[1], bleAddress[2], bleAddress[3], bleAddress[4], bleAddress[5] ); status = ugap_bcastInit(&pCBs); if(status != SUCCESS) { System_printf("ugap_bcastInit returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } ugap_bcastSetDuty(1, 0); ugap_bcastStart(advCount); if(status != SUCCESS) { System_printf("ugap_bcastStart returned %d %s %d\n", status, __FUNCTION__, __LINE__); return; } // This isn't really doing anything. The callback calls uble_processMsg() directly for (;;) { // Waits for an event to be posted associated with the calling thread. // Note that an event associated with a thread is posted when a // message is queued to the message receive queue of the thread Event_pend(syncEvent, Event_Id_NONE, UTIL_QUEUE_EVENT_ID, BIOS_WAIT_FOREVER); // If RTOS queue is not empty, process app message. while (!Queue_empty(mainAppMsgQueueHandle)) { ubtEvt_t *pMsg; // malloc() is not thread safe. Must disable HWI. keyHwi = Hwi_disable(); pMsg = (ubtEvt_t *) Util_dequeueMsg(mainAppMsgQueueHandle); Hwi_restore(keyHwi); if (pMsg) { // Process message. uble_processMsg(); // free() is not thread safe. Must disable HWI. keyHwi = Hwi_disable(); // Free the space from the message. free(pMsg); Hwi_restore(keyHwi); } } } } void myPostEvtProxyCB(void) { //TODO: Append a message to the MQ to deal with the data and resume immediately // For now: System_printf("uBLE Callback %s %d\n", __FUNCTION__, __LINE__); uble_processMsg(); } void beacon_bcast_stateChangeCB(ugapBcastState_t newState) { System_printf("State Callback %d %s %d\n", newState, __FUNCTION__, __LINE__); return; } void beacon_bcast_advPrepareCB(void) { System_printf("Prepare Callback %s %d\n", __FUNCTION__, __LINE__); return; } void beacon_bcast_advDoneCB(bStatus_t status) { System_printf("Ad Done Callback %d %s %d\n", status, __FUNCTION__, __LINE__); return; }
And this is the debug output:
BLE Address 54:fa:24:f2:f8:f0 uBLE Callback myPostEvtProxyCB 720 State Callback 1 beacon_bcast_stateChangeCB 726 uBLE Callback myPostEvtProxyCB 720 uBLE Callback myPostEvtProxyCB 720 State Callback 3 beacon_bcast_stateChangeCB 726
The last line is the last message I get out of the program. The state macro for 3 is UGAP_BCAST_STATE_ADVERTISING but I never see beacons come out. I tried copying parts of the Eddystone beacon example for the CC2640 but I got the same results. I can't find a good explanation for how uBLE actually works, just very sparse mentions and documentation for the API calls.
Questions:
- Is there something special which needs to be set up in sysconfig?
- Is there anything wrong with the data?