zep.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2016 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
21 #include <stdint.h>
22 
23 #include "byteorder.h"
24 #include "net/ntp_packet.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #define ZEP_PORT_DEFAULT (17754)
35 #define ZEP_V2_TYPE_DATA (1)
36 
40 #define ZEP_V2_TYPE_ACK (2)
41 
45 #define ZEP_LENGTH_MASK (0x7f)
46 
50 typedef struct __attribute__((packed)) {
51  char preamble[2];
52  uint8_t version;
53 } zep_hdr_t;
54 
59 typedef struct __attribute__((packed)) {
61  uint8_t chan;
63  uint8_t lqi_mode;
64  uint8_t lqi_val;
65  uint8_t resv[7];
66  uint8_t length;
67 } zep_v1_hdr_t;
68 
73 typedef struct __attribute__((packed)) {
75  uint8_t type;
76  uint8_t chan;
78  uint8_t lqi_mode;
79  uint8_t lqi_val;
82  uint8_t resv[10];
83  uint8_t length;
85 
90 typedef struct __attribute__((packed)) {
92  uint8_t type;
95 
96 #ifdef __cplusplus
97 }
98 #endif
99 
Functions to work with different byte orders.
NTP packet definitions.
NTP timestamp.
Definition: ntp_packet.h:71
ZEP header definition.
Definition: zep.h:50
uint8_t version
Protocol Version (must be 1 or 2)
Definition: zep.h:52
ZEPv1 header definition.
Definition: zep.h:59
uint8_t lqi_mode
CRC/LQI Mode (0: append LQI to frame, 1: append FCS)
Definition: zep.h:63
uint8_t lqi_val
LQI value.
Definition: zep.h:64
network_uint16_t dev
device ID
Definition: zep.h:62
zep_hdr_t hdr
common header fields
Definition: zep.h:60
uint8_t chan
channel ID
Definition: zep.h:61
uint8_t length
length of the frame
Definition: zep.h:66
ZEPv2 header definition (type == Ack)
Definition: zep.h:90
network_uint32_t seq
Sequence number.
Definition: zep.h:93
zep_hdr_t hdr
common header fields
Definition: zep.h:91
uint8_t type
type (must be ZEP_V2_TYPE_ACK)
Definition: zep.h:92
ZEPv2 header definition (type == Data)
Definition: zep.h:73
ntp_timestamp_t time
NTP timestamp.
Definition: zep.h:80
uint8_t chan
channel ID
Definition: zep.h:76
zep_hdr_t hdr
common header fields
Definition: zep.h:74
uint8_t type
type (must be ZEP_V2_TYPE_DATA)
Definition: zep.h:75
uint8_t lqi_val
LQI value.
Definition: zep.h:79
network_uint16_t dev
device ID
Definition: zep.h:77
uint8_t length
length of the frame
Definition: zep.h:83
network_uint32_t seq
Sequence number.
Definition: zep.h:81
uint8_t lqi_mode
CRC/LQI Mode.
Definition: zep.h:78
A 16 bit integer in big endian aka network byte order.
Definition: byteorder.h:70
A 32 bit integer in big endian aka network byte order.
Definition: byteorder.h:80