How do I access Bluetooth services when using RTOS?



I'm working with a hardware device that has firmware on it which is based on Amazon RTOS. I have two mobile apps, one for iOS and one for Android. The device in question has the RTOS bluetooth service, but also has custom BLE services that my apps need to use.

When I developed the iOS app, I chose not to import any Amazon SDKs into my app. Instead I used my own BLE code and look at some of the source code and examples to figure out how to use the various services (such as connecting the device to a Wifi network). Then it was straightforward for me to add additional code to support the custom services.

My colleague is developing our Android app. He decided to import the "AmazonFreeRTOSManager" and related Amazon code. He was able to build an app that connects to the device, has it scan for Wifi networks, and connect to a Wifi network. That part works fine.

But now we need to access our custom BLE services, and we're at a loss. We don't have any direct access to BLE functions. We don't know how to query for the services and characteristics as we would if we were writing our own code.

I'm sure there must be a way to do these things. Can someone help us out with an explanation?

Thanks, Frank

asked a year ago325 views
1 Answer
Accepted Answer

Hi Frank. Please be aware that FreeRTOS BLE Android SDK (and indeed the iOS one too) is deprecated as of July 31. Please check out the updated README.

We don't have any direct access to BLE functions. We don't know how to query for the services and characteristics as we would if we were writing our own code.

This would seem to be a case of starting with this SDK and iterating it to suit your needs. The following file is where the SDK is reading and writing to BLE characteristics (and calling the Android BLE APIs):

Service discovery is triggered here:

Discovered services are processed here:

profile pictureAWS
answered a year ago
reviewed a year ago
  • Thank you for the response. We ended up simply reconnecting to the device via our own code once we were finished with the RTOS functions.

    I'm a little concerned that these libraries are now deprecated. We are just finishing up a yearlong project. Is it just the app SDKs that are being deprecated, or will the firmware on the device also need to be updated? Is there a replacement? Do you know why it's being deprecated?

    Since our iOS app doesn't use the actual RTOS SDK, is it safe to leave that as-is? I guess what I'm asking is whether the protocols themselves are deprecated.


  • Nothing will stop working. It just means the repos are no longer maintained.

  • To add some context to Greg's excellent answer (since I was the one who pushed the deprecation notice) - the amazon-freertos-ble-ios-sdk and amazon-freertos-ble-android-sdk repositories were deprecated for several key reasons. The first being lack of maintenance and funding. The library was adopted by very few people/teams and because of the packages were a bit neglected since feature requests came in for other libraries much faster. For example the AFR BLE SDKs were several versions behind on dependencies and iOS/Android version support. Additionally the overall demos for this project show a way of handling BLE for IoT Devices that we no longer recommend. These demos implement a custom way of doing a sort of MQTT message relay from a BLE IoT device to a phone which then passes the message through to AWS IoT Core (not the most secure). For these reasons we decided to deprecate the AmazonFreeRTOS BLE SDKs.

    Now - with all this said, the AWS mobile SDKs (, are available and fully supported. Each OS also has a slew of resources for their BLE APIs. I would HIGHLY recommend you get started with those when building your application. Not only will you have newer and better features but the Amplify team does a great job supporting users.

  • The IoT device I'm working with was not developed by my company. My understanding is that the people who wrote the firmware on the device used an RTOS framework provided by Amazon. When we asked them how to access the device, they referred us to the FreeRTOS SDKs and said this was what we needed to use. Is it just the mobile SDKs that are being deprecated, or is the firmware on the device also deprecated?

  • I'd also like to say - as a developer I prefer not to use third-party libraries in my code at all. I have written many iOS apps that act as BLE clients without having to resort to using third-party code. I tried to do the same in this case. While I did manage to avoid installing the AmazonFreeRTOS SDKs in my iOS app, I had to do a lot of work to figure out the protocol on my own by reading the source code. And, whoever wrote this chose to use something called CBORCoding to exchange data with the device, which I had to end up using because I didn't have time to rewrite it myself.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions