Skip to content
Matthew Henry edited this page Mar 2, 2020 · 1 revision

Sweng Notes

deployment options

Need a number of potential Azure deploy/CI options

  • Deploy on web app
  • deploy on storage service (Like Johnnys)
  • Deploy via dockerfile

CI

  • Travis?
  • Microsoft Azure CI?
  • Github actions

General testing solutions

Backend/Frontend are utterly separate at the moment, i.e combined testing/running needs to be implmeneted:

  • Makefile for running both services
  • Global env/Secrets need to be managed
  • Docker-compose potential for running entire solution??????

(Multple docker files probably needed)

Frontend Unit-testing

  • Nightwatch
  • Jest (Assume create-react-app solution?)
  • Some other test runner??

Sensor design

  • Each sensor needs a UUID (Generate using device name or something)
  • Temp/Humidity sensor, should send once per minute wih the following
{
        "id": UUID,
        "area": STRING i.e D
        "desk": integer, i.e 14 (nearest desk to the device)
        "temperature": float, 1 or 2 decimal
        "time": Internally generated timestamp for logging
}

How are these generated

UUID -> Current user? Mac address? Device name? Decided by config?

  • area -> Provided via .env potentially or through a deployable config file
  • desk -> See above
  • temperature -> Read from sensor, stored in memeory unil sent. Sensor read every 1 - 5 seconds (done via node assumptively)
  • time -> Generated by library and using the send time not the last read of sensor time.

sensor service design

The service must:

  • Run on startup
  • Recover on fail
  • Be stateless or let the state be transient enough to ignore
  • Self log (Incase of sensor failures or the like)
  • Send JSON post requests to a pre-configured endpoint
  • Be triggered by a timed event loop (1 request a minute ect)
  • Resend a request if it recieves a 404 or otherwise fails to get a success response
  • Potentially alert the controller service if there is a hardware fault
  • Run on a headless raspberry Pi microcontroller (or similar)

Possible Solutions

Use one of the following languages/frameworks

  • Python3/MicroPython/CircuitPython
  • NodeJS (Likely candidate)
  • GoLang (experimental but universal once compiled)
  • C (At a massive push)

Service loop looks like the following 1. Device starts and loads config 2. Device sends registration (POST)request to controller service - { "id": "UUID" } request style - If success, continue - ELSE retry until hearing back from the contoller 3. Device begins cron-like event loop with time between requests decided by config 4. On loop trigger send temperature data POST request (Described above) 5. Device recieves response from controller - IF response is 200 success, restart event loop - ELSE Resend last request 6. If a 200 is recieved then return to step 3, Else sleep????

Potential Modifications/improvements

It is possible to expand the rights and powers of the controllor to completely remove state from sensor nodes

  • Dynamically generate the config file and send it to the node after registration request (Merges step 1)
  • If the controllor goes down and the sensor goes to sleep have the controller send a wake call on restart
  • Potentailly have the controllor attempt to wake sleeping nodes before marking them as down/maulfunctioning
  • Catch errors early by having nodes alert the controller to issues with peripherals
  • Allow admin screen to communicate with nodes/Request node health, logs, ect

Clone this wiki locally