ot.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Fundacion Inria Chile
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #include "net/netopt.h"
60 #include "net/ieee802154.h"
61 #include "net/ethernet.h"
62 #include "net/netdev.h"
63 #include "thread.h"
64 #include "openthread/instance.h"
65 #include "event.h"
66 
72 #define OPENTHREAD_NUMBER_OF_SERIAL_BUFFER (1U)
74 #define OPENTHREAD_SIZEOF_LENGTH_AND_FREEBUFF (4U)
76 #define OPENTHREAD_SERIAL_BUFFER_SIZE OPENTHREAD_SIZEOF_LENGTH_AND_FREEBUFF + 100
78 #define OPENTHREAD_SERIAL_BUFFER__PAYLOAD_SIZE OPENTHREAD_SERIAL_BUFFER_SIZE - OPENTHREAD_SIZEOF_LENGTH_AND_FREEBUFF
80 #define OPENTHREAD_ERROR_NO_EMPTY_SERIAL_BUFFER -1
82 #define OPENTHREAD_SERIAL_BUFFER_STATUS_FREE (0x0001)
84 #define OPENTHREAD_SERIAL_BUFFER_STATUS_READY_TO_PROCESS (0x0002)
86 #define OPENTHREAD_SERIAL_BUFFER_STATUS_FULL (0x0004)
88 #define IEEE802154_MAX_LENGTH (127U)
90 #define OPENTHREAD_NETDEV_BUFLEN (IEEE802154_MAX_LENGTH)
96 typedef struct {
97  uint16_t length;
100 } serial_msg_t;
101 
108 void recv_pkt(otInstance *aInstance, netdev_t *dev);
109 
117 void send_pkt(otInstance *aInstance, netdev_t *dev, netdev_event_t event);
118 
125 
131 otInstance* openthread_get_instance(void);
132 
137 
145 void openthread_radio_init(netdev_t *dev, uint8_t *tb, uint8_t *rb);
146 
159 int openthread_netdev_init(char *stack, int stacksize, char priority, const char *name, netdev_t *netdev);
160 
164 void ot_random_init(void);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
Definitions low-level network driver interface.
Definitions for Ethernet.
netdev_event_t
Possible event types that are send from the device driver to the upper layer.
Definition: netdev.h:234
void send_pkt(otInstance *aInstance, netdev_t *dev, netdev_event_t event)
Inform OpenThread when tx is finished.
void openthread_bootstrap(void)
Bootstrap OpenThread.
void ot_random_init(void)
Init OpenThread random.
otInstance * openthread_get_instance(void)
Get pointer to the OpenThread instance.
#define OPENTHREAD_SERIAL_BUFFER__PAYLOAD_SIZE
sizeof the spinel payload data
Definition: ot.h:78
void openthread_radio_init(netdev_t *dev, uint8_t *tb, uint8_t *rb)
Init OpenThread radio.
event_queue_t * openthread_get_evq(void)
Get OpenThread event queue.
int openthread_netdev_init(char *stack, int stacksize, char priority, const char *name, netdev_t *netdev)
Starts OpenThread thread.
void recv_pkt(otInstance *aInstance, netdev_t *dev)
Gets packet from driver and tells OpenThread about the reception.
Definition of global configuration options.
event queue structure
Definition: event.h:153
event structure
Definition: event.h:145
Structure to hold driver state.
Definition: netdev.h:365
Struct containing a serial message.
Definition: ot.h:96
uint16_t serial_buffer_status
status of the buffer
Definition: ot.h:98
uint16_t length
length of the message
Definition: ot.h:97
IEEE 802.15.4 header definitions.