Simple code to configure connection and GATT on a BlueNRG 2 microcontroller from ST. With a lot of nice comments :)
- Initialize the platform.
- Play with LEDs.
- Start Bluetooth, GAP and GATT framework.
- Make the device visible and connectable.
- Publish as GATT characteristics some random values.
- What can I do with GATT characteristics? Read them using smartphone apps (nRF connect for Android, as example) or play with them using Pyhton (GATT library https://github.com/getsenic/gatt-python).
- Make modular code
- Make it read values from the sensors embedded in the ST BlueTile and publish them via Bluetooth.
- Get KEIL uVision for ST Microelectronics from https://www2.keil.com/stmicroelectronics-stm32/mdk
- Install on KEIL the Software Pack for the BlueNRG-2.
- Get the Software Development Kit for the ST BlueTile from https://www.st.com/en/evaluation-tools/steval-bcn002v1b.html#tools-software
- Unpack the SDK just downloaded, go to Project -> BLE_Examples -> BLE_SensorDemo and replace the existing folders with the ones from here. EWARM and TrueStudio folders are not necessary, as we're using uVision.
- Go inside the MDK-ARM folder, and open the uVision project. It will load everything, including the libraries from ST that are included in the SDK.
- Compile everything: you will get an .hex file in the MDK-ARM folder (or a subfolder). Use the ST RF-Flasher Utility from https://www.st.com/en/embedded-software/stsw-bnrgflasher.html to flash the HEX file (not the BIN!) to the board.
- The blue LED will turn on on the board and the device will be visible to any Bluetooth device. Use the nRF Android App or an application you wrote to take a look at its services and characteristics :)
- If something went wrong, flash another .hex file from the SDK, for example the ResetManager (Firmware -> BLE_Examples -> BLE_OTA_ResetManager) and then flash your .hex again. This has something to do with the OTA system from ST. https://community.st.com/s/question/0D50X0000BB0RlUSQV/unable-to-run-precompiled-firmware-on-bluetile-stevalbcn002v1