Skip to content

Commit

Permalink
move to integrity package
Browse files Browse the repository at this point in the history
  • Loading branch information
notoriaga committed Dec 12, 2022
1 parent 3445390 commit 0e72dc0
Show file tree
Hide file tree
Showing 39 changed files with 1,787 additions and 110 deletions.
1 change: 0 additions & 1 deletion c/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ swift_cc_library(
"src/v4/sbas.c",
"src/v4/settings.c",
"src/v4/signing.c",
"src/v4/skylark.c",
"src/v4/solution_meta.c",
"src/v4/ssr.c",
"src/v4/system.c",
Expand Down
1 change: 0 additions & 1 deletion c/include/libsbp/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <libsbp/v4/sbp_msg.h>
#include <libsbp/v4/settings.h>
#include <libsbp/v4/signing.h>
#include <libsbp/v4/skylark.h>
#include <libsbp/v4/solution_meta.h>
#include <libsbp/v4/ssr.h>
#include <libsbp/v4/system.h>
Expand Down
25 changes: 25 additions & 0 deletions c/include/libsbp/integrity_macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,4 +294,29 @@
*/
#define SBP_MSG_SSR_FLAG_IONO_GRID_POINT_SAT_LOS_ENCODED_OVERHEAD 17u

#define SBP_MSG_ACKNOWLEDGE 0x0BD2
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_MASK (0xffu)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_SHIFT (0u)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_GET(flags) \
((u8)((u8)((flags) >> SBP_ACKNOWLEDGE_RESPONSE_CODE_SHIFT) & \
SBP_ACKNOWLEDGE_RESPONSE_CODE_MASK))
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_SET(flags, val) \
do { \
(flags) = (u8)((flags & (~(SBP_ACKNOWLEDGE_RESPONSE_CODE_MASK \
<< SBP_ACKNOWLEDGE_RESPONSE_CODE_SHIFT))) | \
(((val) & (SBP_ACKNOWLEDGE_RESPONSE_CODE_MASK)) \
<< (SBP_ACKNOWLEDGE_RESPONSE_CODE_SHIFT))); \
} while (0)

#define SBP_ACKNOWLEDGE_RESPONSE_CODE_OK (0)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_OUT_OF_COVERAGE (1)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_FORBIDDEN (2)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_INVALID_REQUEST (3)
#define SBP_ACKNOWLEDGE_RESPONSE_CODE_INVALID_AREA_ID (4)
/**
* Encoded length of sbp_msg_acknowledge_t (V4 API) and
* msg_acknowledge_t (legacy API)
*/
#define SBP_MSG_ACKNOWLEDGE_ENCODED_LEN 11u

#endif /* LIBSBP_INTEGRITY_MACROS_H */
13 changes: 6 additions & 7 deletions c/include/libsbp/legacy/cpp/message_traits.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <libsbp/legacy/sbas.h>
#include <libsbp/legacy/settings.h>
#include <libsbp/legacy/signing.h>
#include <libsbp/legacy/skylark.h>
#include <libsbp/legacy/solution_meta.h>
#include <libsbp/legacy/ssr.h>
#include <libsbp/legacy/system.h>
Expand Down Expand Up @@ -1137,6 +1136,12 @@ struct MessageTraits<msg_ssr_flag_iono_grid_point_sat_los_t> {
};


template<>
struct MessageTraits<msg_acknowledge_t> {
static constexpr u16 id = 3026;
};


template<>
struct MessageTraits<msg_ed25519_signature_dep_t> {
static constexpr u16 id = 3073;
Expand All @@ -1155,12 +1160,6 @@ struct MessageTraits<msg_ed25519_signature_t> {
};


template<>
struct MessageTraits<msg_acknowledge_t> {
static constexpr u16 id = 4000;
};


template<>
struct MessageTraits<msg_fileio_config_req_t> {
static constexpr u16 id = 4097;
Expand Down
18 changes: 18 additions & 0 deletions c/include/libsbp/legacy/integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,24 @@ typedef struct SBP_ATTR_PACKED {
sv_id_t faulty_los[0]; /**< List of faulty LOS */
} msg_ssr_flag_iono_grid_point_sat_los_t;

typedef struct SBP_ATTR_PACKED {
u8 request_id; /**< Echo of the request ID field from the
corresponding CRA message, or 255 if
no request ID was provided. */
u32 area_id; /**< Echo of the Area ID field from the
corresponding CRA message. */
u8 response_code; /**< Reported status of the request. */
u16 correction_mask_on_demand; /**< Contains the message group(s) that
will be sent in response from the
corresponding CRA correction mask. An
echo of the correction mask field
from the corresponding CRA message. */
u16 correction_mask_stream; /**< For future expansion. Always set to
0. */
u8 solution_id; /**< The solution ID of the instance
providing the corrections. */
} msg_acknowledge_t;

/** \} */

SBP_PACK_END
Expand Down
1 change: 0 additions & 1 deletion c/include/libsbp/sbp_msg_type.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include <libsbp/sbas_macros.h>
#include <libsbp/settings_macros.h>
#include <libsbp/signing_macros.h>
#include <libsbp/skylark_macros.h>
#include <libsbp/solution_meta_macros.h>
#include <libsbp/ssr_macros.h>
#include <libsbp/system_macros.h>
Expand Down
1 change: 1 addition & 0 deletions c/include/libsbp/v4/integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#ifndef LIBSBP_V4_INTEGRITY_MESSAGES_H
#define LIBSBP_V4_INTEGRITY_MESSAGES_H
#include <libsbp/v4/integrity/IntegritySSRHeader.h>
#include <libsbp/v4/integrity/MSG_ACKNOWLEDGE.h>
#include <libsbp/v4/integrity/MSG_SSR_FLAG_HIGH_LEVEL.h>
#include <libsbp/v4/integrity/MSG_SSR_FLAG_IONO_GRID_POINTS.h>
#include <libsbp/v4/integrity/MSG_SSR_FLAG_IONO_GRID_POINT_SAT_LOS.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
*/

/*****************************************************************************
* Automatically generated from yaml/swiftnav/sbp/skylark.yaml
* Automatically generated from yaml/swiftnav/sbp/integrity.yaml
* with generate.py. Please do not hand edit!
*****************************************************************************/

#ifndef LIBSBP_V4_SKYLARK_MSG_ACKNOWLEDGE_H
#define LIBSBP_V4_SKYLARK_MSG_ACKNOWLEDGE_H
#ifndef LIBSBP_V4_INTEGRITY_MSG_ACKNOWLEDGE_H
#define LIBSBP_V4_INTEGRITY_MSG_ACKNOWLEDGE_H

#include <math.h>
#include <stdarg.h>
Expand All @@ -26,7 +26,7 @@
#include <string.h>

#include <libsbp/common.h>
#include <libsbp/skylark_macros.h>
#include <libsbp/integrity_macros.h>
#include <libsbp/v4/string/sbp_string.h>

#ifdef __cplusplus
Expand Down Expand Up @@ -199,4 +199,4 @@ static inline bool operator>=(const sbp_msg_acknowledge_t &lhs,

#endif // ifdef __cplusplus

#endif /* LIBSBP_V4_SKYLARK_MSG_ACKNOWLEDGE_H */
#endif /* LIBSBP_V4_INTEGRITY_MSG_ACKNOWLEDGE_H */
1 change: 0 additions & 1 deletion c/include/libsbp/v4/sbp_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
#include <libsbp/v4/sbas.h>
#include <libsbp/v4/settings.h>
#include <libsbp/v4/signing.h>
#include <libsbp/v4/skylark.h>
#include <libsbp/v4/solution_meta.h>
#include <libsbp/v4/ssr.h>
#include <libsbp/v4/system.h>
Expand Down
20 changes: 20 additions & 0 deletions c/src/include/libsbp/internal/v4/integrity.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,26 @@ bool sbp_msg_ssr_flag_iono_grid_point_sat_los_encode_internal(
bool sbp_msg_ssr_flag_iono_grid_point_sat_los_decode_internal(
sbp_decode_ctx_t *ctx, sbp_msg_ssr_flag_iono_grid_point_sat_los_t *msg);

/**
* Internal function to encode an SBP type to a buffer
*
* @param ctx Encode context
* @param msg SBP type instance
* @return true on success, false otherwise
*/
bool sbp_msg_acknowledge_encode_internal(sbp_encode_ctx_t *ctx,
const sbp_msg_acknowledge_t *msg);

/**
* Internal function to decode an SBP type from a buffer
*
* @param ctx Decode context
* @param msg SBP type instance
* @return true on success, false otherwise
*/
bool sbp_msg_acknowledge_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_acknowledge_t *msg);

#ifdef __cplusplus
}
#endif
Expand Down
127 changes: 127 additions & 0 deletions c/src/v4/integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,3 +956,130 @@ int sbp_msg_ssr_flag_iono_grid_point_sat_los_cmp(
}
return ret;
}

bool sbp_msg_acknowledge_encode_internal(sbp_encode_ctx_t *ctx,
const sbp_msg_acknowledge_t *msg) {
if (!sbp_u8_encode(ctx, &msg->request_id)) {
return false;
}
if (!sbp_u32_encode(ctx, &msg->area_id)) {
return false;
}
if (!sbp_u8_encode(ctx, &msg->response_code)) {
return false;
}
if (!sbp_u16_encode(ctx, &msg->correction_mask_on_demand)) {
return false;
}
if (!sbp_u16_encode(ctx, &msg->correction_mask_stream)) {
return false;
}
if (!sbp_u8_encode(ctx, &msg->solution_id)) {
return false;
}
return true;
}

s8 sbp_msg_acknowledge_encode(uint8_t *buf, uint8_t len, uint8_t *n_written,
const sbp_msg_acknowledge_t *msg) {
sbp_encode_ctx_t ctx;
ctx.buf = buf;
ctx.buf_len = len;
ctx.offset = 0;
if (!sbp_msg_acknowledge_encode_internal(&ctx, msg)) {
return SBP_ENCODE_ERROR;
}
if (n_written != NULL) {
*n_written = (uint8_t)ctx.offset;
}
return SBP_OK;
}

bool sbp_msg_acknowledge_decode_internal(sbp_decode_ctx_t *ctx,
sbp_msg_acknowledge_t *msg) {
if (!sbp_u8_decode(ctx, &msg->request_id)) {
return false;
}
if (!sbp_u32_decode(ctx, &msg->area_id)) {
return false;
}
if (!sbp_u8_decode(ctx, &msg->response_code)) {
return false;
}
if (!sbp_u16_decode(ctx, &msg->correction_mask_on_demand)) {
return false;
}
if (!sbp_u16_decode(ctx, &msg->correction_mask_stream)) {
return false;
}
if (!sbp_u8_decode(ctx, &msg->solution_id)) {
return false;
}
return true;
}

s8 sbp_msg_acknowledge_decode(const uint8_t *buf, uint8_t len, uint8_t *n_read,
sbp_msg_acknowledge_t *msg) {
sbp_decode_ctx_t ctx;
ctx.buf = buf;
ctx.buf_len = len;
ctx.offset = 0;
if (!sbp_msg_acknowledge_decode_internal(&ctx, msg)) {
return SBP_DECODE_ERROR;
}
if (n_read != NULL) {
*n_read = (uint8_t)ctx.offset;
}
return SBP_OK;
}

s8 sbp_msg_acknowledge_send(sbp_state_t *s, u16 sender_id,
const sbp_msg_acknowledge_t *msg,
sbp_write_fn_t write) {
uint8_t payload[SBP_MAX_PAYLOAD_LEN];
uint8_t payload_len;
s8 ret =
sbp_msg_acknowledge_encode(payload, sizeof(payload), &payload_len, msg);
if (ret != SBP_OK) {
return ret;
}
return sbp_payload_send(s, SBP_MSG_ACKNOWLEDGE, sender_id, payload_len,
payload, write);
}

int sbp_msg_acknowledge_cmp(const sbp_msg_acknowledge_t *a,
const sbp_msg_acknowledge_t *b) {
int ret = 0;

ret = sbp_u8_cmp(&a->request_id, &b->request_id);
if (ret != 0) {
return ret;
}

ret = sbp_u32_cmp(&a->area_id, &b->area_id);
if (ret != 0) {
return ret;
}

ret = sbp_u8_cmp(&a->response_code, &b->response_code);
if (ret != 0) {
return ret;
}

ret =
sbp_u16_cmp(&a->correction_mask_on_demand, &b->correction_mask_on_demand);
if (ret != 0) {
return ret;
}

ret = sbp_u16_cmp(&a->correction_mask_stream, &b->correction_mask_stream);
if (ret != 0) {
return ret;
}

ret = sbp_u8_cmp(&a->solution_id, &b->solution_id);
if (ret != 0) {
return ret;
}
return ret;
}
Loading

0 comments on commit 0e72dc0

Please sign in to comment.