RoadTest: TI SimpleLink™ Bluetooth® LE CC2640R2F LaunchPad
Author: backgar
Creation date:
Evaluation Type: Development Boards & Tools
Did you receive all parts the manufacturer stated would be included in the package?: True
What other parts do you consider comparable to this product?: NRF52 Development Kit with Bluetooth 5.0, Arduino/Genuino 101 (Bluetooth LE) and the CY8CKIT-042-BLE pioner kit from Cypress with Bluetooth LE 4.2.
What were the biggest problems encountered?: The documentation available is complex for beginners and there are few examples and tutorials for the Bluetooth 5.0.
Detailed Review:
Since the other roadtesters had done a great job explaining what comes with the launchPad and the general especifications about it, I will skip that part. Instead, I want to focus on my journey to test the new features of the Bluetooth 5.0 (the new 2Mb/s high throughput) using this Launchpad (Spoiler: I was not successful). To give some context, I have been working with Bluetooth Low Energy for around 1 year using the CY8CKIT-042-BLE pioner kit from Cypress Semiconductor, and it was my first time using a Texas Instrument product or the Code Composer Studio. My research is related with wearable devices so I am interested in the new capabilities of Bluetooth 5.0 to send data from the sensor to the Smartphone.
My objective for this LaunchPad was to test the maximum amount of data I could send using this Launchpad and a Samsung S8 with Bluetooth 5.0. In order to understand more how to achive the maximum throughput using Bluetooth 5.0 I recommend this well explained post. Also, I must mention that even though some Smartphones have Bluetooth 5.0, it is not possible to develop Android apps using the Bluetooth 5.0 capabilities until the phone is updated to Android 8.0 Oreo (only few phones). In the case of the Samsung S8, recently the beta of the Android 8.0 Oreo has launched for a few number of testers (not my case) and most of the people will have to wait until the beginning of next year. However, according to the video by AndroidAuthority, apparently, there is a way to make a Bluetooth 5.0 connection between the S8 and a Bluetooth 5.0 device if the device request that kind of connection.
There are two options to program the LaunchPad: The Code Composer Studio (which has to be downloaded here) or the CCS Cloud (that allows to program the Launchpad using a web browser). I decided to work with the first one because I am more used to program using a traditional IDE. After downloading the .zip file, extract it and run the installation file to install the program. Once installed, the first time it will ask for a workspace directory to save the files in it. Then, the Getting Started view will open (figure 1), in this view there are different options such as create New Project, Browse Examples or Import Project among other options.
Fig. 1. Getting started view when we open the Code Composer Studio.
Then, click on the Browse Examples option to open the Resource Explorer view (figure 2) where there are examples and information for the diferent boards.
Fig. 2. Resource Explorer view after clicking the Browse Examples option.
On the right side, there are software packages with the different versions for each of the boards. For this Launchpad we are interested in the SimpleLink CC2640R2 SDK and the SimpleLink CC2640R2 SDK BLE Example Pack, it is possible to download this packages in order to work with the offline. On the left side, there is a tree view with all the directories that contain the examples and training resources. In order to find an example, click on the Software directory, where you can find the SDK for the different boards, then click on the SimpleLink CC2640R2 SDK and then open the Examples\Development Tools\CC2640R2 LaunchPad\blestack directory (figure 3).
Fig. 3. Directory where the examples for this LaunchPad are stored.
The name of the folder is blestack which is a bit confusing, since in the previous version of the SDK (SimpleLink CC2640R2 SDK - v:1.40.00.45) there are two directories blestack and ble5stack that contain examples for two BLE versions (BLE 4.2 and BLE 5.0 respectively) as seen in figure 4. For this reason, I was not sure if the examples of the latest version of the SDK, were for the BLE 5.0 or 4.2 version (I guess only for the 4.2 version but I am not sure). Furthermore, in the SimpleLink Academy of the previous version, there is information about the Bluetooth 5 2Mbps PHY and the Bluetooth 5.0 version of the Project Zero, however, in the latest version of the SDK there are not.
Fig. 4. Files and directories that are available in the previous version of the SDK but they are not in the latest one.
For this reason, I decided to work with the previous version of the SDK, in particular with theexample simple_peripheral under the ble5stack directory. To open the example, open the CCS Compiler directory and selecting the simple_peripheral CCS files click on the Import to IDE button (red circle in the figure 5). This example converts the LaunchPad into a peripheral device with differente BLE characteristicas, including the Characteristic 4 with notification permisions.
Fig. 5. How to open the simple_peripheral example and import it in the IDE.
As mentioned before, this example converts the LauchPad into a BLE peripheral device with different charcateristics, including a Notification type characteristic. It also contains the option to choose between BLE 1 Mbps and the BLE 2 Mbps using the two buttons available in the LauchPad. In order to run the program in the Launchpad, first connect the Launchpad to the computer using the Usb cable. Then, selecting one of the files in the Project Explorer View, first click on Build (hammer icon) and once the building is finished click on the debug button (as shown in figure 6).
Fig. 6. How to build and run the example in the LaunchPad.
Once the program has been loaded in to the LaunchPad, press the terminate button (red stop icon) or press Ctrl + F2 to stop debugging. Then, install an application in the smartphone that allows to connect to a Bluetooth LE peripheral device. In my case, I used the Android app BLE Scanner, which is recommeded at the Texas Instrument documentation. On the other hand, to visualize the output text from the LaunchPad (such as the button menu) we need some software to connect via Serial comunication with the LauchPad. Following the documentation, I used PuTTY.
Since the connection is using Serial communication, we need to know to which port the LauchPad is conencted. For that, while the LauchPad is connected to the computer using the USB cable, in Windows open the device manager and check the PORT (COM and LPT). There, you should see at least two devices and one of them should have in its name Application/User UART, check to which COM port it is connected, in my case it was connected COM 13. Then, in PuTTY select Serial in the connection type, in the command line write the Port to which the LauchPad is connected (in my case COM 13) and a speed of 115200 (figure 7). Click Open and you will see the text sent from the LauchPad. If you do not see anything press the Reset button (next to the micro USB port) to restart the program.
Fig. 7. PuTTY setup (left) and text received from the LauchPad (right) after connecting.
On the smartphone side open the BLE Scanner app and you will see the a device called SimpleBLEPeripheral, click the Connect button and you will some changes both in the Smartphone app and in PuTTY (figure 8).
Fig. 8. BLE Scanner app when we start the application before connecting to the SimpleBLEPeripheral device (left), the discovered BLE services (center) and
the new view in PUTTY (right) after we connect to the device using a Samsung S8.
In the previous figure, we can see in the PuTTY window that the current PHY is 2 Mbps when we use the Samsung S8 to connect to the device. However, when we use a smartphone that does not support Bluetooth 5.0, we will not see that text. I used a Samsung S5 to connect to the device and observed in PuTTY that there is no information about the PHY (figure 9).
Fig. 9. Text shown in PuTTY when we connect a Samsung S5 to the device.
Moreover, when we use the buttons to try to connect using the 2 Mbps mode, we can see that it is written "PHY Change failure" (figure 10).
Fig. 10. Failure error shown in PuTTY when we try to connect a Samsung S5 to the device using the 2 Mbps mode.
With this test I checked that it was possible to connect the LauchPad and the Samsung S8 using the 2 Mbps mode even when the smartphone does not have Android 8.0 Oreo installed; and displays error when the smartphone does not have Bluetooth 5.0.
In order to test the real values of the high throughput mode, I edited the Characteristic 4 of the simple_peripheral program so that it could send the highest amount of data. In the simple_peripheral example, the Characteristic 4 notifies only one value per notification. However, we want to send more information per notification event so increase the total amount of data we can transfer per second. For that, some changes need to be done in the simple_peripheral example code.
Add a new constant to store the length of the value of Characteristic 4 (figure 11).
#define SIMPLEPROFILE_CHAR4_LEN 112
Fig. 11. Code that needs to be added in the simple_gatt_profile.h file to add the length of the value of Characteristic 4.
The value of 112 for the length of the value has its reason. Even though the maximum MTU size is 251, so that the maximum length of the characteristic value should be 247, when I tried with a length higher than 112 the example was programmed correctly in the LaunchPad but it did not work. The device did not appear as a Bluetooth device and when I tried to connect to the LaunchPad in PuTTY no text was shown (figure 12). I do not know why there is an error with higher length values, but after trying different values, 112 was the maximum length I could set that let the device work correctly.
Fig. 12. No text shown in PuTTY when the length of the value was larger than 112.
Some changes need to be done in this file:
#define SBP_PERIODIC_EVT_PERIOD 15
uint16_t myIndex = 0;
Fig. 13. Add a global variable myIndex that increments its value every time the periodic task is called.
3. Edit the SimpleBLEPeripheral_init function, in particular the FEATURE_OAD_ONCHIP part to initialize the Characetristic 4 vlaue with an array of length SIMPLEPROFILE_CHAR4_LEN:
#ifndef FEATURE_OAD_ONCHIP // Setup the SimpleProfile Characteristic Values // For more information, see the sections in the User's Guide: // http://software-dl.ti.com/lprf/ble5stack-docs-latest/html/ble-stack/gatt.html# // http://software-dl.ti.com/lprf/ble5stack-docs-latest/html/ble-stack/gatt.html#gattservapp-module { uint8_t k; uint8_t charValue1 = 1; uint8_t charValue2 = 2; uint8_t charValue3 = 3; uint8_t charValue4[SIMPLEPROFILE_CHAR4_LEN]; uint8_t charValue5[SIMPLEPROFILE_CHAR5_LEN] = { 1, 2, 3, 4, 5 }; for(k = 0; k < SIMPLEPROFILE_CHAR4_LEN; k++) { charValue4[k] = 1; } SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR1, sizeof(uint8_t), &charValue1); SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR2, sizeof(uint8_t), &charValue2); SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR3, sizeof(uint8_t), &charValue3); SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, SIMPLEPROFILE_CHAR4_LEN, charValue4); SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR5, SIMPLEPROFILE_CHAR5_LEN, charValue5); } // Register callback with SimpleGATTprofile SimpleProfile_RegisterAppCBs(&SimpleBLEPeripheral_simpleProfileCBs); #endif //!FEATURE_OAD_ONCHIP
4. Edit the SimpleBLEPeripheral_performPeriodicTask function, so that it sends a notification each period of time with an array of length SIMPLEPROFILE_CHAR4_LEN, that has value 1 in all its elements except the first two bytes in which the value of myIndex is stored. Also every time this function is called the value of myIndex is increased:
static void SimpleBLEPeripheral_performPeriodicTask(void) { #ifndef FEATURE_OAD_ONCHIP uint8_t valueToCopy[SIMPLEPROFILE_CHAR4_LEN]; uint8_t k; for(k = 0; k < SIMPLEPROFILE_CHAR4_LEN; k++) { valueToCopy[k] = 1; } //Edit the first two bytes to store myIndex value: valueToCopy[0] = HI_UINT8(myIndex); valueToCopy[1] = LO_UINT8(myIndex); //Increase the value of myIndex: myIndex += 1; // Call to set that value of the fourth characteristic in the profile. // Note that if notifications of the fourth characteristic have been // enabled by a GATT client device, then a notification will be sent // every time this function is called. SimpleProfile_SetParameter(SIMPLEPROFILE_CHAR4, SIMPLEPROFILE_CHAR4_LEN, valueToCopy); #endif //!FEATURE_OAD_ONCHIP }
static uint8 simpleProfileChar4[SIMPLEPROFILE_CHAR4_LEN] = {0};
2. Edit the code for Characteristic 4 at the Attribute table (figure 14):
// Characteristic Value 4 { { ATT_BT_UUID_SIZE, simpleProfilechar4UUID }, 0, 0, simpleProfileChar4 },
Fig. 14. Edited code for the value of Characteristic 4 at the Attribute table.
3. Edit the SimpleProfile_SetParameter function, so that in the case of Characteristic 4 it uses the function memcpy to copy the value of the variable value to the variable simpleProfileChar4:
case SIMPLEPROFILE_CHAR4: if ( len == SIMPLEPROFILE_CHAR4_LEN ) { VOID memcpy( simpleProfileChar4, value, SIMPLEPROFILE_CHAR4_LEN ); // See if Notification has been enabled GATTServApp_ProcessCharCfg( simpleProfileChar4Config, simpleProfileChar4, FALSE, simpleProfileAttrTbl, GATT_NUM_ATTRS( simpleProfileAttrTbl ), INVALID_TASK_ID, simpleProfile_ReadAttrCB ); } else { ret = bleInvalidRange; } break;
4. Edit the SimpleProfile_GetParameter function to work well with an array in the case of Characteristic 4:
case SIMPLEPROFILE_CHAR4: VOID memcpy( value, simpleProfileChar4, SIMPLEPROFILE_CHAR4_LEN ); break;
5. Edit the simpleProfile_ReadAttrCB function to work well with an array in the case of Characteristic 4:
case SIMPLEPROFILE_CHAR4_UUID: *pLen = SIMPLEPROFILE_CHAR4_LEN; VOID memcpy( pValue, pAttr->pValue, SIMPLEPROFILE_CHAR4_LEN ); break;
In order to test the changes made in the program I used the Android app nRF Connect to connect the Samsung S8 to the LaunchPad via Bluetooth 5.0. I choosed this application because of the options it has to edit the connection parameters and also because together with the application nRF Logger to store all the received values.
First program the LaunchPad with the edited example, and while the LauchPad has power launch the nRF Connect Application and you will see that the SimpleBLEPeripheral device is available (figure 15 left), press the Connect button and the application will show all the discovered services. Click on the 3 dots to display the connection options (red square of figure 15 right).
Fig. 15. nRF Connect application when opened (left) and the discovered services after connecting (right).
Then, some connection options will appear ("Read all characteristics", "Enable services"...). The first option I chose was "Request Conection priority" (figure 16 left) which allows to select the connection interval range (figure 16 right), I choosed HIGH priority to receive as many notifications as possible (it end up being a conection interval of 15 ms, thats why the period of the periodic event was set to 15 ms).
Fig. 16. The different connections options available (left) and the available connection priorities (right).
Next, I chose the "Request MTU" option (figure 17 left) to select the connection MTU size. For some reason the notifications did not work until I manually set the MTU size in the application, I chose a MTU size of 247 (figure 17 right).
Fig. 17. Request MTU option (left) and the manual setting of the MTU size (right).
Finally, press the "Enable services" option to enable the notifications (figure 18 left) and the received values will appear at the Characteristic 4 (figure 18 center), which can be found under Unknown Service. When we try to close the application it will prompt a message (figure 18 right) asking if you want to store the recording in the nRF Logger application (if already downloaded) , so press SAVE to store it.
Fig. 18. Enable services option (left), the received values at the Characteristic 4 (center) and the prompt message before closing the application (right).
In the nRF Logger application you will see the nRF Logger Welcome view. To access the log files from the nRF Connect application click on the menu button (red square figure 19 left) and the option for the nRF Connect will appear (figure 19 right).
Fig. 19. Welcome view of the nRF Logger application (left) and the nRF Connect option (right).
When we press the nRF Connect option, all the stored logs will appear (figure 20 left), then press one of the recordings to observe the recording data (figure 20 right). Observing the difference between consecutive timestamps I observed that the difference was of about 15 ms. This time difference between consecutive notification was the same even when I reduced the value of SBP_PERIODIC_EVT_PERIOD below 15 (due to the Connection interval value of 15ms). However, when the period was below 15 then some values were lost.
Fig. 20. List of stored log recordings (left) and the received values with the notifications (right).
Therefore, it was possible to calculate the amount of information per second that was transmited from the LaunchPad to the Samsung S8 (Bluetooth 5.0):
throughput=1000(ms)15(ms) ·112(bytes)·8(bitsbytes )≈60Kbps
This throughput was much smaller than the teoric maximum value. I tried the same experiment (same MTU size and connection interval) using a Samsung S5 (BLE 4.2) and observed that aorund 53 notifications were sent per second. The connection interval was also 15 ms but some of the notifications were missed. Therefore the throughput was:
throughput=53·112(bytes)·8(bitsbyte )≈50Kbps
In order to improve the throughput the length of the value of Characteristic 4 should be bigger (ideally 247 bytes) and also more notifications should be sent per connection, however I was not successful achieving those.
Other examples
Before finishing I wanted to mention that some other Bluetooth 5.0 are available. Particularly, I wanted to mention the Bluetooth 5.0 examples available at the Texas Instrument SimpleLink github. There are examples to test both the Long Range mode and the High Throughput mode. However, these examples require two CC2640R2 LaunchPads. I tried to program the thorughput_peripheral example in the LaunchPad but I did not know how to test the high throughput because there was no characteristic that supported Notifications.
Also, in the Resource Explorer of Code Composer Studio there is the SimpleLink CC2640R2 SDK BLE Example Pack, which contains few Bluetooth 5.0 examples to convert the LaunchPad into a Glucose Sensor, Heart Rate Monitor or a HID emulator.
In my opinion, when selecting a new board, one of the important points is the amount of available examples and tutorials for that board. In the case of this Launchpad, there are some resources available but I think that the Resource Explorer is a bit confusing. On the one hand, some examples are in one package and other examples in another package. On the other hand, depending on the SDK version there are different examples available.
Also, since the key aspects of Bluetooth 5.0 are both the higher throughput and the long range, there should be examples showing these capabilities. And, even though there are some examples that can be found in github, they use two LaunchPads instead of using a LaunchPad and a smartphone (which is more common). I think it is still early and we will have to wait until Android 8.0 Oreo is available in more devices to start seeing more and more examples of Bluetooth 5.0 connections between a smartphone and a device.
To sum up, I think this board is a good option if you have previous knowledge of both Bluetooth Low Energy and programming Texas Instrument products and you want to improve your products to Bluetooth 5.0. Otherwise, If you have not previos knowledge of those and you want to start learning about Bluetooth Low Energy and programming I would recommend the Arduino/Genuino 101, which has a similar price an built in sensors. And even though it does not support Bluetooth 5.0, there are many examples that will help you learn about how Bluetooth LE works.
I will still try to improve my code and try to get a higher throughput, so if you have any suggestion or you think I have not done some things correctly (which is very likely) please comment below and I will try to fix those.
Top Comments
Very well written road test report.
Well done.
DAB
Very nice overview of the TI CC2640R2F BLE LaunchPad. Yeah, the TI SimpleLink ecosystem takes some getting used to but does offer some cool examples. I find the Nordic nRF Connect BLE tool is one of my…