Other Parts Discussed in Thread: SYSCONFIG
I'm encountering issues dealing with TI BLE Stack in my application. I am porting my application from SDK 3.20 to version 4.40 and of course everything worked perfectly in the 3.20 implementation.
The problem is this: I initialize the ICall stack and create an ICall Task, then I create some application tasks and from one of them I want to initialize the BLE Stack. I register that application task as an ICall dispatcher, then I proceed to call some BLE APIs as shown below. The problem occurs when calling HCI_LE_WriteSuggestedDefaultDataLenCmd(APP_SUGGESTED_PDU_SIZE, APP_SUGGESTED_TX_TIME);
or GAP_DeviceInit(GAP_PROFILE_PERIPHERAL, selfEntity, addrMode, NULL);
The call never return and following the execution step by step I found out that the program seems to be stuck in an infinite loop inside the OSAL task manager, it seems like the call needs a response message from the BLE Stack which never arrives.
Here is the main.c initialization:
static Task_Handle *BLE5taskHandler, *RF868taskHandler; Error_Block eb; Error_init(&eb); RegisterAssertCback(AssertHandler); Board_init(); // Enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); /* Update User Configuration of the stack */ user0Cfg.appServiceInfo->timerTickPeriod = Clock_tickPeriod; user0Cfg.appServiceInfo->timerMaxMillisecond = ICall_getMaxMSecs(); /* Initialize ICall module */ ICall_init(); /* Start tasks of external images - Priority 5 */ ICall_createRemoteTasks(); Peripherals_createTask(); BLE5taskHandler = ICall_getRemoteTaskHandle(0); BLE5_createTask(); RF868taskHandler = RF868_createTask(); PeopleCounter_createTask(); /* initialize and open the DMM policy manager */ DMMPolicy_init(); DMMPolicy_Params_init(&dmmPolicyparams); dmmPolicyparams.numPolicyTableEntries = DMMPolicy_ApplicationPolicySize; dmmPolicyparams.policyTable = DMMPolicy_ApplicationPolicyTable; DMMPolicy_open(&dmmPolicyparams); /* initialize and open the DMM scheduler */ DMMSch_init(); DMMSch_Params_init(&dmmSchParams); DMMSch_open(&dmmSchParams); /* register clients with DMM scheduler */ /* Set the stacks in default states */ DMMSch_registerClient(BLE5taskHandler, DMMPolicy_StackRole_BlePeripheral); DMMPolicy_updateStackState(DMMPolicy_StackRole_BlePeripheral, DMMPOLICY_STACKSTATE_BLEPERIPH_ADV); DMMSch_registerClient(RF868taskHandler, DMMPolicy_StackRole_WsnNode); DMMPolicy_updateStackState(DMMPolicy_StackRole_WsnNode, DMMPOLICY_STACKSTATE_CUSTOM_SLEEPING); BIOS_start(); return 0;
And here is the body of BLE.c, which is the application task I've described before:
// Register the current thread as an ICall dispatcher application so that the application can send and receive messages ICall_registerApp(&selfEntity, &syncEvent); // Create an RTOS queue for message from profile to be sent to app. appMsgQueueHandle = Util_constructQueue(&appMsgQueue); // Create one-shot clock for internal periodic events. Util_constructClock(&clkPeriodic, BLE5_clockHandler, BLE_PERIODIC_EVT_PERIOD, 0, false, (UArg)&argPeriodic); // Set the Device Name characteristic in the GAP GATT Service GGS_SetParameter(GGS_DEVICE_NAME_ATT, GAP_DEVICE_NAME_LEN, attDeviceName); // Configure GAP { uint16_t paramUpdateDecision = DEFAULT_PARAM_UPDATE_REQ_DECISION; // Pass all parameter update requests to the app for it to decide GAP_SetParamValue(GAP_PARAM_LINK_UPDATE_DECISION, paramUpdateDecision); } // Setup the GAP Bond Manager setBondManagerParameters(); // Initialize GATT attributes GGS_AddService(GATT_ALL_SERVICES); // GAP GATT Service GATTServApp_AddService(GATT_ALL_SERVICES); // GATT Service DevInfo_AddService(); // Device Information Service MicrologProfile_AddService(GATT_ALL_SERVICES); // GATT Profile // Register callback with Microlog GATT Profile MicrologProfile_RegisterAppCBs(&BLE5_MicrologProfileCBs); // Start Bond Manager and register callback VOID GAPBondMgr_Register(&BLE5_BondMgrCBs); // Register with GAP for HCI/Host messages. This is needed to receive HCI events GAP_RegisterForMsgs(selfEntity); // Register for GATT local events and ATT Responses pending for transmission GATT_RegisterForMsgs(selfEntity); // Set default values for Data Length Extension // Extended Data Length Feature is already enabled by default // Set initial values to maximum, RX is set to max. by default(251 octets, 2120us) // Some brand smartphone is essentially needing 251/2120, so we set them here. #define APP_SUGGESTED_PDU_SIZE 251 //default is 27 octets(TX) #define APP_SUGGESTED_TX_TIME 2120 //default is 328us(TX) /* This fails*/ HCI_LE_WriteSuggestedDefaultDataLenCmd(APP_SUGGESTED_PDU_SIZE, APP_SUGGESTED_TX_TIME); // Initialize GATT Client GATT_InitClient(); // Initialize Connection List BLE5_clearConnListEntry(LINKDB_CONNHANDLE_ALL); //Initialize GAP layer for Peripheral role and register to receive GAP events GAP_DeviceInit(GAP_PROFILE_PERIPHERAL, selfEntity, addrMode, NULL); /* This fails */ // Initialize array to store connection handle and RSSI values BLE5_initPHYRSSIArray();