ZB 10: Scan network
This program shows how to scan the XBee's network in order to find other XBee modules. This example prints all available data within the API structures

Required Materials

1 x Waspmote 1 x Battery 1 x MiniUSB wire 1 x XBee-ZigBee module

Notes

- The coordinator must be turned on - The battery has to be connected. - This example can be executed in Waspmote v12

Code

1
/*
2
* ------ [ZB_10] - scan network --------
3
*
4
* Explanation: This program shows how to scan the XBee's network
5
* in order to find other XBee modules. This example prints all
6
* available data within the API structures
7
*
8
* Copyright (C) 2015 Libelium Comunicaciones Distribuidas S.L.
9
* http://www.libelium.com
10
*
11
* This program is free software: you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation, either version 3 of the License, or
14
* (at your option) any later version.
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU General Public License for more details.
20
*
21
* You should have received a copy of the GNU General Public License
22
* along with this program. If not, see .
23
*
24
* Version: 0.2
25
* Design: David Gascón
26
* Implementation: Yuri Carmona
27
*/
28
29
#include <WaspXBeeZB.h>
30
31
32
void setup()
33
{
34
// init USB port
35
USB.ON();
36
USB.println(F("ZB_10 example"));
37
38
//////////////////////////
39
// 1. init XBee
40
//////////////////////////
41
xbeeZB.ON();
42
43
delay(3000);
44
45
//////////////////////////
46
// 2. check XBee's network parameters
47
//////////////////////////
48
checkNetworkParams();
49
50
}
51
52
void loop()
53
{
54
////////////////////////////////
55
// 3. scan network
56
////////////////////////////////
57
xbeeZB.scanNetwork();
58
59
////////////////////////////////
60
// 4. print info
61
////////////////////////////////
62
63
USB.print(F("\n\ntotalScannedBrothers:"));
64
USB.println(xbeeZB.totalScannedBrothers,DEC);
65
66
// print all scanned nodes information
67
printScanInfo();
68
69
}
70
71
72
/*
73
* printScanInfo
74
*
75
* This function prints all info related to the scan
76
* process given by the XBee module
77
*/
78
void printScanInfo()
79
{
80
USB.println(F("----------------------------"));
81
82
for(int i=0; i
Copied!

Output

1
E#
2
ZB_10 example
3
4
Joined a network!
5
operating 16-b PAN ID: ADFE
6
operating 64-b PAN ID: 1122334455667788
7
channel: 0B
8
9
10
totalScannedBrothers:2
11
----------------------------
12
MAC:0013A200408C9DBB
13
NI:1
14
Device Type:Coordinator
15
PMY:FFFE
16
PID:C105
17
MID:101E
18
----------------------------
19
MAC:0013A200408C9DB8
20
NI:
21
Device Type:Router
22
PMY:FFFE
23
PID:C105
24
MID:101E
25
----------------------------
Copied!
Last modified 2yr ago