Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: sample02_sw xbee_aging sample01_led sample04_sens
You are viewing an older revision! See the latest version
Homepage
XBee library 'ZB Coord API'
Sample Code 01 led¶
An XBee ZB Coordinator on a Nucleo Board controls LEDs on the other XBee ZB device.
sample
#include "xbee.h"
DigitalOut myled(LED1);
int main(){
byte dev_gpio[] = {0x00,0x13,0xA2,0x00,0x40,0x30,0xC1,0x6F};
// MAC Address of your remote XBee device
myled = 1; // NUCLEOのLEDをHレベル(3.3V)へ
xbee_init( 0 ); // XBee用COMポートの初期化
xbee_atnj( 0xFF ); // デバイスの参加を受け入れる
myled = 0; // NUCLEOのLEDをHレベル(3.3V)へ
while(1){ // 永久に受信する
myled = 1; // NUCLEOのLEDをHレベル(3.3V)へ
xbee_gpo(dev_gpio,11,1); // GPOポート11をHレベル(3.3V)へ
xbee_gpo(dev_gpio,12,1); // GPOポート12をHレベル(3.3V)へ
wait(1);
myled = 0; // NUCLEOのLEDをHレベル(3.3V)へ
xbee_gpo(dev_gpio,11,0); // GPOポート11をLレベル(0.0V)へ
xbee_gpo(dev_gpio,12,0); // GPOポート12をLレベル(0.0V)へ
wait(1);
}
}
http://mbed.org/users/bokunimowakaru/code/sample01_led/
Sample Code 02 sw¶
To push buttons (or switches) on an XBee ZB device report the conditions of input ports on it to a Nucleo board, and display them on a LCD.
#include "xbee.h"
#include "TextLCD.h"
TextLCD lcd(PA_9, PC_7, PB_5, PB_4, PB_10, PA_8); // rs, e, d4-d7
int main(){
byte data;
int i;
XBEE_RESULT xbee_result;
byte dev_gpio[] = {0x00,0x13,0xA2,0x00,0x40,0x30,0xC1,0x6F};
lcd.cls(); lcd.printf("Sample 2 SW");
xbee_init( 0x00 ); // XBee用COMポートの初期化(引数はポート番号)
lcd.cls(); lcd.printf("ATNJ");
xbee_atnj( 0xFF ); // デバイスを常に参加受け入れ(テスト用)
lcd.cls(); lcd.printf("gpio init");
xbee_gpio_init(dev_gpio); // デバイスdev_gpioにIO設定を行うための送信
lcd.cls(); lcd.printf("DONE");
while(1){ // 永久に受信する
data = xbee_rx_call( &xbee_result );
if( xbee_result.MODE == MODE_GPIN){ // PIO入力(リモート機のボタンが押された)の時
lcd.cls();
for( i=7; i>=0 ; i--) lcd.printf( "%c",(char)( (int)'0' + ((data>>i) & 0x01) ) );
// dataに入った値をバイナリで表示
}
}
}
http://mbed.org/users/bokunimowakaru/code/sample02_sw/
Sample Code 04 sens¶
Measured results of an XBee wireless sensor device are displayed a LCD on Nucleo board with an XBee coordinator which is in API mode.