This project is an iOS app that demonstrates how to steer a Sphero ball via URL commands using IBM Bluemix, the MQTT protocol and the IBM Internet of Things service. Watch the videos to learn more.
For the communication between the iOS app and the ball over bluetooth the Sphero iOS SDK is used. Since the SDK is not available under an open source license two directories need to be downloaded and copied into the iOS project.
For the communication between the iOS app and IBM Bluemix the IBM WebSphere iOS MQTT Client is used which needs to be downloaded and copied into the iOS project as well.
Authors: Mike Robertson, Bryan Boyd
After importing the dependencies and opening the project in Xcode, you should have the following project structure.
Download the Sphero iOS SDK and extract it. Copy the following two folders into the root of your iOS project.
To import the MQTT client library download the package and extract it. Make sure you select and download the refresh pack "1.0.0.4-WS-MQCP-MA9B.zip". From the zip file import the following two files into the Chariot folder.
- libiosMQTT.a
- MqttOCClient.h
In order to send commands to the iOS app a Node-RED flow in IBM Bluemix is used in combination with the IBM Internet of Things Foundation.
Log in to Bluemix and create a new application, e.g. MySphero, based on the Internet of Things Foundation Starter. Additionally add the Internet of Things service to it.
In the next step you have to register your own device. Open the dashboard of the Internet of Things service and navigate to 'Add Device'. As device type choose 'and' and an unique device id - screenshot. As result you'll get an org id and password - screenshot.
In order to import the flow open your newly created Bluemix application and open the Node-RED editor, e.g. http://mysphero.mybluemix.net/red, and choose [import from clipboard]((https://raw.githubusercontent.com/IBM-Bluemix/sphero-bluemix-android/master/images/nodered4.png). You find the flow (flow.txt) in the sub-directory 'noderedflow'. In the outgoing IoT node select your unique device id and deploy the application.
Before running the app you need to enter the Internet of Things configuration from the previous step in the iOS app. You can either do this in the UI of the app or directly in the source code. If you don’t want to modify the source code you can enter your configuration in the app’s welcome screen. Alternatively you can define the values of your org id, the unique id and the password in the file LoginViewController.m.
The app can not be run via the emulator but only via actual iOS devices. Before you can do this you need to sign the app. Also make sure that both Wifi and Bluetooth are enabled.
After this you can see the connected device in the IoT dashboard. You can now invoke the following URL commands to steer the Sphero ball.