Path: blob/master/libraries/AP_ADSB/sagetech-sdk/sgEncodeDataReq.c
9688 views
/**1* @copyright Copyright (c) 2021 Sagetech, Inc. All rights reserved.2*3* @file sgEncodeDataReq.c4* @author Jacob.Garrison5*6* @date Feb 23, 20217*8* This file receives a populated data request struct and9* converts it into a data request message buffer.10*/1112#include <stdbool.h>13#include <stdlib.h>1415#include "sg.h"16#include "sgUtil.h"1718#define SG_PAYLOAD_LEN_DATAREQ SG_MSG_LEN_DATAREQ - 5 /// the payload length.1920#define PBASE 4 /// the payload offset.2122#define OFFSET_REQ_TYPE 0 /// the requested response message type23#define OFFSET_RSVD_1 1 /// a reserved field24#define OFFSET_RSVD_2 2 /// a reserved field25#define OFFSET_RSVD_3 3 /// a reserved field2627/*28* Documented in the header file.29*/30bool sgEncodeDataReq(uint8_t *buffer, sg_datareq_t *data, uint8_t msgId)31{32// populate header33buffer[0] = SG_MSG_START_BYTE;34buffer[1] = SG_MSG_TYPE_HOST_DATAREQ;35buffer[2] = msgId;36buffer[3] = SG_PAYLOAD_LEN_DATAREQ;3738// populate Request Type39buffer[PBASE + OFFSET_REQ_TYPE] = data->reqType;4041// populate Reserved fields42buffer[PBASE + OFFSET_RSVD_1] = 0;43buffer[PBASE + OFFSET_RSVD_2] = 0;44buffer[PBASE + OFFSET_RSVD_3] = 0;4546// populate checksum47appendChecksum(buffer, SG_MSG_LEN_DATAREQ);4849return true;50}515253