ax25.h
Go to the documentation of this file.
1 /*
2  * KubOS Core Flight Services
3  * Copyright (C) 2015 Kubos Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
32 #ifndef AX25_H
33 #define AX25_H
34 
35 #include <stdint.h>
36 #include "kubos-core/k_buffer.h"
37 
38 #ifndef AX25_BUFFER_SIZE
39 #define AX25_BUFFER_SIZE 255
40 #endif
41 
42 #define AX25_CHAR(c) ((char) ((c) << 1))
43 #define AX25_ADDR_NOCALL { .callsign = { \
44  AX25_CHAR('N'), AX25_CHAR('0'), AX25_CHAR('C'), AX25_CHAR('A'), \
45  AX25_CHAR('L'), AX25_CHAR('L') }, .ssid = AX25_CHAR('0') }
46 
47 #define AX25_UI_CONTROL 0x03
48 #define AX25_UI_PROTOCOL 0xF0
49 
50 typedef struct ax25_addr_s {
51  char callsign[6];
52  char ssid;
53 } ax25_addr_t;
54 
64 ax25_addr_t ax25_addr_init(char *addr);
65 
69 void ax25_print_addr(char *prefix, ax25_addr_t addr);
70 
72  uint8_t addrs_len, uint8_t ctrl,
73  uint8_t protocol);
74 
75 
76 #define ax25_ui_pkt_build(info, addrs, addrs_len) \
77  ax25_pkt_build(info, addrs, addrs_len, AX25_UI_CONTROL, \
78  AX25_UI_PROTOCOL)
79 #endif
80 
81 /* @} */
k_buffer_t * ax25_pkt_build(k_buffer_t *info, ax25_addr_t *addrs, uint8_t addrs_len, uint8_t ctrl, uint8_t protocol)
char callsign[6]
Definition: ax25.h:51
ax25_addr_t ax25_addr_init(char *addr)
Turn an ASCII encoded callsign / SSID into the 7-bit encoded and space padded 7 byte address that is ...
Messaging Buffer Wrapper.
char ssid
Definition: ax25.h:52
Definition: ax25.h:50
void ax25_print_addr(char *prefix, ax25_addr_t addr)
Prints an AX.25 address using printf with the passed in prefix.
Definition: k_buffer.h:43
struct ax25_addr_s ax25_addr_t