Digi XBee(R) ANSI C Host Library
discovery.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2012 Digi International Inc.,
3  * All rights not expressly granted are reserved.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
7  * You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
10  * =======================================================================
11  */
12 
70 #ifndef XBEE_DISCOVERY_H
71 #define XBEE_DISCOVERY_H
72 
73 #include "xbee/platform.h"
74 #include "xbee/device.h"
75 #include "wpan/types.h"
76 
78 
80 #define XBEE_DISC_MAX_NODEID_LEN 20
81 
82 typedef XBEE_PACKED(xbee_node_id1_t, {
83  uint16_t network_addr_be;
84  addr64 ieee_addr_be;
85  char node_info[XBEE_DISC_MAX_NODEID_LEN + 1];
88 
89 // data following variable-length node info
90 typedef XBEE_PACKED(xbee_node_id2_t, {
91  uint16_t parent_addr_be;
92 
93  uint8_t device_type;
94  #define XBEE_ND_DEVICE_TYPE_COORD 0
95  #define XBEE_ND_DEVICE_TYPE_ROUTER 1
96  #define XBEE_ND_DEVICE_TYPE_ENDDEV 2
97 
98  uint8_t source_event;
99  #define XBEE_ND_SOURCE_EVENT_NONE 0
100  #define XBEE_ND_SOURCE_EVENT_PUSHBUTTON 1
101  #define XBEE_ND_SOURCE_EVENT_JOINED 2
102  #define XBEE_ND_SOURCE_EVENT_POWER_CYCLE 3
103 
104  uint16_t profile_be;
105  uint16_t manufacturer_be;
106 
108  uint32_t device_id_be;
109 
111  uint8_t rssi;
113 
115 typedef XBEE_PACKED(xbee_frame_node_id_t, {
116  uint8_t frame_type;
117  addr64 ieee_address_be;
118  uint16_t network_address_be;
119  uint8_t options;
121  xbee_node_id1_t node_data;
122  // an xbee_node_id2_t follows the variable-length xbee_node_id1_t
124 
126 typedef struct xbee_node_id_t {
135 
149 int xbee_disc_nd_parse( xbee_node_id_t FAR *parsed, const void FAR *source,
150  int source_length);
151 
158 void xbee_disc_node_id_dump( const xbee_node_id_t FAR *ni);
159 
173 
196  void FAR *context);
197 
200 #define XBEE_DISC_DIGI_DATA_CLUSTER_ENTRY \
201  { DIGI_CLUST_NODEID_MESSAGE, xbee_disc_nodeid_cluster_handler, NULL, \
202  WPAN_CLUST_FLAG_INPUT | WPAN_CLUST_FLAG_NOT_ZCL}
203 
222 int xbee_disc_atnd_response_handler( xbee_dev_t *xbee, const void FAR *raw,
223  uint16_t length, void FAR *context);
224 
226 #define XBEE_FRAME_HANDLE_ATND_RESPONSE \
227  { XBEE_FRAME_LOCAL_AT_RESPONSE, 0, xbee_disc_atnd_response_handler, NULL }
228 
250 int xbee_disc_nodeid_frame_handler(xbee_dev_t *xbee, const void FAR *raw,
251  uint16_t length, void FAR *context);
252 
255 #define XBEE_FRAME_HANDLE_AO0_NODEID \
256  { XBEE_FRAME_NODE_ID, 0, xbee_disc_nodeid_frame_handler, NULL }
257 
272 
288 
306 int xbee_disc_discover_nodes( xbee_dev_t *xbee, const char *identifier);
307 
309 
310 // If compiling in Dynamic C, automatically #use the appropriate C file.
311 #ifdef __DC__
312  #use "xbee_discovery.c"
313 #endif
314 
315 #endif
316 
unsigned long uint32_t
32-bit unsigned integer
Definition: platform_config.h:43
WPAN datatypes and support functions, valid for ZigBee and DigiMesh.
#define FAR
On platforms with "far" pointers, define to the proper keyword; empty definition if not required...
Definition: platform.h:396
uint16_t parent_addr
ATMP.
Definition: discovery.h:129
#define XBEE_BEGIN_DECLS
Macro defined to.
Definition: platform.h:41
Common header for Hardware Abstraction Layer.
int xbee_disc_remove_node_id_handler(xbee_dev_t *xbee, xbee_disc_node_id_fn fn)
Remove a function registered to receive parsed Node ID messages on a given XBee device.
Definition: xbee_discovery.c:142
void(* xbee_disc_node_id_fn)(struct xbee_dev_t *xbee, const struct xbee_node_id_t *rec)
Function to process parsed Node ID messages.
Definition: device.h:294
int xbee_disc_nodeid_cluster_handler(const wpan_envelope_t FAR *envelope, void FAR *context)
Process messages sent to the Node ID Message cluster (0x0095) of the Digi Data endpoint (0xE8) when A...
Definition: xbee_discovery.c:200
char node_info[XBEE_DISC_MAX_NODEID_LEN+1]
ATNI value (variable length, null-terminated)
Definition: discovery.h:133
format of 0x95 frames received from XBee
Definition: discovery.h:123
int xbee_disc_nd_parse(xbee_node_id_t FAR *parsed, const void FAR *source, int source_length)
Parse a Node Discovery response and store it in an xbee_node_id_t structure.
Definition: xbee_discovery.c:39
void xbee_disc_node_id_dump(const xbee_node_id_t FAR *ni)
Debugging function used to dump an xbee_node_id_t structure to stdout.
Definition: xbee_discovery.c:105
int xbee_disc_discover_nodes(xbee_dev_t *xbee, const char *identifier)
Send an ATND command to the XBee, initiating node discovery for all nodes or a specific node's "node ...
Definition: xbee_discovery.c:280
int xbee_disc_add_node_id_handler(xbee_dev_t *xbee, xbee_disc_node_id_fn fn)
Designate a function to receive parsed Node ID messages on a given XBee device.
Definition: xbee_discovery.c:122
int xbee_disc_atnd_response_handler(xbee_dev_t *xbee, const void FAR *raw, uint16_t length, void FAR *context)
Process AT Command Response frames (type 0x88), looking for ATND responses to parse and pass to Node ...
Definition: xbee_discovery.c:220
#define XBEE_DISC_MAX_NODEID_LEN
Maximum length of a Node ID string (ATNI value) (excludes null terminator).
Definition: discovery.h:80
int xbee_disc_nodeid_frame_handler(xbee_dev_t *xbee, const void FAR *raw, uint16_t length, void FAR *context)
Process Node Identification frames (type 0x95), sent when ATAO = 0.
Definition: xbee_discovery.c:260
unsigned short uint16_t
16-bit unsigned integer
Definition: platform_config.h:41
addr64 ieee_addr_be
ATSH and ATSL.
Definition: discovery.h:127
unsigned char uint8_t
8-bit unsigned integer
Definition: platform_config.h:39
< ATMP value [0xFFFE on DigiMesh]
Definition: discovery.h:112
parsed Node ID in host-byte-order and fixed length fields
Definition: discovery.h:126
Typedef used to hold a 64-bit IEEE address, represented as 8 bytes, 4 16-bit values or 2 32-bit value...
Definition: types.h:34
Definition: device.h:361
uint16_t network_addr
ATMY value.
Definition: discovery.h:128
uint8_t device_type
one of XBEE_ND_DEVICE_TYPE_COORD, _ROUTER or _ENDDEV
Definition: discovery.h:131
#define XBEE_END_DECLS
Macro defined to.
Definition: platform.h:42
const char * xbee_disc_device_type_str(uint8_t device_type)
Return a string ("Coord", "Router", "EndDev", or "???") description for the "Device Type" field of a ...
Definition: xbee_discovery.c:89
The "envelope" is used to gather all necessary information about a given frame on the network...
Definition: aps.h:40
< ATMY value [0xFFFE on DigiMesh] ATSH and ATSL null-terminated ATNI value (variable length) ...
Definition: discovery.h:87