Path: blob/master/libraries/AP_ADSB/sagetech-sdk/sgEncodeFlightId.c
9710 views
/**1* @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved.2*3* @file sgEncodeFlightId.c4* @author Jacob.Garrison5*6* @date Feb 25, 20217*8*/910#include <ctype.h>11#include <stdbool.h>12#include <stdlib.h>1314#include "sg.h"15#include "sgUtil.h"1617#define SG_PAYLOAD_LEN_FLIGHT SG_MSG_LEN_FLIGHT - 5 /// the payload length.1819#define PBASE 4 /// the payload offset.20#define OFFSET_ID 0 /// the flight id offset in the payload.21#define OFFSET_RSVD 8 /// the reserved field offset in the payload.2223#define ID_LEN 8 /// the length of the flight identification field.2425/*26* Documented in the header file.27*/28bool sgEncodeFlightId(uint8_t *buffer, sg_flightid_t *id, uint8_t msgId)29{30// populate header31buffer[0] = SG_MSG_START_BYTE;32buffer[1] = SG_MSG_TYPE_HOST_FLIGHT;33buffer[2] = msgId;34buffer[3] = SG_PAYLOAD_LEN_FLIGHT;3536// populate flight identification37charArray2Buf(&buffer[PBASE + OFFSET_ID], id->flightId, ID_LEN);3839// populate reserved field40uint322Buf(&buffer[PBASE + OFFSET_RSVD], 0);4142// populate checksum43appendChecksum(buffer, SG_MSG_LEN_FLIGHT);4445return true;46}474849