Skip to content

Latest commit

 

History

History

proxy

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Server functionality

proxy.py implements a functionality, which could be found on a server, allowing many clients to connect to it, and send data further into the database. A server acts also as a proxy between user-changeable settings stored in the database and configuration of client devices. Therefore, it has a means of exchanging information with both clients and the database. proxy.py utilises:

  • GSpread API to connect to Google Sheets implementation of database
  • MQTT protocol to communicate setting changes to clients, as well as receive incoming data

Implementation

The server runs two separate threads - one for database interface, which is implemented in dbHandler() function - and the other, recieveMessage() one to receive messages from the client.

dbHandler

Database handle function was designed to read settings changed in an app, convert them into easily transferable JSON files and pass it on to the client using MQTT messages. Another functionality of the function is to unpack incoming JSON packed sensor measurement data and transform them into database tuples, which are then added into the database as a new row.

receiveMessage

receiveMessage() function implements a simple MQTT client designed to receive sensor measurements and status updates from the client. On arrival, an MQTT message is put into a shared queue of information passed onto the dbHandler thread.