Search Notebooks
XBee-mbed - XBee APIモードライブラリ

api, digimesh, Wi-Fi, xbee, zigbee

Page owner: user Suga koubou

Created 22 Nov 2010.
Last updated 21 Nov 2011

XBee-mbed - XBee APIモードライブラリ

Page last updated 21 Nov 2011, by   user Suga koubou   tag api, digimesh, Wi-Fi, xbee, zigbee | 0 replies      

XBee-mbed library

This library has been ported from the XBee-Arduino..

for Series 1, Series 2 (and DigiMesh)

AP=2 API ENABLE (use escape characters)

アナログ値取得、バグ修正済み

※ XBee Wi-Fi 対応関数実装
※ Wi-Fi 拡張作業中

blockdiagram

	+--------+             +--------+
	|        |3.3V------VCC|1       |
	|        |             |        |
	|        |RX-------DOUT|2  XBee |
	|        |TX--------DIN|3       |
	|        |     or      |    or  |
	|        |SCK------SCLK|18      |
	|  mbed  |CS-------SSEL|17 XBee |
	|        |MOSI-----MOSI|11 Wi-Fi|
	|        |MISO-----MISO|4   SPI |
	|        |INT------ATTN|13 mode |
	|        |             |        |
	|        |GND-------GND|10      |
	+--------+             +--------+

※ SPI: XBee Wi-Fi は X-CTUであらかじめ設定しておくほか、DOUT をLowに保ったまま電源を入れると、AP・D2・D3・D4・D9・P2 がSPI用に自動的に設定される。初期化が終わると ATTN がアサート(Low)される。

Documents

Download

» Import this library into a programXBee

XBee-mbed library http://mbed.org/users/okini3939/notebook/xbee-mbed/

Sample

リモートのXBeeのポートに取り付けたLEDを点滅させる。

» Import this programXBee_sample

XBee-mbed sample

sample

#include "mbed.h"
#include "XBee.h"

XBee xbee(p13, p14);

int main() {
    uint8_t Cmd[] = {'D', '4'};
    uint8_t Val[] = {0x04};
    XBeeAddress64 remoteAddress(0x0013A200, 0x40319F25);
    RemoteAtCommandRequest remoteAtRequest;

    wait(1);
    xbee.begin(9800);

    remoteAtRequest = RemoteAtCommandRequest(remoteAddress, Cmd, Low, sizeof(Low));
    remoteAtRequest.setApplyChanges(true);

    remoteAtRequest.setCommandValue(Val);
    remoteAtRequest.setCommandValueLength(sizeof(Val));
    xbee.send(remoteAtRequest);
}

XBeeをAPIモードで使う (by Todotani) 電波強度(RSSI)の取得と、リモートのADC入力の実例

» Import this programXBeeApi_RemoteCommand

Sample program for XBee remote API operation. This program get ADC sample data from remote XBee connected over the radio

要旨

sample

XBee xbee(p13, p14); // 宣言

void main () {
    AtCommandResponse local = AtCommandResponse();
    RemoteAtCommandResponse remote = RemoteAtCommandResponse();
      :
    while (1) {
          :
        xbee.readPacket();
        if (xbee.getResponse().isAvailable()) {
            // XBeeより読み込み
            switch (xbee.getResponse().getApiId()) {
            case AT_COMMAND_RESPONSE:
                xbee.getResponse().getAtCommandResponse(local);
                if (local.getStatus() == AT_OK) {
                    // ローカルATコマンド、レスポンスの処理
                }
                break;
            case REMOTE_AT_COMMAND_RESPONSE:
                xbee.getResponse().getRemoteAtCommandResponse(remote);
                if (remote.getStatus() == AT_OK) {
                    // リモートATコマンド、レスポンスの処理
                }
                break;
            case ZB_RX_RESPONSE:
                xbee.getResponse().getZBRxResponse(rx);
                if (rx.getOption() == ZB_PACKET_ACKNOWLEDGED) {
                    // データパケット受信の処理
                }
              :
            }
        }
          :
    }
}

Original

XBee-mbed は XBee-Arduino ライブラリからの移植です。

through the serial mbed to xbee

mbed の PCシリアル=UART 経由で X-CTU による設定も可能。

Code

#include "mbed.h"

Serial pc(USBTX, USBRX); // tx, rx
Serial xbee(p13, p14); // tx, rx

int main() {

    pc.printf("begin\r");

    for (;;) {
        if (pc.readable()) xbee.putc(pc.getc());
        if (xbee.readable()) pc.putc(xbee.getc());
    }
}

USB serial (mbed) <- -> P13, P14 (XBee)

mbeduino platform - mbed用マザーボード(ベースボード)

Can use the X-CTU.

Note

Acknowledge


戻る (back)


02 Dec 2010
mbedでXBを使ってみたかったので非常に助かりました。
05 Dec 2010 . Edited: 05 Dec 2010

As it is issue of original Arduino library, I encountered the bug described in the following thread. For e.g,if you use AD3 disabling AD0-2, you don't get correct ADC value. So, I modified code in my local environments.

Problem with uint16_t ZBRxIoSampleResponse::getAnalog
07 Jan 2011
user Ken Todotani wrote:

As it is issue of original Arduino library, I encountered the bug described in the following thread. For e.g,if you use AD3 disabling AD0-2, you don't get correct ADC value. So, I modified code in my local environments.

Problem with uint16_t ZBRxIoSampleResponse::getAnalog

Thank you for your report.
I
changed this source.

Please login to post comments.