Companion servers in Node and Python for the PhonePi Sensor Streamer apps.
These are simple servers with WebSocket support that accept the sensor data and write it to a text file. These are companion sample servers for the PhonePi Sensor Streamer app.
Due to changes in the Android ecosystem since the last time the app was updated, we have had to re-write PhonePi. Also we have few extra sensors like camera and mic available in the new version. All new users are requested to download the "Sensor Stream" app (https://play.google.com/store/apps/details?id=com.sensorsensei) especially if you have an Android version >= X. All new updates will be made to this app. It's available for free. A pro version will be available in the upcoming months with more enancements and support for other protocols apart from Web Sockets.
We will continue to support "PhonePi" and "PhonePi+" for as long as feasible and atleast until the new version achieves feature parity with PhonePi+.
python --version
and pip --version
Brief Summary of steps to follow to create virtual env [Optional Step]
cd Python
cd Flask or cd WebSocket # Depending upon which server you want to use
py -m venv env # Create virtual env
source env/bin/activate (On Linux or Mac) or .\env\Scripts\activate (On Windows)
Final Installation and run steps
cd PhonePi_SampleServer-master/Python
cd Flask or cd WebSocket # Depending upon which server you want to use
pip install -r requirements.txt
python3 PhonePi.py
cd Node
npm install
npm start
You can make any changes you want to to PhonePi.py or PhonePi.js
This makes use of flask_sockets. Note the use of namespaces which are in accordance with the sensor's name. Sample code:
@sockets.route('/accelerometer')
def echo_socket(ws):
f=open("accelerometer.txt","a")
while True:
message = ws.receive()
print(message)
ws.send(message)
print>>f,message
f.close()
The app would then establish a connection to ws://url//accelerometer where url is what the user enters (ip address:port)
This repository is open to contributions. On the server side, we are looking to support sample servers in more languages and frameworks such as node.js, Go etc. Please feel free to raise PRs!