Xbee Arduino
Arduino Driver for Xbee
Loading...
Searching...
No Matches
xbee.h
Go to the documentation of this file.
1
36#ifndef XBEE_H
37#define XBEE_H
38
39#if defined(__cplusplus)
40extern "C"
41{
42#endif
43
44#include <stdint.h>
45#include <stdbool.h>
46#include <stdlib.h>
47#include "config.h"
48#include "port.h"
49
50// Abstract base class for XBee
51typedef struct XBee XBee;
52
63typedef struct {
64 bool (*init)(XBee* self, uint32_t baudrate, void* device);
65 bool (*connect)(XBee* self);
66 bool (*disconnect)(XBee* self);
67 uint8_t (*sendData)(XBee* self, const void* data);
68 bool (*softReset)(XBee* self);
69 void (*hardReset)(XBee* self);
70 void (*process)(XBee* self);
71 bool (*connected)(XBee* self);
72 void (*handleRxPacketFrame)(XBee* self, void *frame);
73 void (*handleTransmitStatusFrame)(XBee* self, void *frame);
75
76
87typedef struct {
88 int (*PortUartRead)(uint8_t *buffer, int length);
89 int (*PortUartWrite)(const uint8_t *buf, uint16_t len);
90 uint32_t (*PortMillis)(void);
91 void (*PortFlushRx)(void);
92 int (*PortUartInit)(uint32_t baudrate, void *device);
93 void (*PortDelay)(uint32_t ms);
95
106typedef struct {
107 void (*OnReceiveCallback)(XBee* self, void * data);
108 void (*OnConnectCallback)(XBee* self);
109 void (*OnDisconnectCallback)(XBee* self);
110 void (*OnSendCallback)(XBee* self, void * data);
111} XBeeCTable;
112
121struct XBee {
122 // Add common XBee attributes here
126 uint8_t frameIdCntr;
129
130};
131
132// Interface functions to call the methods
133bool XBeeInit(XBee* self, uint32_t baudrate, void* device);
134bool XBeeConnect(XBee* self);
135bool XBeeDisconnect(XBee* self);
136uint8_t XBeeSendData(XBee* self, const void*);
137bool XBeeSoftReset(XBee* self);
138void XBeeHardReset(XBee* self);
139void XBeeProcess(XBee* self);
140bool XBeeConnected(XBee* self);
141bool XBeeWriteConfig(XBee* self);
142bool XBeeApplyChanges(XBee* self);
143bool XBeeSetAPIOptions(XBee* self, const uint8_t value);
144
145#if defined(__cplusplus)
146}
147#endif
148
149#endif // XBEE_H
Define library configurations.
Platform-specific abstraction layer for hardware interfaces.
Definition: xbee.h:106
Definition: xbee.h:87
Definition: xbee.h:121
uint8_t frameIdCntr
Definition: xbee.h:126
const XBeeCTable * ctable
Definition: xbee.h:125
const XBeeHTable * htable
Definition: xbee.h:124
const XBeeVTable * vtable
Definition: xbee.h:123
bool txStatusReceived
Flag to indicate if TX Status frame was received.
Definition: xbee.h:127
uint8_t deliveryStatus
Stores the delivery status of the transmitted frame.
Definition: xbee.h:128
Definition: xbee.h:63
bool XBeeInit(XBee *self, uint32_t baudrate, void *device)
Initializes the XBee module.
Definition: xbee.c:53
bool XBeeConnect(XBee *self)
Connects the XBee to the network.
Definition: xbee.c:68
void XBeeProcess(XBee *self)
Calls the XBee subclass's process implementation.
Definition: xbee.c:142
bool XBeeDisconnect(XBee *self)
Disconnects the XBee from the network.
Definition: xbee.c:82
bool XBeeApplyChanges(XBee *self)
Sends the ATAC command to apply pending configuration changes on the XBee module.
Definition: xbee.c:195
bool XBeeSoftReset(XBee *self)
Performs a soft reset of the XBee module.
Definition: xbee.c:111
bool XBeeConnected(XBee *self)
Checks if the XBee module is connected to the network.
Definition: xbee.c:157
bool XBeeSetAPIOptions(XBee *self, const uint8_t value)
Sends the AT_AO command to set API Options.
Definition: xbee.c:219
uint8_t XBeeSendData(XBee *self, const void *)
Request XBee to send data over network.
Definition: xbee.c:96
bool XBeeWriteConfig(XBee *self)
Sends the ATWR command to write the current configuration to the XBee module's non-volatile memory.
Definition: xbee.c:173
void XBeeHardReset(XBee *self)
Performs a hard reset of the XBee module.
Definition: xbee.c:126