Code Monkey home page Code Monkey logo

amazon-freertos-ble-ios-sdk's Introduction

image DEPRECATED

Announcement:

As of July 31st, 2023, this repository is deprecated. The contents of this repository will remain available but we will no longer provide updates nor accept new contributions and pull requests. We recommend instead that you start here for creating interactions between an iOS device and AWS. For Bluetooth Low Energy APIs we recommend you start here.

Since the initial release of this package, several new iOS versions have been released bringing with them enhanced security and usability. AWS Amplify has also released dozens of later versions of the AWS SDK with many new features and bug fixes.

The amazon-freertos-ble-ios-sdk is being deprecated to remove an example built on outdated code.

Have more questions? Post them in the FreeRTOS forum.

iOS SDK for FreeRTOS Bluetooth Devices

CocoaPods Version License Platform Build Status

Introduction

Using the iOS SDK for FreeRTOS Bluetooth Devices, you can create mobile applications that do the following:

  • Scan for and connect to nearby BLE devices running FreeRTOS

  • Provision Wi-Fi networks for a BLE device running FreeRTOS

  • Act as a proxy for transmitting MQTT messages between a device running FreeRTOS and the AWS IoT cloud

Setting Up the SDK

To install the iOS SDK for FreeRTOS Bluetooth Devices

  1. Install CocoaPods:
$ gem install cocoapods
$ pod setup

Note

You might need to use sudo to install CocoaPods.

  1. Install the SDK with CocoaPods (In Podfile):

Newer version of the freertos firmware use CBOR encoding, please use:

pod 'AmazonFreeRTOS'

Older version of the freertos firmware use JSON encoding, please use:

pod 'AmazonFreeRTOS', :git => 'https://github.com/aws/amazon-freertos-ble-ios-sdk.git', :tag => '0.9.4'

For FreeRTOS

https://github.com/aws/amazon-freertos release 201906.00_Major and after

Contents

All main functions are defined in

AmazonFreeRTOSManager.swift

AmazonFreeRTOSDevice.swift

These functions include:

AmazonFreeRTOSManager

BLE Helper Functions

The SDK includes some functions that help you perform BLE operations with Amazon FreeRTOS devices:

// Start scan for FreeRTOS devices.
startScanForDevices()

// Stop scan for FreeRTOS devices.
stopScanForDevices()

//  Disconnect. Clear all contexts. Scan for FreeRTOS devices.
rescanForDevices()

AmazonFreeRTOSDevice

BLE Helper Functions

The device ble options:

// Connect to the FreeRTOS device.
connect(reconnect: Bool, certificateId: String? = nil, credentialsProvider: AWSCredentialsProvider? = nil)

// Disconnect from the FreeRTOS device.
disconnect()

MQTT Proxy Service

MQTT proxy service start automatically

Network Config Service

The network configuration service configures the Wi-Fi network of the FreeRTOS Device. Its functions include:

listNetwork(_ listNetworkReq: ListNetworkReq)
saveNetwork(_ saveNetworkReq: SaveNetworkReq)
editNetwork(_ editNetworkReq: EditNetworkReq)
deleteNetwork(_ deleteNetworkReq: DeleteNetworkReq)

Documentation

https://aws.github.io/amazon-freertos-ble-ios-sdk/

Demo Application

The SDK includes a demo application that demonstrates some of the main features of the SDK. You can find the demo in Example/AmazonFreeRTOSDemo.

License

This library is licensed under the Apache 2.0 License.

amazon-freertos-ble-ios-sdk's People

Contributors

clundin55 avatar kstribrnamzn avatar lundinc2 avatar massi-ang avatar mingyue86010 avatar mwillbanks avatar ravibhagavandas avatar xuaninbox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

amazon-freertos-ble-ios-sdk's Issues

Undefined symbols for architecture arm64

Hello, we have a react-native project with AmazonFreeRTOS and Xcode 14.2. We are experience some issues with building releases:

Undefined symbols for architecture arm64:
"OBJC_CLASS$_AWSServiceConfiguration", referenced from:
objc-class-ref in AmazonFreeRTOSDevice.o
"OBJC_CLASS$_AWSEndpoint", referenced from:
objc-class-ref in AmazonFreeRTOSDevice.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Local Debug builds work with 50% chance. Sometimes we have to re-install Pods in order to fix the issues. But the main problem that we are using github actions for prod and because of that builds are always failing. And so far amazon-freertos-ble-ios-sdk is the only package which outputs errors in our project with Xcode 14.2 but we really need it for our app. Would it be possible to fix those 2 errors? I know that you already had one Issue created on this topic but its already Closed + we tried everything from that source and nothing helped us. I also believe that the issue might be in the syntax (Swift/Objective-C) and not Cocoapods, because the same config works perfectly fine on Xcode 13. We are ready to provide more info about env if needed and also help with testing fixes and etc.

  • OS: macOS 13.1
  • Xcode: 14.2
  • Target iOS: 14.5

Trying to compile demo throws errors on unknown symbols for arm64

Undefined symbols for architecture arm64:
"OBJC_CLASS$_AWSServiceConfiguration", referenced from:
objc-class-ref in AmazonFreeRTOSDevice.o
"OBJC_CLASS$_AWSEndpoint", referenced from:
objc-class-ref in AmazonFreeRTOSDevice.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I suspect this is a Mac M1 problem.
Can this be ported to Mac please, ASAP ?

Also, the project has so many warnings on AWS/Amazon libraries. Is that normal ?

Trying to build with Xcode 12.5

Terminating app due to uncaught exception 'NSInvalidArgumentException'

Hi,

I have followed the instructions on how to set up the demo ios app (modified awsconfiguration.json, AmazonConstants.swift).
The build is successful. The app runs. I am able to create a new account, get SMS confirmation, and then login into the app. This is when I get the following exception:
2019-02-09 18:49:53.712659+0100 AmazonFreeRTOSDemo[18854:7075888] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSNull _fastCStringContents:]: unrecognized selector sent to instance 0x251c399b0'

Any suggestions?

Thanks.

AFR LTS Release

  1. When trying ble connection no list is showing but we need to unpair it and then try again(log provided)
  2. When trying ble connection, ble list is showing but not getting connected. So we need to unpair and connect again(log will be provided soon)

Published (demo) app in appstore

We were using 'WifiConfig' from 'Massimiliano Angelino' from the App store, but is seems to have vanished. Is there another published application in the app store (based on this project?) that allows me to provision WiFI on aws freertos devices?

Wi-Fi provisioning fails on ESP32 board with "Failed to allocate taskpool" error

I checked out the master branches of amazon-freertos and amazon-freertos-ble-ios-sdk and did the usual configuration setup, including everything described in issue #9.

When I run the example iOS demo app, I get the bluetooth pairing popup but I don't get the list of local Wi-Fi networks.

The last thing reported in the ESP32 console log is: Failed to allocate taskpool job for list network request

Am I missing some configuration setting, perhaps? I did enable IOT_BLE_ENABLE_WIFI_PROVISIONING

Unable to access secure values after disconnecting from device

I pair a new BLE device (ESP32 FreeRTOS), and I can read the secured values (eg Mtu). If I then disconnect the device from the UI, or close the app, and then connect to the device again, the app is unable to read the secured values.

I have to forget the device from the Bluetooth settings and pair it again for it to work

Return error when incorrect password is provided

When calling AmazonFreeRTOSManager.shared.devices[uuid]?.saveNetwork() there is no return for that if the password is incorrect, this does not work in the demo app for iOS either. It would be very helpful if we could get that added to both so we can implement the same feature that the Android SDK already supports.

Can't get WiFi provisioning demo to work with ESP32 board and Release 1.5 branch of amazon-freertos

I checked out the Release-1.5 branch of the amazon-freetos project and built a version for the EPS32 board after doing the usual Thing/Cert/Policy creation using SetupAWS.py.

Next I checked out the beta branch of this project (amazon-freertos-ble-ios-sdk), modified AmazonConstants and awsconfiguration.json with the appropriate AWS/IoT IDs, and ran the demo app under Xcode.

The demo app runs fine and lets me create an account. It recognizes the ESP32 board. But when I try to use the Network Config feature, the app reports the following error:

2019-05-20 15:53:51.786156-0700 AmazonFreeRTOSDemo[1774:792997] [AFR][8D78F2FC-A4CF-8F6D-EA70-53B6E8C876EC][NETWORK][ERROR] NetworkConfig service or RXNetworkMessage characteristic doesn't exist
After poking around a bit, it looks like the NetworkConfig service is not being discovered in AmazonFreeRTOSManager.swift.

CBOR encoding crashes when saving a network SSID with UTF characters

If you call saveNetwork with a network that has an SSID or a password that contains UTF character this results in a crash in the CBOR encoding library.

Here is the stack trace of the crash:

EXC_BREAKPOINT

amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/SwiftCBOR/Extensions.swift:126:35 Swift runtime failure: Unexpectedly found nil while unwrapping an Optional value
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/SwiftCBOR/Extensions.swift:144:29 ascii_bytes.get
merged @objc (extension in AmazonFreeRTOS):__C.NSNumber.encode() -> Swift.String
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/SwiftCBOR/Encoder.swift:35:26 getIncludedEncodings
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/SwiftCBOR/Encoder.swift:96:66 encode
merged @objc (extension in AmazonFreeRTOS):__C.NSNumber.encode() -> Swift.String
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/SwiftCBOR/CBOR.swift:16:22 encode
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/AmazonFreeRTOSManager.swift encode
amazon-freertos-ble-ios-sdk/AmazonFreeRTOS/AmazonFreeRTOSDevice.swift:292:38 saveNetwork

It looks like amazon-freertos-ble-ios-sdk uses a copy of https://github.com/hassan-shahbazi/CBORSwift as its CBOR implementation. Unfortunately it looks like this library is no longer being maintained. This CBOR implementation explicitly tries to parse strings using ASCII encoding as seen here: https://github.com/aws/amazon-freertos-ble-ios-sdk/blob/master/AmazonFreeRTOS/SwiftCBOR/Extensions.swift#L126 which is problematic.

One way to fix this is to update the SwiftCBOR implementation in this repo to handle UTF strings. But another option would be to switch to a Swift CBOR library that is actively maintained. What would you propose? Thanks.

Get afrVersion spelled gatAfrVersionOfPeripheral

If intentional, maybe a bit confusing?

The function name starts with gat, which in BLE terms it could suggest GATT.

But the source comments suggest it should bet get:

/** Get afrVersion of the Amazon FreeRTOSperipheral.... */ public func gatAfrVersionOfPeripheral(_ peripheral: CBPeripheral)

PIN-Based Bluetooth Connection without Default Popup

Requirement:

  • We need to implement authentication for a BLE connection. Currently, Peripheral broadcasts an intent for PIN-based pairing, and the device displays a popup to enter the PIN for pairing. However, we want to handle this process programmatically without displaying the default popup.

Problem:

  • In Android, we can bypass the default OS popup and manage PIN-based authentication programmatically using the setPin method. However, in the iOS SDK, I haven't found a similar method that fulfills our requirement. It seems that there is no such method even in CBCentralManager.

Here are some threads indicating that achieving this in iOS is not possible

We are using this SDK and would like to know how we can implement PIN-based authentication programmatically.

Please advise on how to proceed with this implementation.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.