Skip to content

Software designs

Jelle edited this page Mar 26, 2019 · 11 revisions

On this page the software designs for the bGeigie ESP-XBee are described.

Summary

The bGeigie ESP-XBee is an extension for the bGeigieNano kit. With this module the bGeigieNano can be used as a stationary (fixed) sensor, as well as the mobile sensor which we are all used to.

The main functions of the ESP-XBee 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 ESP-XBee 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 ESP-XBee

Required interfaces

Interface (Component) Reason
dataReports (bGeigieController) To retrieve measurements from the bGeigieController
bluetoothControl (Bluetooth) To send the readings over bluetooth
APIControler (APIConnector) To send the readings to the API
serverControl (ConfigServer) To setup the config server

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

State machine

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" states:

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

ESP-XBee state machine diagram

Events

Overview of all events in the 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
StationaryMode
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
e_connected WiFi connection has been made it the network Connecting
ConnectionError
Reconnecting
e_API_available Ping to API was successful TestApi
e_connection_lost Lost connection with the WiFi network Connected
e_connection_failed Unable to connect to the WiFi network Connecting
Reconnecting

Data process

TODO: Write description

Data process

Clone this wiki locally