Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion microSWIFT_V2.2/Core/Components/Inc/iridium.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Created on: Oct 28, 2022
* Author: Phil
*/
// clang-format off

#ifndef SRC_IRIDIUM_H_
#define SRC_IRIDIUM_H_
Expand Down Expand Up @@ -46,7 +47,6 @@
#define SBDD_RESPONSE_SIZE 20U
#define SBDIX_WAIT_TIME ONE_SECOND * 13U
#define ERROR_MESSAGE_TYPE 99U
#define IRIDIUM_CHECKSUM_LENGTH sizeof(iridium_checksum_t)
#define IRIDIUM_MAX_RESPONSE_SIZE 64U
#define IRIDIUM_DEFAULT_BAUD_RATE 19200U
#define CHECKSUM_FIRST_BYTE_INDEX 327U
Expand Down
65 changes: 62 additions & 3 deletions microSWIFT_V2.2/Core/Inc/sbd.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Created on: Sep 18, 2024
* Author: philbush
*/
// clang-format off

#ifndef INC_SBD_H_
#define INC_SBD_H_
Expand All @@ -12,7 +13,6 @@
#include "NEDWaves/rtwhalf.h"
#define TYPE_99_CHAR_BUF_LEN 320
#define IRIDIUM_SBD_MAX_LENGTH 340
#define IRIDIUM_SBD_OVERHEAD_BYTES 2
#define TELEMETRY_FIELD_ERROR_CODE (0x70E2)

// @formatter:off
Expand All @@ -22,6 +22,7 @@ typedef struct
uint8_t checksum_a;
uint8_t checksum_b;
} iridium_checksum_t;
#define IRIDIUM_CHECKSUM_LENGTH sizeof(iridium_checksum_t)

// Primary message type for wave dynamic measurements
typedef struct __packed
Expand Down Expand Up @@ -64,7 +65,7 @@ typedef struct __packed
uint16_t ambient_avgs[17];
} sbd_message_type_53_element;

#define TURBIDITY_MSGS_PER_SBD ((IRIDIUM_SBD_MAX_LENGTH - IRIDIUM_SBD_OVERHEAD_BYTES) / sizeof(sbd_message_type_53_element))
#define TURBIDITY_MSGS_PER_SBD ((IRIDIUM_SBD_MAX_LENGTH - IRIDIUM_CHECKSUM_LENGTH) / sizeof(sbd_message_type_53_element))

// Definition for the SBD message with multiple sample windows
typedef struct __packed
Expand Down Expand Up @@ -102,7 +103,7 @@ typedef struct __packed
uint16_t avg_nir;
} sbd_message_type_54_element;

#define LIGHT_MSGS_PER_SBD ((IRIDIUM_SBD_MAX_LENGTH - IRIDIUM_SBD_OVERHEAD_BYTES) / sizeof(sbd_message_type_54_element))
#define LIGHT_MSGS_PER_SBD ((IRIDIUM_SBD_MAX_LENGTH - IRIDIUM_CHECKSUM_LENGTH) / sizeof(sbd_message_type_54_element))

// Definition for the SBD message with multiple sample windows
typedef struct __packed
Expand All @@ -115,6 +116,64 @@ typedef struct __packed
iridium_checksum_t checksum;
} sbd_message_type_54;

// Definition for accelerometer waves message; based heavily on type_52 for the
// waves component.
typedef struct __packed
{
char legacy_number_7; // byte 0
uint8_t type; // byte 1

// I'm hoping we can omit this, otherwise will have to find 3 bytes elsewhere
// uint8_t port;
// uint16_t size;

uint32_t timestamp; // byte 2-5

float latitude; // byte 6-9
float longitude; // byte 10-13

// bit 0-1: sensitivity (+/- 2, 4, 8g) == {00, 01, 10}
// bit 2: == 0 for low-rate spectra; == 1 for high-rate
// bit 3: ==0 for background/duty-cycle; == 1 for wake-on-shake
// bit 4-7: threshold for wake-on-shake; TODO: define how this translates to counts
uint8_t config; // byte 14
// bit 0-3: count of wake-on-shake events since last duty cycle
// bit 4-7: TBD
uint8_t status; // byte 15

uint16_t min_x_accel; // byte 16-21
uint16_t max_x_accel;
uint16_t mean_x_accel;

uint16_t min_y_accel; // byte 22-27
uint16_t max_y_accel;
uint16_t mean_y_accel;

uint16_t min_z_accel; // byte 28-33
uint16_t max_z_accel;
uint16_t mean_z_accel;

// at 34 bytes here...

// the Waves component is 204 bytes
real16_T Hs;
real16_T Tp;
real16_T Dp;
real16_T E_array[42];
real16_T f_min;
real16_T f_max;
signed char a1_array[42];
signed char b1_array[42];
signed char a2_array[42];
signed char b2_array[42];
unsigned char cf_array[42];

// 2 bytes for the checksum; this MUST be the final element in the struct,
// since the iridium thread calculates the checksum and calls memcpy on
// payload[sizeof(sbd_message_type_55) - IRIDIUM_CHECKSUM_LENGTH]
iridium_checksum_t checksum;
} sbd_message_type_55;

typedef struct
{
char message_body[TYPE_99_CHAR_BUF_LEN];
Expand Down