|
| 1 | +Introduction |
| 2 | +============ |
| 3 | + |
| 4 | +The tree_structure_network project demonstrates the capabilities of the Texas |
| 5 | +Instruments BLE stack to function in Bluetooth® Low energy Tree Structure |
| 6 | +network. Technical aspects of this example are described in the accompanied app |
| 7 | +note. Please see: [Bluetooth® Low Energy Tree Structure Network](www.ti.com/lit/swra648) |
| 8 | + |
| 9 | +This example project is capable of functioning as a grandfather |
| 10 | +node, a father node and a child node in any combination, while |
| 11 | +maintaining several connections (up to the amount of connections defined by |
| 12 | +MAX_NUM_BLE_CONNS). The project is capable of connecting to any role in tree |
| 13 | +structure network. The role will be defined according to the connection sequence |
| 14 | +(e.g. the first nod to connect as a master will become the grandpa node). The |
| 15 | +project supports multiple simultaneous GATT discoveries. This project has the |
| 16 | +following app build configurations available: |
| 17 | + |
| 18 | +| Build Configuration | Description | |
| 19 | +|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 20 | +| FlashROM_Release (default) | All TI-RTOS debug features disabled but application-logging to UART remains enabled. The application uses the config file ble_release.cfg and the defines are in <app name>\_FlashROM\_Release.opt. | |
| 21 | +| FlashROM_Debug | All TI-RTOS debug features enabled. The application uses the config file ble_debug.cfg and the defines are in <app name>\_FlashROM\_Debug.opt. | |
| 22 | + |
| 23 | +All application configurations use the stack library configuration, |
| 24 | +FlashROM_Library. This build configuration will yield additional flash footprint |
| 25 | +optimizations by the linker since the application and stack can share contiguous |
| 26 | +flash pages. This configuration is further discussed in the Stack Library |
| 27 | +Configuration section of the BLE5-Stack User’s Guide provided in the SDK. |
| 28 | + |
| 29 | +Hardware Prerequisites |
| 30 | +====================== |
| 31 | + |
| 32 | +The default Tree Structure Network board configuration uses the CC26x2R1 |
| 33 | +LaunchPad development kit. This hardware configuration is shown in the below |
| 34 | +image: |
| 35 | + |
| 36 | + |
| 37 | + |
| 38 | +For custom hardware, see the Running the SDK on Custom Boards section of the |
| 39 | +BLE5-Stack User’s Guide. |
| 40 | + |
| 41 | +Software Prerequisites |
| 42 | +====================== |
| 43 | + |
| 44 | +For information on what versions of Code Composer Studio and IAR Embedded |
| 45 | +Workbench to use, see the Release Notes file provided in the SDK. For |
| 46 | +information on how to import this project into your IDE workspace and build/run |
| 47 | +it, please refer to the device’s Platform section in the BLE5-Stack User’s Guide. |
| 48 | + |
| 49 | +Assumptions/Considerations |
| 50 | +========================== |
| 51 | + |
| 52 | +Once the connection limit (set with the MAX_NUM_BLE_CONNS preprocessor define) |
| 53 | +is reached, the grandfather device and father device won’t be allowed to scan |
| 54 | +until there is a disconnection. |
| 55 | + |
| 56 | +By default, the tree_structure_network application is configured to filter and |
| 57 | +connect to peripheral devices with the TI Tree Structure Service UUID. |
| 58 | + |
| 59 | +If the project is configured for a large number of connections (via the |
| 60 | +MAX_NUM_BLE_CONNS preprocessor define) and also security (pairing/bonding), it |
| 61 | +is possible for heap allocation failures to occur which will break the stack. |
| 62 | +Therefore, the project should be stress-tested for its intended use case to verify |
| 63 | +that there are no heap issues by including the HEAPMGR_METRICS preprocessor |
| 64 | +define. See the Debugging section of the BLE5-Stack User’s Guide for more |
| 65 | +information on how to do this. |
| 66 | + |
| 67 | +When at least one connection is already formed, in order to allow enough |
| 68 | +processing time to scan for a new connection, the minimum possible connection |
| 69 | +interval (in milliseconds) that can be used is: |
| 70 | + |
| 71 | +12.5 + 5\*n |
| 72 | + |
| 73 | +where n is the amount of current connections. For example, if there are currently |
| 74 | +four connections, all four connections must use a minimum connection interval of |
| 75 | +12\*5 + 5\*4 = 32.5 ms in order to allow scanning to occur to establish a new |
| 76 | +connection. |
| 77 | + |
| 78 | +Usage |
| 79 | +===== |
| 80 | + |
| 81 | +The tree_structure_network project uses the two buttons on the LaunchPad to |
| 82 | +accept user input and outputs information through the UART. The UART is only |
| 83 | +used for display messages. This document will use a terminal program (Tera Term, |
| 84 | +PuTTY, etc.) to serve as the display for the output of the LaunchPad. Note that |
| 85 | +any other serial terminal can be used. The following default parameters are used |
| 86 | +for the UART peripheral for display: |
| 87 | + |
| 88 | +| UART Param | Default Values | |
| 89 | +|--------------|----------------| |
| 90 | +| Baud Rate | 115200 | |
| 91 | +| Data length | 8 bits | |
| 92 | +| Parity | None | |
| 93 | +| Stop bits | 1 bit | |
| 94 | +| Flow Control | None | |
| 95 | + |
| 96 | +Upon powering on or resetting the device, the user will see the default board |
| 97 | +message. (RP address refers to resolvable private address.) |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +In certain cases, the user may want to switch from a "menu view" to a "log view" |
| 102 | +(i.e. each new message is printed on the next line). In order to achieve this, |
| 103 | +open the compiler predefined symbols list (`.opt` file) and set the following |
| 104 | +define to zero: |
| 105 | + |
| 106 | +`-DBOARD_DISPLAY_USE_UART_ANSI=0` |
| 107 | + |
| 108 | +Establish the First Connection |
| 109 | +============================== |
| 110 | + |
| 111 | +Program all devices that will be a part of the the network with the tree network |
| 112 | +structure example project. |
| 113 | + |
| 114 | +Click the right button on the intended grandpa node. The device will discover |
| 115 | +other devices. If other devices are discovered, it will connect this device, then |
| 116 | +enable the connected device’s notification function, and send the command to turn |
| 117 | +on the green LED automatically. (In the image, the grandfather device display is |
| 118 | +shown on the left and the father1 device display on the right.) |
| 119 | + |
| 120 | + |
| 121 | + |
| 122 | +Establish the Tree Structure Network |
| 123 | +==================================== |
| 124 | + |
| 125 | +Now the grandfather board is connected to the the father1 board. Then turn on |
| 126 | +the power of father2, click the right button on grandfather board to connect the |
| 127 | +father2 board. Then follow the same way to use father1 board to connect the |
| 128 | +child1 board, and father2 board to connect the child2 board. |
| 129 | + |
| 130 | + |
| 131 | + |
| 132 | +GAP Role Information |
| 133 | +==================== |
| 134 | + |
| 135 | +For grandpa node, it is always central role. For children nodes, they are always |
| 136 | +peripheral role. For father node, when it is connected by grandpa node, it will |
| 137 | +be central role first. And after it connects to children node, it will be |
| 138 | +peripheral node. So father node GAP role changes when the connection and is thus |
| 139 | +defined as multi-role. |
| 140 | + |
| 141 | + |
| 142 | + |
| 143 | +Grandfather Node Writing |
| 144 | +======================== |
| 145 | + |
| 146 | +After establishing the tree structure network, the option to write and notify |
| 147 | +will now become available. In this option, pressing the left button on the |
| 148 | +grandfather board once will enable grandfather node to write data to all father |
| 149 | +nodes and children nodes defined in chalVals array. (If the data is intended to |
| 150 | +a child node, the father node will forward it automatically.) Note that when the |
| 151 | +message is received in each father and child node, their red led will be set or |
| 152 | +reset in order according to the message. When this happens the green led will |
| 153 | +automatically turn off. |
| 154 | + |
| 155 | + |
| 156 | + |
| 157 | + |
| 158 | + |
| 159 | + |
| 160 | + |
| 161 | +Grandfather node’s operation in tree type network is defined in the charVals |
| 162 | +table. See details below. |
| 163 | + |
| 164 | +``` |
| 165 | +//Char value table length |
| 166 | +#define string_index_max 8 |
| 167 | +
|
| 168 | +//Send char value table |
| 169 | +uint8_t charVals[string_index_max][TREENETWORKSERVICE_CHAR1_LEN] = { |
| 170 | + {'0', '1', '0', '0', '\0'}, //Father 1 led off |
| 171 | + {'0', '1', '1', '0', '\0'}, //Father 1's child 1 led off |
| 172 | + {'0', '2', '0', '0', '\0'}, //Father 2 led off |
| 173 | + {'0', '2', '1', '0', '\0'}, //Father 2's child 1 led off |
| 174 | + {'0', '1', '0', '1', '\0'}, //Father 1 led on |
| 175 | + {'0', '1', '1', '1', '\0'}, //Father 1's child 1 led on |
| 176 | + {'0', '2', '0', '1', '\0'}, //Father 2 led on |
| 177 | + {'0', '2', '1', '1', '\0'} //Father 2's child 1 led on |
| 178 | + // Reserved |
| 179 | + // Father index |
| 180 | + // Father branch elements (child index) |
| 181 | + // Led ON/OFF |
| 182 | + }; // Should be consistent with those in GattWrite |
| 183 | +``` |
| 184 | + |
| 185 | +Child Node Notification |
| 186 | +======================= |
| 187 | + |
| 188 | +After the network has been established, pressing the left button on a father |
| 189 | +board or a child board once will enable the node to send a message that this |
| 190 | +happened to the grandpa node (by GATT notification). The following shows the |
| 191 | +successful message on the grandpa node of the key pressing message. |
| 192 | + |
| 193 | + |
| 194 | + |
| 195 | +Data Transmission Flow and Data Format |
| 196 | +============================================================= |
| 197 | + |
| 198 | + |
| 199 | + |
| 200 | +Data packets are sent as GATT write or GATT notification packets. The data format |
| 201 | +is given below: |
| 202 | + |
| 203 | +| Array index | 0 | 1 | 2 | 3 | |
| 204 | +|-------------|:--------:|:-------------------:|:---------------------:|:----------:| |
| 205 | +| Meaning | Reserved | Father branch index | Children branch index | Led status | |
0 commit comments