xbee_api

Xbee API operaiton library

Author Sebastien Lelong, Copyright © 2012, all rights reserved.
Adapted-by
Compiler 2.4o

Description

access Xbee in API mode


Sources

mainly inspired by http://code.google.com/p/xbee-arduino/


Notes

Xbee series 2 only


Dependencies

No dependency found



Summary

Global variables/contants

Procedures

Private

Functions

Private

API details

Global variables/contants

Procedures

  • xbee_req_payload'put(byte in data)

    Write a byte in request payload, increasing position for next call. There's
    no check whether position remains in payload. See xbee_res_payload'get for
    more.
    

  • print_xbee_response()

    No documentation found

  • xbee_send_byte(byte in b, bit in escape)

    internally used, send a byte through Xbee carrier, honoring escape setting
    

  • xbee_receive()

    Wrapper around xbee_read_packet. It actually calls it several time until
    it actually receives a XBEE_ZB_RX_RESPONSE (api_id). This is useful when
    several messages are exchanged between coordinator or router, as, for
    instance, coordinator may reply with a tx_status, then a rx response during
    communication. tx_status are kind of administrative message, while "rx"
    response are the one you may only interested in. If so, use this procedure,
    once called you'll a xbee_res "rx" response containing expecting data
    (hopefully)...
    

  • xbee_write_packet()

    send xbee_req request. xbee_req must be fill in first before
    calling this procedure. See xbee_req record definition.
    

  • xbee_send()

    Send a request and read tx_status response. If delivery failed, try again
    (until if works...)
    

  • xbee_read_packet()

    Read a full packet, fill in xbee_res response. This may be a blocking call
    as underlying data carrier may block until data is read (typically when
    serial_hw_data is involved here).
    Once called, you may check xbee_res.error_code = 0 to make sure everything
    if fine. You may also check xbee_res.api_id value (see constants at the
    beginning) to know what lind of response it is (rx, tx_status, etc...)
    

  • xbee_init()

    must be called once lib is included
    

Private

Functions

  • xbee_req_get_frame_data(byte in pos) return byte

    return data byte contained in request according to a give index position
    

  • xbee_res_payload'get() return byte

    read one byte from response's payload. Each time it's called, position in
    payload is increased ready to get next byte. There's no check whether
    position is within payload, so be carefull and check how many time you call
    it according to XBEE_PAYLOAD_SIZE.
    (this is somewhat by design, because payload is a buffer, reserved space and
    the actual data of interest, contained in this buffer, may vary so only the
    caller knows how many bytes she wants to get from it).
    

  • xbee_req_get_frame_data_length() return byte

    No documentation found

Private

Related samples

Here are the list of samples which use this library:

18f27j5318f27j53_xbee_api_rx.jal
18f27j5318f27j53_xbee_api_tx.jal