Embedded System Design 2 - Project
|
Basic Low Power Payload (LPP) functionality. More...
#include <em_device.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include "lpp.h"
#include "datatypes.h"
#include "debug_dbprint.h"
Go to the source code of this file.
Macros | |
#define | LPP_DIGITAL_INPUT 0x00 |
#define | LPP_ANALOG_INPUT 0x02 |
#define | LPP_TEMPERATURE 0x67 |
#define | LPP_HUMIDITY 0x68 |
#define | LPP_ACCELEROMETER 0x71 |
#define | LPP_PRESSURE 0x73 |
#define | LPP_DIGITAL_INPUT_SIZE 0x03 |
#define | LPP_ANALOG_INPUT_SIZE 0x04 |
#define | LPP_TEMPERATURE_SIZE 0x04 |
#define | LPP_HUMIDITY_SIZE 0x03 |
#define | LPP_ACCELEROMETER_SIZE 0x08 |
#define | LPP_PRESSURE_SIZE 0x04 |
#define | LPP_DIGITAL_INPUT_CHANNEL 0x01 |
#define | LPP_ANALOG_INPUT_CHANNEL 0x02 |
#define | LPP_TEMPERATURE_CHANNEL 0x03 |
#define | LPP_HUMIDITY_CHANNEL 0x04 |
#define | LPP_ACCELEROMETER_CHANNEL 0x05 |
#define | LPP_PRESSURE_CHANNEL 0x06 |
#define | LPP_VBAT_CHANNEL 0x10 /* 16 */ |
#define | LPP_TEMPERATURE_CHANNEL_INT 0x11 /* 17 */ |
#define | LPP_TEMPERATURE_CHANNEL_EXT 0x12 /* 18 */ |
#define | LPP_STORM_CHANNEL 0x13 /* 19 */ |
#define | LPP_CABLE_BROKEN_CHANNEL 0x14 /* 20 */ |
#define | LPP_STATUS_CHANNEL 0x15 /* 21 */ |
Functions | |
bool | LPP_InitBuffer (LPP_Buffer_t *b, uint8_t size) |
void | LPP_ClearBuffer (LPP_Buffer_t *b) |
void | LPP_FreeBuffer (LPP_Buffer_t *b) |
bool | LPP_AddMeasurements (LPP_Buffer_t *b, MeasurementData_t data) |
Add measurement data to the LPP packet following the custom message convention to save bytes to send. More... | |
bool | LPP_AddStormDetected (LPP_Buffer_t *b, uint8_t stormDetected) |
Add a value to indicate that a storm has been detected to the LPP packet following the custom message convention. More... | |
bool | LPP_AddCableBroken (LPP_Buffer_t *b, uint8_t cableBroken) |
Add a value to indicate that the cable has been broken to the LPP packet following the custom message convention. More... | |
bool | LPP_AddStatus (LPP_Buffer_t *b, uint8_t status) |
Add a value to indicate a program status to the LPP packet following the custom message convention. More... | |
bool | LPP_deprecated_AddVBAT (LPP_Buffer_t *b, int16_t vbat) |
Add a battery voltage measurement to the LPP packet, disguised as an Analog Input packet (2 bytes). The channel is defined by LPP_VBAT_CHANNEL and is 0x10 . More... | |
bool | LPP_deprecated_AddIntTemp (LPP_Buffer_t *b, int16_t intTemp) |
Add an internal temperature measurement (2 bytes) to the LPP packet. The channel is defined by LPP_TEMPERATURE_CHANNEL_INT and is 0x11 . More... | |
bool | LPP_deprecated_AddExtTemp (LPP_Buffer_t *b, int16_t extTemp) |
Add an external temperature measurement (2 bytes) to the LPP packet. The channel is defined by LPP_TEMPERATURE_CHANNEL_EXT and is 0x12 . More... | |
bool | LPP_deprecated_AddStormDetected (LPP_Buffer_t *b, uint8_t stormDetected) |
Add a storm value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_STORM_CHANNEL and is 0x13 . More... | |
bool | LPP_deprecated_AddCableBroken (LPP_Buffer_t *b, uint8_t cableBroken) |
Add a cable break value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_CABLE_BROKEN_CHANNEL and is 0x14 . More... | |
bool | LPP_deprecated_AddStatus (LPP_Buffer_t *b, uint8_t status) |
Add a status value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_STATUS_CHANNEL and is 0x15 . More... | |
bool | LPP_AddDigital (LPP_Buffer_t *b, uint8_t data) |
bool | LPP_AddAnalog (LPP_Buffer_t *b, int16_t data) |
bool | LPP_AddTemperature (LPP_Buffer_t *b, int16_t data) |
bool | LPP_AddHumidity (LPP_Buffer_t *b, uint8_t data) |
bool | LPP_AddAccelerometer (LPP_Buffer_t *b, int16_t x, int16_t y, int16_t z) |
bool | LPP_AddPressure (LPP_Buffer_t *b, uint16_t data) |
Basic Low Power Payload (LPP) functionality.
Definition in file lpp.c.
bool LPP_AddAccelerometer | ( | LPP_Buffer_t * | b, |
int16_t | x, | ||
int16_t | y, | ||
int16_t | z | ||
) |
bool LPP_AddAnalog | ( | LPP_Buffer_t * | b, |
int16_t | data | ||
) |
bool LPP_AddCableBroken | ( | LPP_Buffer_t * | b, |
uint8_t | cableBroken | ||
) |
Add a value to indicate that the cable has been broken to the LPP packet following the custom message convention.
This is what each added byte represents:
LPP_CABLE_BROKEN_CHANNEL = 0x14
)LPP_DIGITAL_INPUT = 0x00
)cableBroken
valueWe always need 4 bytes.
[in] | b | The pointer to the LPP pointer. |
[in] | cableBroken | The cable break value. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 317 of file lpp.c.
bool LPP_AddDigital | ( | LPP_Buffer_t * | b, |
uint8_t | data | ||
) |
bool LPP_AddHumidity | ( | LPP_Buffer_t * | b, |
uint8_t | data | ||
) |
bool LPP_AddMeasurements | ( | LPP_Buffer_t * | b, |
MeasurementData_t | data | ||
) |
Add measurement data to the LPP packet following the custom message convention to save bytes to send.
This is what each added byte represents, in the case of 2
measurements:
LPP_VBAT_CHANNEL = 0x10
)LPP_ANALOG_INPUT = 0x02
)2
measurements)LPP_TEMPERATURE_CHANNEL_INT = 0x11
)LPP_TEMPERATURE = 0x67
)2
measurements)LPP_TEMPERATURE_CHANNEL_EXT = 0x12
)LPP_TEMPERATURE = 0x67
)2
measurements)If we have 6 measurements we need 43 bytes:
1 byte
to hold the amount of measurements2 bytes
to hold the battery voltage channel and LPP analog input type6*2bytes
to hold the battery voltage measurements2 bytes
to hold the internal temperature channel and LPP temperature type6*2bytes
to hold the internal temperature measurements2 bytes
to hold the external temperature channel and LPP temperature type6*2bytes
to hold the external temperature measurements[in] | b | The pointer to the LPP pointer. |
[in] | data | The struct which contains the measurements to send using LoRaWAN. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 182 of file lpp.c.
bool LPP_AddPressure | ( | LPP_Buffer_t * | b, |
uint16_t | data | ||
) |
bool LPP_AddStatus | ( | LPP_Buffer_t * | b, |
uint8_t | status | ||
) |
Add a value to indicate a program status to the LPP packet following the custom message convention.
This is what each added byte represents:
LPP_STATUS_CHANNEL = 0x15
)LPP_DIGITAL_INPUT = 0x00
)status
valueWe always need 4 bytes.
[in] | b | The pointer to the LPP pointer. |
[in] | status | The status value. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 360 of file lpp.c.
bool LPP_AddStormDetected | ( | LPP_Buffer_t * | b, |
uint8_t | stormDetected | ||
) |
Add a value to indicate that a storm has been detected to the LPP packet following the custom message convention.
This is what each added byte represents:
LPP_STORM_CHANNEL = 0x13
)LPP_DIGITAL_INPUT = 0x00
)stormDetected
valueWe always need 4 bytes.
[in] | b | The pointer to the LPP pointer. |
[in] | stormDetected | If a storm is detected using the accelerometer or not. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 274 of file lpp.c.
bool LPP_AddTemperature | ( | LPP_Buffer_t * | b, |
int16_t | data | ||
) |
void LPP_ClearBuffer | ( | LPP_Buffer_t * | b | ) |
Definition at line 118 of file lpp.c.
bool LPP_deprecated_AddCableBroken | ( | LPP_Buffer_t * | b, |
uint8_t | cableBroken | ||
) |
Add a cable break value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_CABLE_BROKEN_CHANNEL
and is 0x14
.
[in] | b | The pointer to the LPP pointer. |
[in] | cableBroken | The cable break value. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 529 of file lpp.c.
bool LPP_deprecated_AddExtTemp | ( | LPP_Buffer_t * | b, |
int16_t | extTemp | ||
) |
Add an external temperature measurement (2 bytes) to the LPP packet. The channel is defined by LPP_TEMPERATURE_CHANNEL_EXT
and is 0x12
.
[in] | b | The pointer to the LPP pointer. |
[in] | extTemp | The measured external temperature. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 466 of file lpp.c.
bool LPP_deprecated_AddIntTemp | ( | LPP_Buffer_t * | b, |
int16_t | intTemp | ||
) |
Add an internal temperature measurement (2 bytes) to the LPP packet. The channel is defined by LPP_TEMPERATURE_CHANNEL_INT
and is 0x11
.
[in] | b | The pointer to the LPP pointer. |
[in] | intTemp | The measured internal temperature. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 433 of file lpp.c.
bool LPP_deprecated_AddStatus | ( | LPP_Buffer_t * | b, |
uint8_t | status | ||
) |
Add a status value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_STATUS_CHANNEL
and is 0x15
.
[in] | b | The pointer to the LPP pointer. |
[in] | status | The status value. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 560 of file lpp.c.
bool LPP_deprecated_AddStormDetected | ( | LPP_Buffer_t * | b, |
uint8_t | stormDetected | ||
) |
Add a storm value to the LPP packet, disguised as a Digital Input packet (1 byte). The channel is defined by LPP_STORM_CHANNEL
and is 0x13
.
[in] | b | The pointer to the LPP pointer. |
[in] | stormDetected | If a storm is detected using the accelerometer or not. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 498 of file lpp.c.
bool LPP_deprecated_AddVBAT | ( | LPP_Buffer_t * | b, |
int16_t | vbat | ||
) |
Add a battery voltage measurement to the LPP packet, disguised as an Analog Input packet (2 bytes). The channel is defined by LPP_VBAT_CHANNEL
and is 0x10
.
[in] | b | The pointer to the LPP pointer. |
[in] | vbat | The measured battery voltage. |
true
- Successfully added the data to the LoRaWAN packet. false
- Couldn't add the data to the LoRaWAN packet. Definition at line 400 of file lpp.c.
void LPP_FreeBuffer | ( | LPP_Buffer_t * | b | ) |
Definition at line 129 of file lpp.c.
bool LPP_InitBuffer | ( | LPP_Buffer_t * | b, |
uint8_t | size | ||
) |
Definition at line 84 of file lpp.c.