Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of d7a_1x by
include/d7a_alp.h
- Committer:
- Jeej
- Date:
- 2016-09-23
- Revision:
- 59:b42eae56b51b
- Parent:
- 58:38a366236bda
- Child:
- 63:afd046faedb0
File content as of revision 59:b42eae56b51b:
#ifndef _D7A_ALP_H_ #define _D7A_ALP_H_ #define ALP_CTRL_GROUP 0x80 #define ALP_CTRL_RESP 0x40 #define ALP_CTRL_OVERLOAD 0x80 #define ALP_CTRL_INDIRECT 0x40 #define ALP_CTRL_EOP 0x80 #define ALP_CTRL_ERR 0x40 typedef enum { // OPCODE | OPERAND ALP_OPCODE_NOP = 0, //| - ALP_OPCODE_F_RD_DATA = 1, //| FDR ALP_OPCODE_F_RD_PROP = 2, //| FID ALP_OPCODE_F_WR_DATA = 4, //| FD ALP_OPCODE_F_WR_FLUSH = 5, //| FD ALP_OPCODE_F_WR_PROP = 6, //| FD ALP_OPCODE_QUERY = 8, //| Q ALP_OPCODE_QBREAK = 9, //| Q ALP_OPCODE_PERM_REQ = 10, //| P ALP_OPCODE_CRC_CHECK = 11, //| Q ALP_OPCODE_F_EXIST = 16, //| FID ALP_OPCODE_F_CREATE = 17, //| FD ALP_OPCODE_F_DELETE = 18, //| FID ALP_OPCODE_F_RESTORE = 19, //| FID ALP_OPCODE_F_FLUSH = 20, //| FID ALP_OPCODE_F_OPEN = 21, //| FID ALP_OPCODE_F_CLOSE = 22, //| FID ALP_OPCODE_F_COPY = 23, //| 2xFID ALP_OPCODE_F_EXECUTE = 31, //| FID ALP_OPCODE_RSP_F_DATA = 32, //| FD ALP_OPCODE_RSP_F_PROP = 33, //| FH ALP_OPCODE_RSP_STATUS = 34, //| S ALP_OPCODE_RSP_ISTATUS = ALP_OPCODE_RSP_STATUS + (1 << 6), //| SI ALP_OPCODE_RSP_TAG = 35, //| PID ALP_OPCODE_RSP_EOPTAG = ALP_OPCODE_RSP_TAG + (2 << 6), //| PID ALP_OPCODE_RSP_ERRTAG = ALP_OPCODE_RSP_TAG + (1 << 6), //| PID ALP_OPCODE_CHUNK = 48, //| - ALP_OPCODE_LOGIC = 49, //| - ALP_OPCODE_FORWARD = 50, //| I ALP_OPCODE_IFORWARD = 51, //| IFID ALP_OPCODE_TAG = 52, //| PID ALP_OPCODE_EXT = 63, //| RFU // Modifiers ALP_OPCODE_RESP = 0x40, ALP_OPCODE_GROUP = 0x80, ALP_OPCODE_ERR = 0x40, ALP_OPCODE_EOP = 0x80, ALP_OPCODE_INDIRECT = 0x40, ALP_OPCODE_OVERLOAD = 0x80, } alp_opcodes_t; typedef enum { ALP_RESP_TYPE_UNKNOWN = 0, ALP_RESP_TYPE_F_DATA = ALP_OPCODE_RSP_F_DATA, ALP_RESP_TYPE_F_PROP = ALP_OPCODE_RSP_F_PROP, ALP_RESP_TYPE_ISTATUS = ALP_OPCODE_RSP_ISTATUS, ALP_RESP_TYPE_STATUS = ALP_OPCODE_RSP_STATUS, ALP_RESP_TYPE_TAG = ALP_OPCODE_RSP_TAG, } alp_resp_type_t; // ======================================================================= // d7a_resp_t // ----------------------------------------------------------------------- // Enumerator of the D7ASP Response types // ======================================================================= typedef enum { // No response requested D7A_RESP_NO = 0, // Get all responses in response period D7A_RESP_ALL, // Get at least one acknowledgement per request during response period D7A_RESP_ANY, // RFU D7A_RESP_RFU_1, // No response requested, repeat 3 times D7A_RESP_NO_RPT, // Get all responses in response period, only Responders having not received packets respond D7A_RESP_ON_ERR, // Get at least one acknowledgement per request during response period. // Stick to a single responder when possible D7A_RESP_PREFERRED, // RFU D7A_RESP_RFU_2, } d7a_resp_t; typedef struct { uint8_t type; uint8_t* data; // data union { struct { uint32_t length; uint32_t offset; uint8_t fid; } f_data; struct { uint32_t length; uint32_t offset; uint8_t fid; } f_prop; struct { uint8_t code; uint8_t id; // Action ID } status; struct { uint32_t length; uint8_t type; } itf; struct { uint8_t id; uint8_t eop; uint8_t err; } tag; } meta; } alp_uns_resp_parsed_t; TYPEDEF_STRUCT_PACKED { uint8_t aid; int8_t status; } d7a_alp_rsp_status_t; #define NO_TAG (-1) TYPEDEF_STRUCT_PACKED { int16_t tag; bool eop; d7a_msg_t* msg; } d7a_alp_rsp_t; // ======================================================================= // d7a_ctf_t // ----------------------------------------------------------------------- // DLL compressed time format // ======================================================================= typedef union { // bit access fields struct { // Mantissa uint8_t mant : 5; // Exponent uint8_t exp : 3; } bf; // byte access uint8_t byte; } d7a_ctf_t; // ======================================================================= // d7a_qos_t // ----------------------------------------------------------------------- // Bitfield structure of the D7ASP Quality of Service control byte // ======================================================================= typedef union { // bit access fields struct { // Response mode uint8_t resp : 3; // Retry mode uint8_t retry : 3; // Responder has to keep the ACK template (TPL status file) uint8_t record : 1; // Stop D7ASP on not acknowledged request uint8_t stop_on_err : 1; } bf; // byte access uint8_t byte; } d7a_qos_t; // ======================================================================= // d7a_sp_cfg_t // ----------------------------------------------------------------------- // Structure of the D7ASP Configuration // ======================================================================= TYPEDEF_STRUCT_PACKED { // D7ASP QoS d7a_qos_t qos; // Dormant Timeout (0, no timeout) d7a_ctf_t dorm_to; // Addressee d7a_addressee_t addressee; } d7a_sp_cfg_t; // ======================================================================= // alp_d7a_itf_t // ----------------------------------------------------------------------- // ALP/D7A Interface file TODO:should be in alp_d7a.h when/if it exists // but not in alp.h as it requires D7A // ==================================================================== TYPEDEF_STRUCT_PACKED { uint8_t type; d7a_sp_cfg_t cfg; } alp_d7a_itf_t; // ======================================================================= // d7a_ch_header_t // ----------------------------------------------------------------------- /// Bitfield structure of the channel identifier // ======================================================================= typedef union { // bit access fields struct { /// Coding scheme uint8_t cs : 2; /// Channel Class uint8_t cl : 2; /// Channel Band uint8_t band : 3; /// RFU uint8_t rfu : 1; } bf; // byte access uint8_t byte; } d7a_ch_header_t; // ======================================================================= // d7a_sp_status_t // ----------------------------------------------------------------------- /// Bitfield structure of the D7ASP segment status byte // ======================================================================= typedef union { // bit access fields struct { /// RFU uint8_t rfu : 4; /// Identifier type of the received segment uint8_t idf : 2; /// Current seqnum was already received uint8_t retry : 1; /// There are not received seqnums anterior to the current seqnum uint8_t missed : 1; } bf; // byte access uint8_t byte; } d7a_sp_status_t; // ======================================================================= // d7a_nwl_security_t // ----------------------------------------------------------------------- /// NWL Security File structure // ======================================================================= TYPEDEF_STRUCT_PACKED { /// Key counter uint8_t key_counter; /// Frame counter uint32_t frame_counter; } d7a_nwl_security_t; // ======================================================================= // d7a_sp_res_t // ----------------------------------------------------------------------- /// D7A specific segment metadata // ======================================================================= TYPEDEF_STRUCT_PACKED { /// channel header d7a_ch_header_t header; /// channel index uint16_t idx; /// RSSI in -dBm int8_t rxlev; /// Link budget in dB int8_t lb; /// Target RXLEV in -dBm int8_t target_rxlev; /// D7ASP status d7a_sp_status_t status; /// D7ASP Token uint8_t token; /// D7ASP Sequence number uint8_t seq; /// Response timeout uint32_t resp_to; /// Addressee d7a_addressee_t addressee; /// NLS security state (optional) d7a_nwl_security_t nls_state; } d7a_sp_res_t; d7a_errors_t d7a_alp_open(UnsolicitedMsgFunction uns_msg); d7a_errors_t d7a_alp_close(void); void d7a_alp_new_pkt(d7a_com_rx_msg_t* pkt); d7a_com_rx_msg_t* d7a_alp_wait_pkt(uint32_t millisec = osWaitForever); void d7a_alp_free_msg(d7a_msg_t* msg); d7a_msg_t** d7a_alp_write_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, const uint8_t* const buf, d7a_addressee_t* addressee = NULL, uint8_t retry = 0, bool resp = true); d7a_msg_t** d7a_alp_read_file(const uint8_t file_id, const uint32_t offset, const uint32_t size, d7a_addressee_t* addressee = NULL, uint8_t retry = 0); #endif // _D7A_ALP_H_