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.

CC2642R: CC2652R: How to remove RSSI monitoring and auto PHY update from simple_peripheral project

Part Number: CC2642R
Other Parts Discussed in Thread: SYSCONFIG

CC26x2


Note: The following instructions have been written for SDK 3_40_00_02 but can be adapted to quite any SDK version (that is why I provided the sources but also the diff files). In addition, the code was written for CC2642R but can be adapted to all the devices of the family (CC2652R, CC2652P, CC1352R, CC1352P)

 

This modification should free up some FLASH and some CPU time. The amount of stack required by the example should be decreased too.
We are going to basically stop reading the RSSI of our BLE connection. As a result, we will remove all the code allowing to change PHY according to the RSSI value.

  1. Import the project you want (the OOB simple_peripheral or the project where you have already removed the display function and/or the long range advertisement [see here])

  2. In simple_peripheral.c:
    • Remove the code executed when a HCI_READ_RSSI command is completed. As a result, you can remove the function SimplePeripheral_processCmdCompleteEvt(). Don’t forget to remove all the calls to it.
    • Remove the function SimplePeripheral_initPHYRSSIArray() and its calls
    • Remove the function SimplePeripheral_startAutoPhyChange() and its calls. This will allow you to delete the SimplePeripheral_connEvtCB() function.
    • Remove the function SimplePeripheral_stopAutoPhyChange() and its calls
    • Remove the RSSI thresholds defined (this does not save any FLASH or RAM but it these defines are useless now). Same remark for SP_MAX_RSSI_STORE_DEPTH, SP_RSSI_TRACK_CHNLS . You can also remove all the define related to auto-phy update: SP_PHY_NONE, SP_INVALID_HANDLE, AUTO_PHY_UPDATE (used for auto phy update)
    • Modify the spConnRec_t structure. We don’t need any more the RSSI related elements (rssiArr, rssiCntr, rssiAvg) and the PHY change related (currPhy, rqPhy, phyCngRq, phyRqFailCnt, isAutoPHYEnable). Remove all the code referring to these elements.
    • Remove the call to HCI_ReadRssiCmd(). As a result you can remove the whole SimplePeripheral_processConnEvt() function (and its call too)
    • Remove the functions SimplePeripheral_doSetConnPhy()and SimplePeripheral_setPhy(). You can also remove the global variable menuConnHandle
    • Remove the list setPhyCommStatList and the code related to it (as a result you can remove SimplePeripheral_updatePHYStat() function)
    • Remove the function SimplePeripheral_processCmdCompleteEvt() (this function is now empty, maybe you already removed it before). Don’t forget to remove all the calls to it.
    • To finish, you can remove the function SimplePeripheral_doAutoConnect(), the “AUTOCONNECT_” enum, the autoConnect global variable and the code associated
               >> Here are the diff file and the file you are supposed to get if you also removed the display and the secondary advertisement:
1261.simple_peripheral_remove_RSSI_autoPHY.diff
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_remove_long_range_adv.c Tue Feb 11 16:32:11 2020
+++ C:\ti\simplelink_cc13x2_26x2_sdk_3_40_00_02\examples\rtos\CC26X2R1_LAUNCHXL\ble5stack\simple_peripheral\Application\simple_peripheral_SIMPLE.c Wed Feb 12 13:28:45 2020
@@ -126,32 +126,12 @@
// Size of string-converted device address ("0xXXXXXXXXXXXX")
#define SP_ADDR_STR_SIZE 15
-// For storing the active connections
-#define SP_RSSI_TRACK_CHNLS 1 // Max possible channels can be GAP_BONDINGS_MAX
-#define SP_MAX_RSSI_STORE_DEPTH 5
-#define SP_INVALID_HANDLE 0xFFFF
-#define RSSI_2M_THRSHLD -30
-#define RSSI_1M_THRSHLD -40
-#define RSSI_S2_THRSHLD -50
-#define RSSI_S8_THRSHLD -60
-#define SP_PHY_NONE LL_PHY_NONE // No PHY set
-#define AUTO_PHY_UPDATE 0xFF
-
// Spin if the expression is not true
#define SIMPLEPERIPHERAL_ASSERT(expr) if (!(expr)) simple_peripheral_spin();
/*********************************************************************
* TYPEDEFS
*/
-
-// Auto connect availble groups
-enum
-{
- AUTOCONNECT_DISABLE = 0, // Disable
- AUTOCONNECT_GROUP_A = 1, // Group A
- AUTOCONNECT_GROUP_B = 2 // Group B
-};
-
// App event passed from stack modules. This type is defined by the application
// since it can queue events to itself however it wants.
@@ -210,17 +190,9 @@
// 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
} spConnRec_t;
/*********************************************************************
@@ -268,17 +240,8 @@
// Per-handle connection info
static spConnRec_t connList[MAX_NUM_BLE_CONNS];
-// Current connection handle as chosen by menu
-static uint16_t menuConnHandle = LINKDB_CONNHANDLE_INVALID;
-
-// List to store connection handles for set phy command status's
-static List_List setPhyCommStatList;
-
// List to store connection handles for queued param updates
static List_List paramUpdateList;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  
3716.simple_peripheral_SIMPLE.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/******************************************************************************
@file simple_peripheral.c
@brief This file contains the Simple Peripheral sample application for use
with the CC2650 Bluetooth Low Energy Protocol Stack.
Group: WCS, BTS
Target Device: cc13x2_26x2
******************************************************************************
Copyright (c) 2013-2019, 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 <string.h>
#include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Event.h>
#include <ti/sysbios/knl/Queue.h>
#if !(defined __TI_COMPILER_VERSION__)
#include <intrinsics.h>
#endif
#include <ti/drivers/utils/List.h>
#include <icall.h>
#include "util.h"
#include <bcomdef.h>
/* This Header file contains all BLE API and icall structure definition */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Build and test your program. Except the eventual warning raised by SysConfig due to modification we did earlier, everything should build and work smoothly.