arrow-left

All pages
gitbookPowered by GitBook
1 of 1

Loading...

Status

status.h and status.c files define status structs and form in which firmware parameters are stored and periodically sent via LoRa and as BLE advertisement.

hashtag
Status form

Status can consit of several building blocks, defined by FW and tracker type. Each building block is a byte array, where each byte reperesents a values as defined in governing status structre.

Total status cannot exceed 24 - DEVICE_NAME_LEN bytes, as this is the maximum length of BLE advertisment packet. Currently max length is set to 19 bytes.

hashtag
Main status

Main building block is defined by statusData_t struct:

that can be compressed in byte array by

Individual values are defined as:

  • reset_cause - TBD

  • system_functions_errors - TBD

  • battery = (battery_mV - 2500)/10

Total length of main status part is 9 bytes.

hashtag
LR status

If #define STATUS_LR is enabled, additional LR chip status block is added.

where:

  • satellites - nr. of satellites used in last LR fix

  • last_fix - TBD

Total length of LR buildning block is 2 bytes.

hashtag
UBLOX status

If #define STATUS_UBLOX is enabled, additional UBLOX chip status block is added.

where:

  • lat - latitude defined as:

    • lat[0] = (lat+90)*1000 >> 16

    • lat[1] = (lat+90)*1000 >> 8

Total length of UBLOX status is 8 bytes.

hashtag
Functions

hashtag
Get status

To obtain new status message for either BLE advertisement or LR status send, int get_status_message(uint8_t *message, uint8_t max_len) function updates all values with int update_status_message(bool lr_status, bool ublox_status) function and returns message length.

max_len can be passed as an argument, as maximal length of message depends on the send format. If status message is too long, only max_len message will be returned.

charging_voltage - TBD

  • temperature - TBD

  • uptime - uptime in hours, with 255 turnaround

  • acc_x - abs(acc_x*10)

  • acc_y - abs(acc_y*10)

  • acc_z - abs(acc_z*10)

  • lat[2] = (lat+90)*1000

  • lon - longitude defined as:

    • lon[0] = (lat+180)*1000 >> 16

    • lon[1] = (lat+180)*1000 >> 8

    • lat[2] = (lat+180)*1000

  • time - TBD

  • typedef struct {
        uint8_t reset_cause;
        uint8_t system_functions_errors;
        uint8_t battery;
        uint8_t charging_voltage;
        uint8_t temperature;
        uint8_t uptime;
        uint8_t acc_x;
        uint8_t acc_y;
        uint8_t acc_z;
    }__attribute__((packed)) statusData_t;
    typedef union statusPacket_t {
      statusData_t data;
      uint8_t bytes[sizeof(statusData_t)];
    } statusPacket_t;
    typedef struct {
        uint8_t satellites;
        uint8_t last_fix;
    }__attribute__((packed)) statusDataLR_t;
    
    typedef union statusPacketLR_t{
      statusDataLR_t data;
      uint8_t bytes[sizeof(statusDataLR_t)];
    } statusPacketLR_t;
    typedef struct {
        uint8_t lat[3];
        uint8_t lon[3];
        uint8_t time[2];
    }__attribute__((packed)) statusDataUblox_t;
    
    typedef union statusPacketUblox_t{
      statusDataUblox_t data;
      uint8_t bytes[sizeof(statusDataUblox_t)];
    } statusPacketUblox_t;