- 1 ginstr IoT firmware parameter documentation
- 1.1 Periphery access class
- 1.2 Periphery access class description
- 1.3 BLE access class description
- 1.4 Configuration class description
- 1.4.1 Architecture and logic description
- 1.4.2 Enumerations
- 1.4.3 Public methods
ginstr IoT firmware parameter documentation
Periphery access class description
A lot of onboard periphery works through multiplexers: 4051 for digital and analog inputs and 74HC595 for outputs.
"MuxDriver" class provides convenient access to the available onboard periphery with respect to multiplexors usage.
The MuxDriver class provides the following enumerations:
|GREEN_LED||15||green led power supply|
|AMBER_LED||14||amber led power supply|
|WHITE_LED||13||white led power supply|
|BLUE_LED||12||blue led power supply|
|D_BLUE_LED||11||bicolor led blue part power supply|
|D_RED_LED||10||bicolor led blue part power supply|
|GSM||9||GSM module power supply|
|LORA||8||LoRa module power supply|
|READ_A||7||4051 multiplexer trigger for A channel addressing|
|READ_B||6||4051 multiplexer trigger for B channel addressing|
|READ_C||5||4051 multiplexer trigger for C channel addressing|
|MUXOUT_1||4||custom digital output|
|port_reg (detailed ports table)|
|AMBER_LED_PORT||2||amber led power supply|
|WHITE_LED_PORT||3||white led power supply|
|BLUE_LED_PORT||4||blue led power supply|
|D_BLUE_LED_PORT||5||bicolor led blue part power supply|
|D_RED_LED_PORT||6||bicolor led blue part power supply|
|LORA_PORT||7||GSM module power supply|
|GSM_PORT||8||LoRa module power supply|
Set the power state of auxiliary periphery
void periphery_power(power_state a);
This method turns on/off the power on all auxiliary periphery used on this board. Without powering on, it will be impossible to use multiplexed inputs / outputs and manage GSM/LoRa power.
This method is a part of a power management system, used on the board.
Update the multiplexed periphery state
The method is used in the main cycle loop to update the state of multiplexers. Without it`s regular updating the periphery output states will not be updated and the input multiplexer data would not be read.
Reset the state of multiplexers to default values (everything is off)
The method is used for resetting the states of outputs for the off states. For inverted channels (LoRa, for example) the default logic level is HIGH.
Set the indication LEDs
void set_indication(mux_reg a, power_state val | bool val);
The method provides the way to set the selected LED on or off. This method is a simplified alias to set_muxout method, with disabled inversion by default
Set the state of multiplexer outputs with respect to inverted / non-inverted mode
void set_muxout(mux_reg a, power_state val, inversion inv);
The method provides the way to manage multiplexed ports with inversion mode defining
Set the value of physical ports
void set_physical(uint8_t a, power_state val, inversion inv);
Set the state of listed and available physical outputs with respect to inverted / non-inverted mode
Set the power state of GSM module
void GSM_power(power_state a);
This method used for GSM power management. After method execution, the separated step-up/step-down converter is powered on or off.
Set the power state of LoRa module
void LoRa_power(power_state a);
This method used for LoRa power management. After method execution, the p-channel MOSFET turns power on or off.
Get the ADC value from 4051 multiplexer
float get_adc_value(byte channel);
This method returns the value of ADC channel from 4051 multiplexer input. To avoid the inaccuracy of the readings, the multiplexed ADC update rate is one reading per 30 mS.
Get the digital values interpretation from 4051
bool get_dig_value(byte channel, float threshold=0.8);
This method is a wrapper for get_adc_value. It returns true if the read voltage is bigger than the threshold value. The default threshold value is 0.8V
Get the current values from the power sensor
Get the voltage values from the power sensor
Begin and set-up the G-sensor routine
bool g_sensor_begin(float sample_rate, int g_range);
This method is used when the g-sensor is setting up.
sample_rate - the sampling in samples per seconds (Hz). Highest frequency - bigger accuracy and power consumption. This parameter supports the following values: 0.781, 1.563, 3.125, 6.25, 12.5, 25, 50, 100, 200, 400, 800, 1600.
g_range - the range of sensibility. This parameter supports the following values in g: 2, 4, 8, 16.
Set the G-Sensor threshold
bool set_G_interrupt(int threshold, int duration);
This method is used to set up the threshold of g-sensor interrupt generation.
threshold - the sensibility threshold. Could be from 1 to 4096. lower - better sensibility;
duration - the movement duration of the event In ms. Could be from 1 to 255;
Get the X acceleration value from the G-sensor
Get the Y acceleration value from the G-sensor
Get the Z acceleration value from the G-sensor
Get the temperature value from a temperature sensor in C
Get the temperature value from a temperature sensor in F
Blinking the LED
Powering on the custom digital output
Powering on the modems
Reading the ADC data
Reading the digital data
Reading the accelerometer data
Reading the temperature data
BLE access class description
The BLE access class provides the features to use the ESP32 Bluetooth functionality with GATT profile to interact with the onboard periphery, configuration core and the logging core.
The main purpose of this class is providing the features for direct control and device configuration.
Configuration class description
The configuration class provides the features for complex device setup, which includes:
- registers reading/writing
- interacting with the filesystem
- configuration XML file parsing and configuration structure creating
- setting up the periphery with custom conditions
Architecture and logic description
Configuration tree structure and XML
The XML configuration file provides the data structure which configures the device with features needed for the exact specific case in a very broad range: from the telemetry transmission case to use cases connected with programmable logic controller usage.
The XML document should use the standards of this document type.
The configuration file consists of one root element and multiple logical blocks with a tree-like structure inside the root element.
The list of sections, used for configuration:
|Section name||Section description|
|configData||Inside this block, the config attributive information is described|
|communicationPriorities||Priorities for communication interface usage. If the device with higher priority is unable to get the network or transmit the data, then the lower priority device is used for this purpose.|
|modemDevices||Communication devices entities description|
|sensorDevices||Onboard sensors description and default configurations|
|durationPatterns||Description of duration patterns for the operations such as indication blinking and button-triggered functions|
|dataTransmision||List of data entities and their attributes, which should be sent to the ginstr server|
|ledIndication||List of led indication signals|
|deviceActions||List of device action entities in which could be described the conditions and the data sources for custom actions, such as “turn MUXOUT_3_PORT on IF condition is true” or “send a report with a message if conditions are true”. Different actions could work with the same target and contain multiple conditions|
|deviceActions||This section is used for port function configuration|
|ginstrServer||Connection set up|
|watchdog||Configuration of the watchdog timeout|
|button||Functions attached to button pressing patterns|