This is a simple demo using node.js and Cordova (PhoneGap) to create a communication channel between an iOS device and a web application. The example demonstrates how to send iOS sensor data and custom messages to a web application and how to send commands from the web app to the iOS device.
Currently this demo only works for iOS devices. It could be made to work with Android as well if you add a Cordova websocket plugin for Android. I just don't have an Anroid device to test with.
Install and setup node.js and the required npm modules (note that the modules are not included in the distribution so you'll need to install them yourself):
- Install node.js if you have not already.
- Install the following npm modules. Navigate to Sensorconnect/sensor_connect_server in your terminal:
- type: 'npm install websocket' and hit enter
- type: 'npm install websocket-server' and hit enter
- type: 'npm install express' and hit enter
If you have trouble and are unfamiliar with node.js and npm, please read up on those topics.
Install and setup Cordova (PhoneGap):
- Download and install Cordova (PhoneGap) (This demo is using Cordova 1.8.0)
- Follow the Cordova setup instruction for iOS (use the instruction in the download, not the Cordova website because it's typically out of date).
- Change line 55 of main.js to the hostname of your computer. You can alternatively use the IP address of you're computer but the hostname is better if you're using a mac since your IP address could change.
- Open the SensorConnect XCode project and compile for you iOS device.
If this is your first time using Cordova (PhoneGap) first make sure you can run the Cordova demo application before trying to run this demo.
Once node.js and Cordova are installed and setup you can run the demo:
- Open Terminal and navigate the SensorConnect/sensor_connect_server/
- Type 'node server.js' to startup the server (you should see 'Server is listening on port 8080' if successful).
- Open SensorConnect/server_connect_client in your browser (I've only tested with Chrome... should also work in Firefox and Safari)
- Open SensorConnect on your iOS device (either directly if you've already installed it, or run it via Xcode)