Skip to content

Software designs

Jelle Bouwhuis edited this page Aug 18, 2019 · 11 revisions

This page contains the software designs descriptions for the bGeigieCast.

Summary

The bGeigieCast is an extension for the bGeigieNano kit. With this module the bGeigieNano can be used as a fixed sensor, as well as the mobile sensor which we are all used to.

The main functions of the bGeigieCast are toggling between mobile and fixed mode, sending average measurements to the API every 5 minutes and configuring the wifi. More about the functional descriptions can be found on the software specification page.

Components

The bGeigieCast is seen as a sub-component of the whole bGeigieNano system. Hardware wise, it will be plugged in the XBee socket on top of the Arduino FIO. This way it will communicate over hardware serial 2 (uart2). It also adds 3 external interfaces, the mode button (hardware), the bluetooth connection (which is the same as the BLEBee module) and a wifi access point for configurations.

component diagram

Components descriptions

Controller

The controller is the core of the system. It will get the data from the bGeigieController and pass it on to the bluetooth and API connector.

Provided interfaces

Interface Description
espMode Button to toggle the mode of the bGeigieCast

Required interfaces

Interface (Component) Reason
dataReports (bGeigieController) To retrieve measurements from the bGeigieController
reporterControl (Reporter) To report readings to bluetooth / API
serverControl (ConfigServer) To setup the config server

Reporter

The reporter will receive data from the controller to report to the bluetooth and API connector.

Provided interfaces

Interface Description
reporterControl Interface to control the reporter, command it to report readings

Required interfaces

Interface (Component) Reason
bluetoothControl (Bluetooth) To send the readings over bluetooth
APIControler (APIConnector) To send the readings to the API

ConfigServer

Component that handles the configuration access point. Can start and stop the web server, uses the esp config component to store new settings.

Configurations that can be set:

  • Access point name (SSID)
  • Access point password
  • WiFi name (SSID)
  • WiFi password
  • API key
  • Which API to use (development / production)

Provided interfaces

Interface Description
serverControl Functions to start, stop and manage the web server
deviceConfig Web interface to set new configurations

Required interfaces

Interface (Component) Reason
config (EspConfig) Set new configurations, use existing configurations for initializing and provide information on the web server

EspConfig

Configuration component, offers some functions to store / retrieve configurations, or reset.

Provided interfaces

Interface Description
config Functions to initialize, retrieve, store or reset data

Required interfaces

This component does not require any other components.

Bluetooth

Component to control the bluetooth connection, send data over bluetooth. Contains all information about the bluetooth service, characteristics and descriptors.

Provided interfaces

Interface Description
liveData Bluetooth endpoint to connect e.g. the safecast drive app
bluetoothControl Functions to initialize and publish readings

Required interfaces

This component has no required interfaces

ApiConnector

The ApiConnector offers basic functions to manage the connection. It will keep track of readings that were not able to be send to the API (e.g. disconnected, api down).

Provided interfaces

Interface Description
APIControl Functions to start, stop and manage the API connector

Required interfaces

Interface (Component) Reason
config (EspConfig) Get the WiFi SSID, WiFi password, API key and server endpoint information
api (API) Interface provided by the safecast API, tt.safecast.org

Internal processes

The system in build with a state machine, where the main controller can be in only one state at the time. There are 3 "main" modes:

  • Config server - Does nothing but host a configuration server to connect to and change the wifi / api settings
  • Active (Mobile) mode - Used when you take the bgeigie out for a drive / walk
  • Active (Fixed) mode - Used when you put the bGeigie on the wall as fixed sensor

There is also the reporter, which will handle the incoming readings, processing them and reporting the reading over bluetooth and to the API.

Controller State Machine

bGeigieCast: Controller state machine diagram

Events

Overview of all events in the controller state machine and how they are triggered:

Event name Description Used in state
e_button_pressed Press the mode button for less than 4 seconds MobileMode
FixedMode
PostInitialize
ServerActive
e_button_long_pressed Press the mode button for more than 4 seconds Active
e_controller_initialized After controller has been initialized Initialize
e_post_init_time_passed 3 seconds passed in the post-init state PostInitialize
e_server_initialized Config server has been initialized SetupServer

Reporter State Machine

bGeigieCast: Reporter state machine diagram

Events

Overview of all events in the reporter state machine and how they are triggered:

Event name Description Used in state

Api connector State Machine

bGeigieCast: Api state machine diagram

Events

Overview of all events in the reporter state machine and how they are triggered:

Event name Description Used in state

Data process

Some overall view of the data flow.

Data process