Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify the TI SensorTag Firmware to advertise indefinitely?

When the side button of the TI SensorTag is pressed, pairing with a device is possible for approx. 2-3 minutes. How do you modify the SensorTag's firmware so that it advertises forever and pressing the side button is not necessary every time?

And how do you upload the firmware with an iOS device, so without using CC-debugger?

like image 826
Mathijs Avatar asked Feb 28 '14 09:02

Mathijs


2 Answers

How I did it, with help of Chris Innanen (thanks!!)

You will need a Windows virtual machine if you do it on a Mac.

  1. Download IAR Embedded Workbench for 8051 (http://supp.iar.com/Download/SW/?item=EW8051-EVAL). Make sure to take the 30-day evaluation copy and not the 4k limited.

  2. Download BLE-STACK from Texas Instruments (http://www.ti.com/tool/ble-stack) and install it on a Windows (virtual) machine. By default, the installer will install here: "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\SensorTag\CC2541DB\SensorTag.eww".

  3. Open this SensorTag.eww file with IAR Embedded Workbench.

  4. Select "CK2541DK-Sensor-OAD-ImgA" in the dropdown menu in the "workspace" section on the left

  5. To prevent a compiling error later on: go to Project -> Options... and change the value for "Number of virtual registers" from 16 to 8.

  6. Find "SensorTag.c" in the filetree in the workspace section on the left: "SensorTag - CK2541DK-Sensor-OAD-ImgA/APP/SensorTag.c"

  7. Search for GAP_ADTYPE_FLAGS_LIMITED and change it to GAP_ADTYPE_FLAGS_GENERAL to enable indefinit advertising

  8. Make the build with Project -> Make. Wait until it's done

  9. By default, the new firmware image (.bin file) is now in "C:\Texas Instruments\BLE-CC254x-1.4.0\Projects\ble\SensorTag\CC2541DB\CC2541DK-Sensor-OAD-ImgA\Exe" (Make sure to place it somewhere you can reach it from Mac OS X later, if you use a virtual machine)

  10. Repeat steps 4 to 10, but now for "CC2541DK-Sensor-OAD-ImgB"

  11. Now get the app to upload the new firmware over the air. Get it here: https://itunes.apple.com/us/app/ti-sensortag/id552918064?mt=8

  12. Open iTunes in Mac OS X and open your iOS device, go to the 'Apps' section, scroll to the bottom to see the apps with filesharing possibilities. "SensorTag" should be in that list. Click on it and add the two new firmware files, both Image A and B.

  13. If that's done, open the SensorTag app on your iOS device and connect it to the SensorTag. Then in the bottom of the app tap "Update FW" -> "Select FW file" -> Shared Files > And then tap Image B and upload it. It takes a few minutes. A firmware with type A is already on your SensorTag by default. Because you've put a B Image on it just now, with any new changes you would need to upload an Image A.

Good luck!

Additional: changing the signal strength

1) Find "HCI_EXT_ClkDivOnHaltCmd" and you'll add a new line (and optional comment) after it: // ADDITION Adjust TX power level HCI_EXT_SetTxPowerCmd( HCI_EXT_TX_POWER_0_DBM );

1b) You can change "_0_DBM" to "_4_DBM" or "_MINUS_6_DBM" or "_MINUS_23_DBM" as well

2) Find "GAP_ADTYPE_POWER_LEVEL" and change the value on the next line to match the above power level

like image 94
Mathijs Avatar answered Sep 22 '22 15:09

Mathijs


The above solution didn't work for me until I changed:

  initial_advertising_enable = TRUE;

In SensorTag_Init().

like image 28
musicalengineer Avatar answered Sep 22 '22 15:09

musicalengineer