This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
CC2640R2 (BLE5)
Note: The following instructions have been written for SDK 3_40_00_10 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files)
By removing the two_btn_menu and the display from the simple_peripheral project, you can significantly increase the remaining memory available on the device.
Remaining FLASH memory +130% - yes more than two times more (in comparison with OOB example)
How to do this?
1. Import the ble5_simple_peripheral project
2. Remove all the occurrences of "display" and "tbm" in main.c, simple_peripheral.c and simple_peripheral.h. Don't forget to change the IO capabilities of the device (look for "GAPBOND_IO_CAP_DISPLAY_ONLY" in simple_peripheral.c and modify it in "GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT").
--- C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\main.c Thu Jan 9 23:49:34 2020 +++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\main_SIMPLE.c Tue Feb 11 08:09:11 2020 @@ -73,8 +73,6 @@ icall_userCfg_t user0Cfg = BLE_USER_CFG; #endif // USE_DEFAULT_USER_CFG -#include <ti/display/Display.h> - /******************************************************************************* * MACROS */ @@ -100,8 +98,6 @@ */ extern void AssertHandler(uint8 assertCause, uint8 assertSubcause); - -extern Display_Handle dispHandle; /******************************************************************************* * @fn Main @@ -194,61 +190,7 @@ */ void AssertHandler(uint8 assertCause, uint8 assertSubcause) { - // Open the display if the app has not already done so - if ( !dispHandle ) - { - dispHandle = Display_open(Display_Type_ANY, NULL); - } - - Display_print0(dispHandle, 0, 0, ">>>STACK ASSERT"); - - // check the assert cause - switch (assertCause) - { - case HAL_ASSERT_CAUSE_OUT_OF_MEMORY: - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> OUT OF MEMORY!"); - break; - - case HAL_ASSERT_CAUSE_INTERNAL_ERROR: - // check the subcause - if (assertSubcause == HAL_ASSERT_SUBCAUSE_FW_INERNAL_ERROR) - { - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> INTERNAL FW ERROR!"); - } - else - { - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> INTERNAL ERROR!"); - } - break; - - case HAL_ASSERT_CAUSE_ICALL_ABORT: - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> ICALL ABORT!"); - HAL_ASSERT_SPINLOCK; - break; - - case HAL_ASSERT_CAUSE_ICALL_TIMEOUT: - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> ICALL TIMEOUT!"); - HAL_ASSERT_SPINLOCK; - break; - - case HAL_ASSERT_CAUSE_WRONG_API_CALL: - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> WRONG API CALL!"); - HAL_ASSERT_SPINLOCK; - break; - - default: - Display_print0(dispHandle, 0, 0, "***ERROR***"); - Display_print0(dispHandle, 2, 0, ">> DEFAULT SPINLOCK!"); - HAL_ASSERT_SPINLOCK; - } - - return; + HAL_ASSERT_SPINLOCK; }
/****************************************************************************** @file main.c @brief main entry of the BLE stack sample application. Group: WCS, BTS Target Device: cc2640r2 ****************************************************************************** Copyright (c) 2013-2020, Texas Instruments Incorporated All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ****************************************************************************** *****************************************************************************/ /******************************************************************************* * INCLUDES */ #include <xdc/runtime/Error.h> #include <ti/sysbios/knl/Clock.h> #include <ti/drivers/Power.h> #include <ti/drivers/power/PowerCC26XX.h> #include <ti/sysbios/BIOS.h> #include <icall.h> #include "hal_assert.h" #include "bcomdef.h" #include "simple_peripheral.h" #ifdef PTM_MODE #include "npi_task.h" #endif // PTM_MODE /* Header files required to enable instruction fetch cache */ #include <inc/hw_memmap.h> #include <driverlib/vims.h> #ifndef USE_DEFAULT_USER_CFG #include "ble_user_config.h" // BLE user defined configuration icall_userCfg_t user0Cfg = BLE_USER_CFG; #endif // USE_DEFAULT_USER_CFG /******************************************************************************* * MACROS */ /******************************************************************************* * CONSTANTS */ /******************************************************************************* * TYPEDEFS */ /******************************************************************************* * LOCAL VARIABLES */ /******************************************************************************* * GLOBAL VARIABLES */ /******************************************************************************* * EXTERNS */ extern void AssertHandler(uint8 assertCause, uint8 assertSubcause); /******************************************************************************* * @fn Main * * @brief Application Main * * input parameters * * @param None. * * output parameters * * @param None. * * @return None. */ int main() { /* Register Application callback to trap asserts raised in the Stack */ RegisterAssertCback(AssertHandler); Board_initGeneral(); // Enable iCache prefetching VIMSConfigure(VIMS_BASE, TRUE, TRUE); // Enable cache VIMSModeSet(VIMS_BASE, VIMS_MODE_ENABLED); #if !defined( POWER_SAVING ) /* Set constraints for Standby, powerdown and idle mode */ // PowerCC26XX_SB_DISALLOW may be redundant Power_setConstraint(PowerCC26XX_SB_DISALLOW); Power_setConstraint(PowerCC26XX_IDLE_PD_DISALLOW); #endif // POWER_SAVING /* 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(); SimplePeripheral_createTask(); /* enable interrupts and start SYS/BIOS */ BIOS_start(); return 0; } /******************************************************************************* * @fn AssertHandler * * @brief This is the Application's callback handler for asserts raised * in the stack. When EXT_HAL_ASSERT is defined in the Stack * project this function will be called when an assert is raised, * and can be used to observe or trap a violation from expected * behavior. * * As an example, for Heap allocation failures the Stack will raise * HAL_ASSERT_CAUSE_OUT_OF_MEMORY as the assertCause and * HAL_ASSERT_SUBCAUSE_NONE as the assertSubcause. An application * developer could trap any malloc failure on the stack by calling * HAL_ASSERT_SPINLOCK under the matching case. * * An application developer is encouraged to extend this function * for use by their own application. To do this, add hal_assert.c * to your project workspace, the path to hal_assert.h (this can * be found on the stack side). Asserts are raised by including * hal_assert.h and using macro HAL_ASSERT(cause) to raise an * assert with argument assertCause. the assertSubcause may be * optionally set by macro HAL_ASSERT_SET_SUBCAUSE(subCause) prior * to asserting the cause it describes. More information is * available in hal_assert.h. * * input parameters * * @param assertCause - Assert cause as defined in hal_assert.h. * @param assertSubcause - Optional assert subcause (see hal_assert.h). * * output parameters * * @param None. * * @return None. */ void AssertHandler(uint8 assertCause, uint8 assertSubcause) { HAL_ASSERT_SPINLOCK; } /******************************************************************************* * @fn smallErrorHook * * @brief Error handler to be hooked into TI-RTOS. * * input parameters * * @param eb - Pointer to Error Block. * * output parameters * * @param None. * * @return None. */ void smallErrorHook(Error_Block *eb) { for (;;); } /******************************************************************************* */
--- C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral.c Mon Feb 10 14:52:29 2020 +++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral_SIMPLE.c Tue Feb 11 08:08:37 2020 @@ -55,8 +55,6 @@ #include <ti/sysbios/knl/Event.h> #include <ti/sysbios/knl/Queue.h> -#include <ti/display/Display.h> - #if !(defined __TI_COMPILER_VERSION__) #include <intrinsics.h> #endif @@ -77,11 +75,7 @@ #endif //USE_RCOSC #include <board.h> -#include <board_key.h> - -#include <menu/two_btn_menu.h> - -#include "simple_peripheral_menu.h" + #include "simple_peripheral.h" #ifdef PTM_MODE @@ -141,7 +135,6 @@ // Application events #define SP_STATE_CHANGE_EVT 0 #define SP_CHAR_CHANGE_EVT 1 -#define SP_KEY_CHANGE_EVT 2 #define SP_ADV_EVT 3 #define SP_PAIR_STATE_EVT 4 #define SP_PASSCODE_EVT 5 @@ -160,17 +153,6 @@ // Size of string-converted device address ("0xXXXXXXXXXXXX") #define SP_ADDR_STR_SIZE 15 - -// Row numbers for two-button menu -#define SP_ROW_SEPARATOR_1 (TBM_ROW_APP + 0) -#define SP_ROW_STATUS_1 (TBM_ROW_APP + 1) -#define SP_ROW_STATUS_2 (TBM_ROW_APP + 2) -#define SP_ROW_CONNECTION (TBM_ROW_APP + 3) -#define SP_ROW_ADVSTATE (TBM_ROW_APP + 4) -#define SP_ROW_RSSI (TBM_ROW_APP + 5) -#define SP_ROW_IDA (TBM_ROW_APP + 6) -#define SP_ROW_RPA (TBM_ROW_APP + 7) -#define SP_ROW_DEBUG (TBM_ROW_APP + 8) // For storing the active connections #define SP_RSSI_TRACK_CHNLS 1 // Max possible channels can be GAP_BONDINGS_MAX @@ -247,25 +229,22 @@ // Connected device information typedef struct { - uint16_t connHandle; // Connection Handle + uint16_t connHandle; // Connection Handle spClockEventData_t* pParamUpdateEventData; - Clock_Struct* pUpdateClock; // pointer to clock struct - int8_t rssiArr[SP_MAX_RSSI_STORE_DEPTH]; - uint8_t rssiCntr; - int8_t rssiAvg; - bool phyCngRq; // Set to true if PHY change request is in progress - uint8_t currPhy; - uint8_t rqPhy; - uint8_t phyRqFailCnt; // PHY change request count - bool isAutoPHYEnable; // Flag to indicate auto phy change + Clock_Struct* pUpdateClock; // pointer to clock struct + int8_t rssiArr[SP_MAX_RSSI_STORE_DEPTH]; + uint8_t rssiCntr; + int8_t rssiAvg; + bool phyCngRq; // Set to true if PHY change request is in progress + uint8_t currPhy; + uint8_t rqPhy; + uint8_t phyRqFailCnt; // PHY change request count + bool isAutoPHYEnable; // Flag to indicate auto phy change } spConnRec_t; /********************************************************************* * GLOBAL VARIABLES */ - -// Display Interface -Display_Handle dispHandle = NULL; // Task configuration Task_Struct spTask; @@ -414,8 +393,6 @@ static void SimplePeripheral_processPasscode(spPasscodeData_t *pPasscodeData); static void SimplePeripheral_charValueChangeCB(uint8_t paramId); static status_t SimplePeripheral_enqueueMsg(uint8_t event, void *pData); -static void SimplePeripheral_keyChangeHandler(uint8 keys); -static void SimplePeripheral_handleKeys(uint8_t keys); static void SimplePeripheral_processCmdCompleteEvt(hciEvt_CmdComplete_t *pMsg); static void SimplePeripheral_initPHYRSSIArray(void); static void SimplePeripheral_updatePHYStat(uint16_t eventCode, uint8_t *pMsg); @@ -429,8 +406,6 @@ uint8_t txPhy, uint8_t rxPhy, uint16_t phyOpts); static uint8_t SimplePeripheral_clearConnListEntry(uint16_t connHandle); -static void SimplePeripheral_menuSwitchCb(tbmMenuObj_t* pMenuObjCurr, - tbmMenuObj_t* pMenuObjNext); static void SimplePeripheral_connEvtCB(Gap_ConnEventRpt_t *pReport); static void SimplePeripheral_processConnEvt(Gap_ConnEventRpt_t *pReport); #ifdef PTM_MODE @@ -605,10 +580,8 @@ uint8_t pairMode = GAPBOND_PAIRING_MODE_WAIT_FOR_REQ; // Use authenticated pairing: require passcode. uint8_t mitm = TRUE; - // This device only has display capabilities. Therefore, it will display the - // passcode during pairing. However, since the default passcode is being - // used, there is no need to display anything. - uint8_t ioCap = GAPBOND_IO_CAP_DISPLAY_ONLY; + // This device has no display capabilities. + uint8_t ioCap = GAPBOND_IO_CAP_NO_INPUT_NO_OUTPUT; // Request bonding (storing long-term keys for re-encryption upon subsequent // connections without repairing) uint8_t bonding = TRUE; @@ -681,9 +654,6 @@ // Initialize GATT Client GATT_InitClient(); - // Init key debouncer - Board_initKeys(SimplePeripheral_keyChangeHandler); - // Initialize Connection List SimplePeripheral_clearConnListEntry(CONNHANDLE_ALL); @@ -692,17 +662,6 @@ // Initialize array to store connection handle and RSSI values SimplePeripheral_initPHYRSSIArray(); - - // The type of display is configured based on the BOARD_DISPLAY_USE... - // preprocessor definitions - dispHandle = Display_open(Display_Type_ANY, NULL); - - // Initialize Two-Button Menu module - TBM_SET_TITLE(&spMenuMain, "Simple Peripheral"); - tbm_setItemStatus(&spMenuMain, TBM_ITEM_NONE, TBM_ITEM_ALL); - - tbm_initTwoBtnMenu(dispHandle, &spMenuMain, 2, SimplePeripheral_menuSwitchCb); - Display_printf(dispHandle, SP_ROW_SEPARATOR_1, 0, "===================="); } @@ -828,18 +787,6 @@ { case HCI_LE_SET_PHY: { - if (pMyMsg->cmdStatus == HCI_ERROR_CODE_UNSUPPORTED_REMOTE_FEATURE) - { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, - "PHY Change failure, peer does not support this"); - } - else - { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, - "PHY Update Status Event: 0x%x", - pMyMsg->cmdStatus); - } - SimplePeripheral_updatePHYStat(HCI_LE_SET_PHY, (uint8_t *)pMsg); break; } @@ -859,22 +806,6 @@ // A Phy Update Has Completed or Failed if (pPUC->BLEEventCode == HCI_BLE_PHY_UPDATE_COMPLETE_EVENT) { - if (pPUC->status != SUCCESS) - { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, - "PHY Change failure"); - } - else - { - // Only symmetrical PHY is supported. - // rxPhy should be equal to txPhy. - Display_printf(dispHandle, SP_ROW_STATUS_2, 0, - "PHY Updated to %s", - (pPUC->rxPhy == PHY_UPDATE_COMPLETE_EVENT_1M) ? "1M" : - (pPUC->rxPhy == PHY_UPDATE_COMPLETE_EVENT_2M) ? "2M" : - (pPUC->rxPhy == PHY_UPDATE_COMPLETE_EVENT_CODED) ? "CODED" : "Unexpected PHY Value"); - } - SimplePeripheral_updatePHYStat(HCI_BLE_PHY_UPDATE_COMPLETE_EVENT, (uint8_t *)pMsg); } break; @@ -943,21 +874,6 @@ */ static uint8_t SimplePeripheral_processGATTMsg(gattMsgEvent_t *pMsg) { - if (pMsg->method == ATT_FLOW_CTRL_VIOLATED_EVENT) - { - // ATT request-response or indication-confirmation flow control is - // violated. All subsequent ATT requests or indications will be dropped. - // The app is informed in case it wants to drop the connection. - - // Display the opcode of the message that caused the violation. - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "FC Violated: %d", pMsg->msg.flowCtrlEvt.opcode); - } - else if (pMsg->method == ATT_MTU_UPDATED_EVENT) - { - // MTU size updated - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "MTU Size: %d", pMsg->msg.mtuEvt.MTU); - } - // Free message payload. Needed only for ATT Protocol messages GATT_bm_free(&pMsg->msg, pMsg->method); @@ -982,10 +898,6 @@ { case SP_CHAR_CHANGE_EVT: SimplePeripheral_processCharValueChangeEvt(*(uint8_t*)(pMsg->pData)); - break; - - case SP_KEY_CHANGE_EVT: - SimplePeripheral_handleKeys(*(uint8_t*)(pMsg->pData)); break; case SP_ADV_EVT: @@ -1076,8 +988,6 @@ // Set Device Info Service Parameter DevInfo_SetParameter(DEVINFO_SYSTEM_ID, DEVINFO_SYSTEM_ID_LEN, systemId); - - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Initialized"); // Setup and start Advertising // For more information, see the GAP section in the User's Guide: @@ -1134,15 +1044,6 @@ // Enable long range advertising for set #2 status = GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); SIMPLEPERIPHERAL_ASSERT(status == SUCCESS); - -#ifdef PTM_MODE - // Enable "Enable PTM Mode" option - tbm_setItemStatus(&spMenuMain, SP_ITEM_PTM_ENBL, SP_ITEM_NONE); -#endif - // Display device address - Display_printf(dispHandle, SP_ROW_IDA, 0, "%s Addr: %s", - (addrMode <= ADDRMODE_RANDOM) ? "Dev" : "ID", - Util_convertBdAddr2Str(pPkt->devAddr)); #if defined(BLE_V42_FEATURES) && (BLE_V42_FEATURES & PRIVACY_1_2_CFG) if (addrMode > ADDRMODE_RANDOM) @@ -1164,22 +1065,12 @@ { gapEstLinkReqEvent_t *pPkt = (gapEstLinkReqEvent_t *)pMsg; - // Display the amount of current connections uint8_t numActive = linkDB_NumActive(); - Display_printf(dispHandle, SP_ROW_STATUS_2, 0, "Num Conns: %d", - (uint16_t)numActive); if (pPkt->hdr.status == SUCCESS) { // Add connection to list and start RSSI SimplePeripheral_addConn(pPkt->connectionHandle); - - // Display the address of this connection - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Connected to %s", - Util_convertBdAddr2Str(pPkt->devAddr)); - - // Enable connection selection option - tbm_setItemStatus(&spMenuMain, SP_ITEM_SELECT_CONN, TBM_ITEM_NONE); // Start Periodic Clock. Util_startClock(&clkPeriodic); @@ -1205,11 +1096,7 @@ { gapTerminateLinkEvent_t *pPkt = (gapTerminateLinkEvent_t *)pMsg; - // Display the amount of current connections uint8_t numActive = linkDB_NumActive(); - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Device Disconnected!"); - Display_printf(dispHandle, SP_ROW_STATUS_2, 0, "Num Conns: %d", - (uint16_t)numActive); // Remove the connection from the list and disable RSSI if needed SimplePeripheral_removeConn(pPkt->connectionHandle); @@ -1219,17 +1106,11 @@ { // Stop periodic clock Util_stopClock(&clkPeriodic); - - // Disable Connection Selection option - tbm_setItemStatus(&spMenuMain, TBM_ITEM_NONE, SP_ITEM_SELECT_CONN); } // Start advertising since there is room for more connections GapAdv_enable(advHandleLegacy, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); GapAdv_enable(advHandleLongRange, GAP_ADV_ENABLE_OPTIONS_USE_MAX , 0); - - // Clear remaining lines - Display_clearLine(dispHandle, SP_ROW_CONNECTION); break; } @@ -1271,20 +1152,6 @@ linkDBInfo_t linkInfo; linkDB_GetInfo(pPkt->connectionHandle, &linkInfo); - if(pPkt->status == SUCCESS) - { - // Display the address of the connection update - Display_printf(dispHandle, SP_ROW_STATUS_2, 0, "Link Param Updated: %s", - Util_convertBdAddr2Str(linkInfo.addr)); - } - else - { - // Display the address of the connection update failure - Display_printf(dispHandle, SP_ROW_STATUS_2, 0, - "Link Param Update Failed 0x%x: %s", pPkt->opcode, - Util_convertBdAddr2Str(linkInfo.addr)); - } - // Check if there are any queued parameter updates spConnHandleEntry_t *connHandleEntry = (spConnHandleEntry_t *)List_get(¶mUpdateList); if (connHandleEntry != NULL) @@ -1300,7 +1167,6 @@ } default: - Display_clearLines(dispHandle, SP_ROW_STATUS_1, SP_ROW_STATUS_2); break; } } @@ -1346,14 +1212,10 @@ { case SIMPLEPROFILE_CHAR1: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR1, &newValue); - - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Char 1: %d", (uint16_t)newValue); break; case SIMPLEPROFILE_CHAR3: SimpleProfile_GetParameter(SIMPLEPROFILE_CHAR3, &newValue); - - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Char 3: %d", (uint16_t)newValue); break; default: @@ -1411,9 +1273,6 @@ if (memcmp(pRpaNew, rpa, B_ADDR_LEN)) { - // If the RPA has changed, update the display - Display_printf(dispHandle, SP_ROW_RPA, 0, "RP Addr: %s", - Util_convertBdAddr2Str(pRpaNew)); memcpy(rpa, pRpaNew, B_ADDR_LEN); } } @@ -1456,59 +1315,6 @@ } /********************************************************************* - * @fn SimplePeripheral_keyChangeHandler - * - * @brief Key event handler function - * - * @param keys - bitmap of pressed keys - * - * @return none - */ -static void SimplePeripheral_keyChangeHandler(uint8_t keys) -{ - uint8_t *pValue = ICall_malloc(sizeof(uint8_t)); - - if (pValue) - { - *pValue = keys; - - if(SimplePeripheral_enqueueMsg(SP_KEY_CHANGE_EVT, pValue) != SUCCESS) - { - ICall_free(pValue); - } - } -} - -/********************************************************************* - * @fn SimplePeripheral_handleKeys - * - * @brief Handles all key events for this device. - * - * @param keys - bit field for key events. Valid entries: - * KEY_LEFT - * KEY_RIGHT - */ -static void SimplePeripheral_handleKeys(uint8_t keys) -{ - if (keys & KEY_LEFT) - { - // Check if the key is still pressed. Workaround for possible bouncing. - if (PIN_getInputValue(Board_PIN_BUTTON0) == 0) - { - tbm_buttonLeft(); - } - } - else if (keys & KEY_RIGHT) - { - // Check if the key is still pressed. Workaround for possible bouncing. - if (PIN_getInputValue(Board_PIN_BUTTON1) == 0) - { - tbm_buttonRight(); - } - } -} - -/********************************************************************* * @fn SimplePeripheral_doSetConnPhy * * @brief Set PHY preference. @@ -1534,7 +1340,6 @@ uint8_t connIndex = SimplePeripheral_getConnIndex(menuConnHandle); if (connIndex >= MAX_NUM_BLE_CONNS) { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Connection handle is not in the connList !!!"); return FALSE; } @@ -1550,9 +1355,6 @@ SimplePeripheral_stopAutoPhyChange(connList[connIndex].connHandle); SimplePeripheral_setPhy(menuConnHandle, 0, phy[index], phy[index], 0); - - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "PHY preference: %s", - TBM_GET_ACTION_DESC(&spMenuConnPhy, index)); } else { @@ -1597,13 +1399,9 @@ switch (pEventData->event) { case GAP_EVT_ADV_START_AFTER_ENABLE: - Display_printf(dispHandle, SP_ROW_ADVSTATE, 0, "Adv Set %d Enabled", - *(uint8_t *)(pEventData->pBuf)); break; case GAP_EVT_ADV_END_AFTER_DISABLE: - Display_printf(dispHandle, SP_ROW_ADVSTATE, 0, "Adv Set %d Disabled", - *(uint8_t *)(pEventData->pBuf)); break; case GAP_EVT_ADV_START: @@ -1613,13 +1411,6 @@ break; case GAP_EVT_ADV_SET_TERMINATED: - { -#ifndef Display_DISABLE_ALL - GapAdv_setTerm_t *advSetTerm = (GapAdv_setTerm_t *)(pEventData->pBuf); -#endif - Display_printf(dispHandle, SP_ROW_ADVSTATE, 0, "Adv Set %d disabled after conn %d", - advSetTerm->handle, advSetTerm->connHandle ); - } break; case GAP_EVT_SCAN_REQ_RECEIVED: @@ -1711,45 +1502,19 @@ static void SimplePeripheral_processPairState(spPairStateData_t *pPairData) { uint8_t state = pPairData->state; - uint8_t status = pPairData->status; switch (state) { case GAPBOND_PAIRING_STATE_STARTED: - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing started"); break; case GAPBOND_PAIRING_STATE_COMPLETE: - if (status == SUCCESS) - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing success"); - } - else - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Pairing fail: %d", status); - } break; case GAPBOND_PAIRING_STATE_ENCRYPTED: - if (status == SUCCESS) - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Encryption success"); - } - else - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Encryption failed: %d", status); - } break; case GAPBOND_PAIRING_STATE_BOND_SAVED: - if (status == SUCCESS) - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Bond save success"); - } - else - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Bond save failed: %d", status); - } break; default: @@ -1766,13 +1531,6 @@ */ static void SimplePeripheral_processPasscode(spPasscodeData_t *pPasscodeData) { - // Display passcode to user - if (pPasscodeData->uiOutputs != 0) - { - Display_printf(dispHandle, SP_ROW_CONNECTION, 0, "Passcode: %d", - B_APP_DEFAULT_PASSCODE); - } - #if defined(GAP_BOND_MGR) // Send passcode response GAPBondMgr_PasscodeRsp(pPasscodeData->connHandle , SUCCESS, @@ -1810,7 +1568,6 @@ if (connIndex >= MAX_NUM_BLE_CONNS) { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Connection handle is not in the connList !!!"); return; } @@ -1861,16 +1618,6 @@ */ bool SimplePeripheral_doSelectConn(uint8_t index) { - menuConnHandle = connList[index].connHandle; - - // Set the menu title and go to this connection's context - TBM_SET_TITLE(&spMenuPerConn, TBM_GET_ACTION_DESC(&spMenuSelectConn, index)); - - // Clear non-connection-related message - Display_clearLine(dispHandle, SP_ROW_CONNECTION); - - tbm_goTo(&spMenuPerConn); - return (true); } @@ -1977,9 +1724,9 @@ // Get connection index from handle connIndex = SimplePeripheral_getConnIndex(connHandle); if(connIndex >= MAX_NUM_BLE_CONNS) - { - return(bleInvalidRange); - } + { + return(bleInvalidRange); + } } // Clear specific handle or all handles @@ -2088,7 +1835,6 @@ connIndex = SimplePeripheral_getConnIndex(connHandle); if (connIndex >= MAX_NUM_BLE_CONNS) { - Display_printf(dispHandle, SP_ROW_STATUS_1, 0, "Connection handle is not in the connList !!!"); return; } @@ -2233,22 +1979,12 @@ } // end of if (connList[index].phyCngRq == FALSE) } // end of if (rssi != LL_RSSI_NOT_AVAILABLE) - Display_printf(dispHandle, SP_ROW_RSSI, 0, - "RSSI:%d dBm, AVG RSSI:%d dBm", - (uint32_t)(rssi), - connList[index].rssiAvg); - - } // end of if (status == SUCCESS) + } // end of if (status == SUCCESS) break; } case HCI_LE_READ_PHY: { - if (status == SUCCESS) - { - Display_printf(dispHandle, SP_ROW_RSSI + 2, 0, "RXPh: %d, TXPh: %d", - pMsg->pReturnParam[3], pMsg->pReturnParam[4]); - } break; } @@ -2450,81 +2186,6 @@ } // end of switch (eventCode) } -/********************************************************************* - * @fn SimplePeripheral_menuSwitchCb - * - * @brief Detect menu context switching - * - * @param pMenuObjCurr - the current menu object - * @param pMenuObjNext - the menu object the context is about to switch to - * - * @return none - */ -static void SimplePeripheral_menuSwitchCb(tbmMenuObj_t* pMenuObjCurr, - tbmMenuObj_t* pMenuObjNext) -{ - uint8_t NUMB_ACTIVE_CONNS = linkDB_NumActive(); - - // interested in only the events of - // entering scMenuConnect, spMenuSelectConn, and scMenuMain for now - if (pMenuObjNext == &spMenuSelectConn) - { - static uint8_t* pAddrs; - uint8_t* pAddrTemp; - - if (pAddrs != NULL) - { - ICall_free(pAddrs); - } - - // Allocate buffer to display addresses - pAddrs = ICall_malloc(NUMB_ACTIVE_CONNS * SP_ADDR_STR_SIZE); - - if (pAddrs == NULL) - { - TBM_SET_NUM_ITEM(&spMenuSelectConn, 0); - } - else - { - uint8_t i; - - TBM_SET_NUM_ITEM(&spMenuSelectConn, MAX_NUM_BLE_CONNS); - - pAddrTemp = pAddrs; - - // Add active connection info to the menu object - for (i = 0; i < MAX_NUM_BLE_CONNS; i++) - { - if (connList[i].connHandle != CONNHANDLE_INVALID) - { - // Get the address from the connection handle - linkDBInfo_t linkInfo; - linkDB_GetInfo(connList[i].connHandle, &linkInfo); - // This connection is active. Set the corresponding menu item with - // the address of this connection and enable the item. - memcpy(pAddrTemp, Util_convertBdAddr2Str(linkInfo.addr), - SP_ADDR_STR_SIZE); - TBM_SET_ACTION_DESC(&spMenuSelectConn, i, pAddrTemp); - tbm_setItemStatus(&spMenuSelectConn, (1 << i), SP_ITEM_NONE); - pAddrTemp += SP_ADDR_STR_SIZE; - } - else - { - // This connection is not active. Disable the corresponding menu item. - tbm_setItemStatus(&spMenuSelectConn, SP_ITEM_NONE, (1 << i)); - } - } - } - } - else if (pMenuObjNext == &spMenuMain) - { - // Now we are not in a specific connection's context - - // Clear connection-related message - Display_clearLine(dispHandle, SP_ROW_CONNECTION); - } -} - #ifdef PTM_MODE /********************************************************************* * @fn SimplePeripheral_doEnablePTMMode @@ -2537,14 +2198,6 @@ */ bool SimplePeripheral_doEnablePTMMode(uint8_t index) { - // Clear Display - Display_clearLines(dispHandle, 0, 15); - - // Indicate in screen that PTM Mode is initializing - Display_printf(dispHandle, 1, 0, "PTM Mode initializing!\n\n\rPlease note UART feed will now stop..."); - - // Before starting the NPI task close Display driver to make sure there is no shared resource used by both - Display_close(dispHandle); // Start NPI task NPITask_createTask(ICALL_SERVICE_CLASS_BLE); @@ -2564,9 +2217,6 @@ // Inform Stack to Initialize PTM HCI_EXT_EnablePTMCmd(); - - // Open back the display to avoid crashes to future calls to Display_printf (even though they won't go through until reboot) - dispHandle = Display_open(Display_Type_ANY, NULL); return TRUE; }
--- C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral.h Thu Jan 9 23:49:34 2020 +++ C:\ti\simplelink_cc2640r2_sdk_3_40_00_10\examples\rtos\CC2640R2_LAUNCHXL\ble5stack\simple_peripheral\src\app\simple_peripheral_SIMPLE.h Mon Feb 10 14:50:18 2020 @@ -56,7 +56,6 @@ /********************************************************************* * INCLUDES */ -#include <menu/two_btn_menu.h> /********************************************************************* * EXTERNAL VARIABLES @@ -79,15 +78,6 @@ */ extern void SimplePeripheral_createTask(void); -/* - * Functions for menu action - */ -/* Actions for Menu: Choose connection to work with */ -bool SimplePeripheral_doSelectConn(uint8 index); - -/* Actions for Menu: Set PHY - Select */ -bool SimplePeripheral_doSetConnPhy(uint8 index); - #ifdef PTM_MODE /* Actions for Menu: Enable PTM Mode */ bool SimplePeripheral_doEnablePTMMode(uint8 index);
3. The following files can be removed(facultative) from the Application folder: board_key.c, board_key.h, simple_peripheral_menu.c, simple_peripheral_menu.h, two_btn_menu.c, two_btn_menu.h
4. Test the example: it should still compile and work smoothly
Here are the links to the different threads I wrote regarding simple_peripheral FLASH size optimization:
Remove display CC26x2 / CC13x2: e2e.ti.com/.../879276
Remove display CC2640R2: e2e.ti.com/.../3252666
Remove #2 advertisement CC26x2 / CC13x2: e2e.ti.com/.../3255504
Remove #2 advertisement CC2640R2: e2e.ti.com/.../880139
Remove RSSI monitoring and auto PHY update CC26x2 / CC13x2: e2e.ti.com/.../880155
Remove RSSI monitoring and auto PHY update CC2640R2: e2e.ti.com/.../880151
Remove connection params updates CC26x2 / CC13x2: e2e.ti.com/.../880171
Remove connection params updates CC2640R2: e2e.ti.com/.../880163
Remove pairing CC26x2 / CC13x2: e2e.ti.com/.../880181
Remove pairing CC2640R2: e2e.ti.com/.../880177