#include <WaspXBeeCore.h>


Public Member Functions | |
| WaspXBeeCore () | |
| class constructor | |
| void | init (uint8_t protocol_used, uint8_t frequency, uint8_t model_used) |
| It initializes the necessary variables. | |
| uint8_t | getOwnMacLow () |
| It gets the own lower 32b MAC. | |
| uint8_t | getOwnMacHigh () |
| It gets the own higher 32b MAC. | |
| uint8_t | getOwnMac () |
| It gets the own MAC. | |
| uint8_t | setOwnNetAddress (uint8_t NA_H, uint8_t NA_L) |
| It sets the own 16b Network Address. | |
| uint8_t | getOwnNetAddress () |
| It gets the 16b Network Address. | |
| uint8_t | setBaudrate (uint8_t baud_rate) |
| It sets the baudrate. | |
| uint8_t | setAPI (uint8_t api_value) |
| It sets API enabled or disabled. | |
| uint8_t | setAPIoptions (uint8_t api_options) |
| It sets API options. | |
| uint8_t | setPAN (uint8_t *PANID) |
| It sets the PAN ID. | |
| uint8_t | getPAN () |
| It gets the PAN ID. | |
| uint8_t | setSleepMode (uint8_t sleep) |
| It sets the sleep mode. | |
| uint8_t | getSleepMode () |
| It gets the sleep mode. | |
| uint8_t | setAwakeTime (uint8_t *awake) |
| It sets the time awake before sleeping. | |
| uint8_t | setSleepTime (uint8_t *sleep) |
| It sets time the module is slept. | |
| uint8_t | setChannel (uint8_t _channel) |
| It sets the channel frequency where module is working on. | |
| uint8_t | getChannel () |
| It gets the channel frequency where module is working on. | |
| uint8_t | setNodeIdentifier (char *node) |
| It sets the Node Identifier. | |
| uint8_t | getNodeIdentifier () |
| It gets the Node Identifier. | |
| uint8_t | scanNetwork () |
| It scans for brothers in the same channel and same PAN ID. | |
| uint8_t | scanNetwork (char *node) |
| It scans for a brother in the same channel and same PAN ID. | |
| uint8_t | setScanningTime (uint8_t *time) |
| It sets the time the Node Discovery is scanning. | |
| uint8_t | getScanningTime () |
| It gets the time the Node Discovery is scanning. | |
| uint8_t | setDiscoveryOptions (uint8_t options) |
| It sets the options for the network discovery command. | |
| uint8_t | getDiscoveryOptions () |
| It gets the options for the network discovery command. | |
| uint8_t | nodeSearch (char *node, struct packetXBee *paq) |
| It performs a quick search of a specific node. Depending on the XBee module it stores different information. | |
| uint8_t | setScanningChannels (uint8_t channel_H, uint8_t channel_L) |
| It sets the list of channels to scan when performing an energy scan. | |
| uint8_t | getScanningChannels () |
| It gets the list of channels to scan when performing an energy scan. | |
| uint8_t | setDurationEnergyChannels (uint8_t duration) |
| It sets the time the Energy Scan will be performed. | |
| uint8_t | getDurationEnergyChannels () |
| It gets the time the Energy Scan will be performed. | |
| uint8_t | setLinkKey (char *key) |
| It sets the link key to use in the 128b AES algorithm. | |
| uint8_t | encryptionMode (uint8_t mode) |
| It sets the encryption mode ON/OFF. | |
| uint8_t | setPowerLevel (uint8_t value) |
| It sets the power level at which RF module transmits. | |
| uint8_t | getRSSI () |
| It gets the Received Signal Strength Indicator. | |
| uint8_t | getHardVersion () |
| It gets the Hardware Version. | |
| uint8_t | getSoftVersion () |
| It gets the Software Version. | |
| uint8_t | setRSSItime (uint8_t time) |
| It sets the RSSI time. | |
| uint8_t | getRSSItime () |
| It gets the RSSI time. | |
| uint8_t | writeValues () |
| It writes the parameters changed into non-volatil memory, being applied when the XBee is set OFF. | |
| uint8_t | applyChanges () |
| It writes the parameters changed into non-volatil memory and applies them immediately. | |
| uint8_t | reset () |
| It resets the XBee firmware. | |
| uint8_t | resetDefaults () |
| It resets the XBee parameters to factory defaults. | |
| uint8_t | setSleepOptions (uint8_t soption) |
| It sets the sleep options. | |
| uint8_t | getSleepOptions () |
| It gets the sleep options. | |
| uint8_t | sendXBee (struct packetXBee *packet) |
| It sends a packet to others XBee modules. | |
| int8_t | send (uint8_t *address, char *data) |
| It sends a packet to others XBee modules. | |
| int8_t | send (char *address, char *data) |
| It sends a packet to others XBee modules. | |
| int8_t | treatData () |
| It treats the data from XBee UART. | |
| uint8_t | freeXBee () |
| It frees the outcoming data buffer in the XBee. | |
| uint8_t | synchronization (struct packetXBee *paq) |
| It synchronizes two nodes in a PAN. | |
| uint8_t | sendCommandAT (char *atcommand) |
| The user introduces an AT command within a string and the function executes it without knowing its meaning. | |
| uint8_t | ON () |
| It connects XBee, activating switch and opens the UART. | |
| uint8_t | OFF () |
| It disconnects XBee, switching it off and closing the UART. | |
| uint8_t | sleep () |
| It sets the XBee to sleep, asserting PIN 9. | |
| uint8_t | wake () |
| It wakes up the XBee, de-asserting PIN 9. | |
| uint8_t | setDestinationParams (packetXBee *paq, uint8_t *address, char *data, uint8_t type, uint8_t off_type) |
| It sets the destination parameters, such as the receiver address and the data to send. | |
| uint8_t | setDestinationParams (packetXBee *paq, uint8_t *address, int data, uint8_t type, uint8_t off_type) |
| It sets the destination parameters, such as the receiver address and the data to send. | |
| uint8_t | setDestinationParams (packetXBee *paq, char *address, char *data, uint8_t type, uint8_t off_type) |
| It sets the destination parameters, such as the receiver address and the data to send. | |
| uint8_t | setDestinationParams (packetXBee *paq, char *address, int data, uint8_t type, uint8_t off_type) |
| It sets the destination parameters, such as the receiver address and the data to send. | |
| uint8_t | setOriginParams (packetXBee *paq, uint8_t type) |
| It sets the origin parameters, such as the sender address. | |
| uint8_t | setOriginParams (packetXBee *paq, char *address, uint8_t type) |
| It sets the origin parameters, such as the sender address. | |
| void | clearCommand () |
| It clears the variable 'command'. | |
Data Fields | |
| uint8_t | XBee_ON |
| Variable : it stores if the XBee module is ON or OFF (0-1). | |
| uint8_t | sourceMacLow [4] |
| Variable : 32b Lower Mac Source. | |
| uint8_t | sourceMacHigh [4] |
| Variable : 32b Higher Mac Source. | |
| uint8_t | sourceNA [2] |
| Variable : 16b Network Address. | |
| uint8_t | baudrate |
| Variable : Baudrate, speed used to communicate with the XBee module (0-5). | |
| uint8_t | apiValue |
| Variable : Api value selected (0-2). | |
| uint8_t | PAN_ID [8] |
| Variable : 64b PAN ID. | |
| uint8_t | sleepMode |
| Variable : Current Sleep Mode (0-5). | |
| matrix * | packet_fragments [MAX_FINISH_PACKETS][MAX_FRAG_PACKETS] |
| Variable : bidimensional array for storing the received fragments. | |
| uint8_t | totalFragmentsReceived |
| Variable : the number of fragments received. | |
| index * | pendingFragments [MAX_FINISH_PACKETS] |
| Variable : array for storing the information related with each global packet, being able to order the different fragments. | |
| uint8_t | pendingPackets |
| Variable : number of packets pending of being treated. | |
| packetXBee * | packet_finished [MAX_FINISH_PACKETS] |
| Variable : array for storing the packets received completely. | |
| uint8_t | totalPacketsReceived |
| Variable : real number of complete received packets. | |
| uint8_t | pos |
| Variable : indicates the position in 'packet_finished' array of each packet. | |
| Node | scannedBrothers [MAX_BROTHERS] |
| Variable : array for storing the information answered by the nodes when a Node Discovery is performe. | |
| int8_t | totalScannedBrothers |
| Variable : number of brothers found. | |
| uint8_t | awakeTime [3] |
| Variable : time to be idle before start sleeping. | |
| uint8_t | sleepTime [3] |
| Variable : Cyclic sleeping time. | |
| uint8_t | channel |
| Variable : Channel frequency where the module is currently working on. | |
| char | nodeID [20] |
| Variable : Node Identifier. | |
| uint8_t | scanTime [2] |
| Variable : time meanwhile the Node Discovery is scanning. | |
| uint8_t | discoveryOptions |
| Variable : options for the network discovery command. | |
| uint8_t | scanChannels [2] |
| Variable : list of channels to scan when performing an energy scan. | |
| uint8_t | energyChannel [20] |
| Variable : energy found on each channel. | |
| uint8_t | timeEnergyChannel |
| Variable : time the Energy Scan is going to be performed. | |
| char | linkKey [16] |
| Variable : 128b AES Link key. | |
| uint8_t | encryptMode |
| Variable : encryption mode (ON/OFF) (0-1). | |
| uint8_t | powerLevel |
| Variable : power level at which the RF transmits. | |
| uint8_t | timeRSSI |
| Variable : time meanwhile the PWM output is active after receiving a packet. | |
| uint8_t | softVersion [2] |
| Variable : software Version. | |
| uint8_t | hardVersion [2] |
| Variable : hardware Version. | |
| uint8_t | valueRSSI [2] |
| Variable : received Signal Strength Indicator. | |
| uint8_t | sleepOptions |
| Variable : sleep Options. | |
| uint8_t | hops |
| Variable : max number of hops a packet can travel. | |
| uint8_t | commandAT [100] |
| Variable : Answer received after executing "sendCommandAT" function. | |
| uint8_t | modem_status |
| Variable : It stores the last Modem Status indication received. | |
| uint8_t | replacementPolicy |
| Variable : It specifies the replacement ploicty to implement (FIFO, LIFO or OUT). | |
| int8_t | error_AT |
| Variable : It stores if the last call to an AT command has generated an error. | |
| int8_t | error_RX |
| Variable : It stores if the last received packet has generated an error. | |
| int8_t | error_TX |
| Variable : It stores if the last sent packet has generated an error. | |
Protected Member Functions | |
| int8_t | readXBee (uint8_t *data) |
| It reads a packet from other XBee module. | |
| uint8_t | sendXBeePriv (struct packetXBee *packet) |
| It sends a packet to other XBee modules. | |
| void | gen_data (const char *data, uint8_t param) |
| It generates the API frame to send to the XBee module. | |
| void | gen_data (const char *data) |
| It generates the API frame to send to the XBee module. | |
| void | gen_data (const char *data, uint8_t param1, uint8_t param2) |
| It generates the API frame to send to the XBee module. | |
| void | gen_data (const char *data, uint8_t *param) |
| It generates the API frame to send to the XBee module. | |
| void | gen_data (const char *data, char *param) |
| It generates the API frame to send to the XBee module. | |
| uint8_t | gen_checksum (const char *data) |
| It generates the checksum API frame to send to the XBee module. | |
| uint8_t | gen_send (const char *data) |
| It sends the API frame stored in 'command' variable to the XBee module. | |
| void | gen_frame (struct packetXBee *_packet, uint8_t *TX_array, uint8_t start_pos) |
| It generates the API frame when a TX is done. | |
| void | gen_frame_ap2 (struct packetXBee *_packet, uint8_t *TX_array, uint8_t &protect, uint8_t type) |
| It generates the frame using eschaped characters. | |
| int8_t | parse_message (uint8_t *frame) |
| It parses the answer received by the XBee module, calling the appropriate function. | |
| void | des_esc (uint8_t *data_in, uint16_t end, uint16_t start) |
| It generates the correct API frame from an eschaped one. | |
| uint8_t | atCommandResponse (uint8_t *data_in, uint8_t *frame, uint16_t end, uint16_t start) |
| It parses the AT command answer received by the XBee module. | |
| uint8_t | modemStatusResponse (uint8_t *data_in, uint16_t end, uint16_t start) |
| It parses the Modem Status message received by the XBee module. | |
| uint8_t | txStatusResponse (uint8_t *ByteIN) |
| It parses the TX Status message received by the XBee module. | |
| uint8_t | txZBStatusResponse (uint8_t *ByteIN) |
| It parses the ZB TX Status message received by the XBee module. | |
| int8_t | rxData (uint8_t *data_in, uint16_t end, uint16_t start) |
| It parses the RX Data message received by the XBee module. | |
| void | treatScan () |
| It parses the ND message received by the XBee module. | |
| uint8_t | checkChecksum (uint8_t *data_in, uint16_t end, uint16_t start) |
| It checks the checksum is good. | |
| void | freeIndex () |
| It frees a position in index array. | |
| void | freeAll () |
| It frees index array and matrix. | |
| uint8_t | getFinishIndex () |
| It gets the next index where store the finished packet. | |
| void | clearFinishArray () |
| It clears the finished packets array. | |
| uint8_t | getIndexFIFO () |
| It gets the index in 'packet_finished' where store the new packet, according to a FIFO policy. | |
| uint8_t | getIndexLIFO () |
| It gets the index in 'packet_finished' where store the new packet, according to a LIFO policy. | |
| void | freeIndexMatrix (uint8_t position) |
| It frees the index array and the matrix row corresponding to the position is sent as an input parameter. | |
Protected Attributes | |
| uint8_t | protocol |
| Variable : protocol used (depends on de the XBee module). | |
| uint8_t | freq |
| Variable : frequency used (depends on de the XBee module). | |
| uint8_t | model |
| Variable : model used (depends on de the XBee module). | |
| uint16_t | data_length |
| Variable : internal variable used to store the data length. | |
| uint8_t | data [50] |
| Variable : it stores the data received in each frame. | |
| uint16_t | it |
| Variable : internal counter. | |
| uint16_t | start |
| Variable : byte for starting getting the data. | |
| uint16_t | finish |
| Variable : byte for stopping getting the data. | |
| uint8_t | add_type |
| Variable : address type. | |
| uint8_t | mode |
| Variable : sending mode. | |
| uint16_t | frag_length |
| Variable : fragment length. | |
| long | TIME1 |
| Variable : time used to manage timeouts. | |
| uint8_t | command [30] |
| Variable : array to store the AT commands. | |
| uint16_t | data_ind |
| Variable : index data to make a packet from many different data. | |
| uint8_t | delivery_status |
| Variable : delivery packet status. | |
| uint8_t | discovery_status |
| Variable : discovery process status. | |
| uint8_t | true_naD [2] |
| Variable : true 16b Network Address where the packet has been sent. | |
| uint8_t | retries_sending |
| Variable : retries done during the sending. | |
| uint8_t | nextIndex1 |
| Variable : specifies the next index where storing the next received fragment. | |
| uint8_t | frameNext |
| Variable : flag to indicate if a frame was truncated. | |
| uint8_t | indexNotModified |
| Variable : flag to indicate if the variable 'nextIndex1' has been modified during the last execution of 'readXBee'. | |
| uint8_t | apsEncryption |
| Variable : specifies if APS encryption is enabled or disabled. | |
WaspXBeeCore Class defines all the variables and functions used for managing the XBee modules. In this library, all the common functions are defined to be used in the other XBee libraries
Definition at line 444 of file WaspXBeeCore.h.
| WaspXBeeCore::WaspXBeeCore | ( | ) | [inline] |
class constructor
It does nothing
| void |
Definition at line 454 of file WaspXBeeCore.h.
| void WaspXBeeCore::init | ( | uint8_t | protocol_used, | |
| uint8_t | frequency, | |||
| uint8_t | model_used | |||
| ) |
It initializes the necessary variables.
It initalizes all the necessary variables
| uint8_t | protocol_used : specifies the protocol used in the XBee module (depends on the XBee module) | |
| uint8_t | frequency : specifies the frequency used in the XBee module (depends on the XBee module) | |
| uint8_t | model_used : specifies the XBee model used (depends on the XBee module) |
Reimplemented in WaspXBee802, WaspXBee868, WaspXBeeDM, and WaspXBeeZB.
Definition at line 37 of file WaspXBeeCore.cpp.
References add_type, apsEncryption, AWAKE_TIME_802_15_4_H, AWAKE_TIME_802_15_4_L, AWAKE_TIME_DIGIMESH_H, AWAKE_TIME_DIGIMESH_L, AWAKE_TIME_DIGIMESH_M, AWAKE_TIME_ZIGBEE_H, AWAKE_TIME_ZIGBEE_L, awakeTime, clearCommand(), clearFinishArray(), data_length, DIGIMESH, discoveryOptions, ENCRYPT_MODE_802_15_4, ENCRYPT_MODE_DIGIMESH, ENCRYPT_MODE_ZIGBEE, encryptMode, error_AT, error_RX, error_TX, finish, frag_length, frameNext, freq, indexNotModified, it, mode, model, nextIndex1, pendingPackets, pos, POWER_LEVEL_802_15_4, POWER_LEVEL_DIGIMESH, POWER_LEVEL_ZIGBEE, powerLevel, protocol, replacementPolicy, SCAN_CHANNELS_802_15_4_H, SCAN_CHANNELS_802_15_4_L, SCAN_CHANNELS_ZIGBEE_H, SCAN_CHANNELS_ZIGBEE_L, SCAN_TIME_802_15_4, SCAN_TIME_DIGIMESH_H, SCAN_TIME_DIGIMESH_L, SCAN_TIME_ZIGBEE, scanChannels, scanTime, SLEEP_OPTIONS_802_15_4, SLEEP_OPTIONS_DIGIMESH, SLEEP_OPTIONS_ZIGBEE, SLEEP_TIME_802_15_4_H, SLEEP_TIME_802_15_4_L, SLEEP_TIME_DIGIMESH_H, SLEEP_TIME_DIGIMESH_L, SLEEP_TIME_DIGIMESH_M, SLEEP_TIME_ZIGBEE_H, SLEEP_TIME_ZIGBEE_L, sleepOptions, sleepTime, start, TIME1, TIME_ENERGY_CHANNEL_ZIGBEE, TIME_RSSI_802_15_4, TIME_RSSI_DIGIMESH, TIME_RSSI_ZIGBEE, timeEnergyChannel, timeRSSI, totalFragmentsReceived, XBEE_802_15_4, XBEE_OUT, and ZIGBEE.
00038 { 00039 protocol=protocol_used; 00040 freq=frequency; 00041 model=model_used; 00042 00043 totalFragmentsReceived=0; 00044 pendingPackets=0; 00045 pos=0; 00046 discoveryOptions=0x00; 00047 if(protocol==XBEE_802_15_4) 00048 { 00049 awakeTime[0]=AWAKE_TIME_802_15_4_H; 00050 awakeTime[1]=AWAKE_TIME_802_15_4_L; 00051 sleepTime[0]=SLEEP_TIME_802_15_4_H; 00052 sleepTime[1]=SLEEP_TIME_802_15_4_L; 00053 scanTime[0]=SCAN_TIME_802_15_4; 00054 scanChannels[0]=SCAN_CHANNELS_802_15_4_H; 00055 scanChannels[1]=SCAN_CHANNELS_802_15_4_L; 00056 encryptMode=ENCRYPT_MODE_802_15_4; 00057 powerLevel=POWER_LEVEL_802_15_4; 00058 timeRSSI=TIME_RSSI_802_15_4; 00059 sleepOptions=SLEEP_OPTIONS_802_15_4; 00060 } 00061 if(protocol==ZIGBEE) 00062 { 00063 awakeTime[0]=AWAKE_TIME_ZIGBEE_H; 00064 awakeTime[1]=AWAKE_TIME_ZIGBEE_L; 00065 sleepTime[0]=SLEEP_TIME_ZIGBEE_H; 00066 sleepTime[1]=SLEEP_TIME_ZIGBEE_L; 00067 scanTime[0]=SCAN_TIME_ZIGBEE; 00068 scanChannels[0]=SCAN_CHANNELS_ZIGBEE_H; 00069 scanChannels[1]=SCAN_CHANNELS_ZIGBEE_L; 00070 timeEnergyChannel=TIME_ENERGY_CHANNEL_ZIGBEE; 00071 encryptMode=ENCRYPT_MODE_ZIGBEE; 00072 powerLevel=POWER_LEVEL_ZIGBEE; 00073 timeRSSI=TIME_RSSI_ZIGBEE; 00074 sleepOptions=SLEEP_OPTIONS_ZIGBEE; 00075 } 00076 if(protocol==DIGIMESH) 00077 { 00078 awakeTime[0]=AWAKE_TIME_DIGIMESH_H; 00079 awakeTime[1]=AWAKE_TIME_DIGIMESH_M; 00080 awakeTime[2]=AWAKE_TIME_DIGIMESH_L; 00081 sleepTime[0]=SLEEP_TIME_DIGIMESH_H; 00082 sleepTime[1]=SLEEP_TIME_DIGIMESH_M; 00083 sleepTime[2]=SLEEP_TIME_DIGIMESH_L; 00084 scanTime[0]=SCAN_TIME_DIGIMESH_H; 00085 scanTime[1]=SCAN_TIME_DIGIMESH_L; 00086 encryptMode=ENCRYPT_MODE_DIGIMESH; 00087 powerLevel=POWER_LEVEL_DIGIMESH; 00088 timeRSSI=TIME_RSSI_DIGIMESH; 00089 sleepOptions=SLEEP_OPTIONS_DIGIMESH; 00090 } 00091 00092 data_length=0; 00093 it=0; 00094 start=0; 00095 finish=0; 00096 add_type=0; 00097 mode=0; 00098 frag_length=0; 00099 TIME1=0; 00100 nextIndex1=0; 00101 frameNext=0; 00102 replacementPolicy=XBEE_OUT; 00103 indexNotModified=1; 00104 error_AT=2; 00105 error_RX=2; 00106 error_TX=2; 00107 clearFinishArray(); 00108 clearCommand(); 00109 apsEncryption=0; 00110 }

| uint8_t WaspXBeeCore::getOwnMacLow | ( | ) |
It gets the own lower 32b MAC.
It stores in global 'sourceMacLow' variable the own lower 32b MAC
Definition at line 121 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_own_mac_low, it, and sourceMacLow.
Referenced by getOwnMac().
00122 { 00123 int8_t error=2; 00124 00125 error_AT=2; 00126 gen_data(get_own_mac_low); 00127 error=gen_send(get_own_mac_low); 00128 00129 if(error==0) 00130 { 00131 for(it=0;it<4;it++) 00132 { 00133 sourceMacLow[it]=data[it]; 00134 } 00135 } 00136 return error; 00137 }


| uint8_t WaspXBeeCore::getOwnMacHigh | ( | ) |
It gets the own higher 32b MAC.
It stores in global 'sourceMacHigh' variable the own higher 32b MAC
Definition at line 148 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_own_mac_high, it, and sourceMacHigh.
Referenced by getOwnMac().
00149 { 00150 int8_t error=2; 00151 00152 error_AT=2; 00153 gen_data(get_own_mac_high); 00154 error=gen_send(get_own_mac_high); 00155 00156 if(error==0) 00157 { 00158 for(it=0;it<4;it++) 00159 { 00160 sourceMacHigh[it]=data[it]; 00161 } 00162 } 00163 return error; 00164 }


| uint8_t WaspXBeeCore::getOwnMac | ( | ) |
It gets the own MAC.
It stores in global 'sourceMacHigh' and 'sourceMacLow' variables the 64b MAC
Definition at line 174 of file WaspXBeeCore.cpp.
References getOwnMacHigh(), and getOwnMacLow().
Referenced by setOriginParams().
00175 { 00176 int8_t error=2; 00177 error=getOwnMacLow(); 00178 if(error==0) 00179 { 00180 error=getOwnMacHigh(); 00181 } 00182 return error; 00183 }


| uint8_t WaspXBeeCore::setOwnNetAddress | ( | uint8_t | NA_H, | |
| uint8_t | NA_L | |||
| ) |
It sets the own 16b Network Address.
| uint8_t | NA_H : higher Network Address byte (range [0x00-0xFF]) | |
| uint8_t | NA_L : lower Network Address byte (range [0x00-0xFF]) |
Definition at line 197 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_own_net_address, sourceNA, and XBEE_802_15_4.
Referenced by sendXBeePriv().
00198 { 00199 int8_t error=2; 00200 00201 if(protocol==XBEE_802_15_4) 00202 { 00203 error_AT=2; 00204 gen_data(set_own_net_address,NA_H,NA_L); 00205 gen_checksum(set_own_net_address); 00206 error=gen_send(set_own_net_address); 00207 } 00208 else 00209 { 00210 error_AT=-1; 00211 error=-1; 00212 } 00213 00214 if(!error) 00215 { 00216 sourceNA[0]=NA_H; 00217 sourceNA[1]=NA_L; 00218 } 00219 return error; 00220 }


| uint8_t WaspXBeeCore::getOwnNetAddress | ( | ) |
It gets the 16b Network Address.
It stores in global 'sourceNA' the 16b Network Address
Definition at line 232 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_own_net_address, protocol, sourceNA, XBEE_802_15_4, and ZIGBEE.
Referenced by setOriginParams().
00233 { 00234 int8_t error=2; 00235 00236 00237 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 00238 { 00239 error_AT=2; 00240 gen_data(get_own_net_address); 00241 error=gen_send(get_own_net_address); 00242 } 00243 else 00244 { 00245 error_AT=-1; 00246 error=-1; 00247 } 00248 00249 if(!error) 00250 { 00251 sourceNA[0]=data[0]; 00252 sourceNA[1]=data[1]; 00253 } 00254 return error; 00255 }


| uint8_t WaspXBeeCore::setBaudrate | ( | uint8_t | baud_rate | ) |
It sets the baudrate.
| uint8_t | baud_rate : the baudrate to set the XBee to (range [0-5]) |
Definition at line 268 of file WaspXBeeCore.cpp.
References baudrate, error_AT, gen_checksum(), gen_data(), gen_send(), and set_baudrate.
00269 { 00270 int8_t error=2; 00271 00272 error_AT=2; 00273 gen_data(set_baudrate,baud_rate); 00274 gen_checksum(set_baudrate); 00275 error=gen_send(set_baudrate); 00276 00277 if(!error) 00278 { 00279 baudrate=baud_rate; 00280 } 00281 return error; 00282 }

| uint8_t WaspXBeeCore::setAPI | ( | uint8_t | api_value | ) |
It sets API enabled or disabled.
| uint8_t | api_value : the API mode (range [0-2]) |
Definition at line 295 of file WaspXBeeCore.cpp.
References apiValue, error_AT, gen_checksum(), gen_data(), gen_send(), and set_api_mode.
00296 { 00297 int8_t error=2; 00298 00299 error_AT=2; 00300 gen_data(set_api_mode,api_value); 00301 gen_checksum(set_api_mode); 00302 error=gen_send(set_api_mode); 00303 00304 if(!error) 00305 { 00306 apiValue=api_value; 00307 } 00308 return error; 00309 }

| uint8_t WaspXBeeCore::setAPIoptions | ( | uint8_t | api_options | ) |
It sets API options.
| uint8_t | api_options : the API options (range [0-1]) |
Definition at line 321 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_api_options, and XBEE_802_15_4.
00322 { 00323 int8_t error=2; 00324 00325 if( (protocol!=XBEE_802_15_4) ) 00326 { 00327 error_AT=2; 00328 gen_data(set_api_options,api_options); 00329 gen_checksum(set_api_options); 00330 error=gen_send(set_api_options); 00331 } 00332 else 00333 { 00334 error_AT=-1; 00335 error=-1; 00336 } 00337 return error; 00338 }

| uint8_t WaspXBeeCore::setPAN | ( | uint8_t * | PANID | ) |
It sets the PAN ID.
| uint8_t* | PANID : the PAN ID (64b - ZigBee ; 16b - Other protocols) |
Definition at line 350 of file WaspXBeeCore.cpp.
References DIGIMESH, error_AT, gen_checksum(), gen_data(), gen_send(), it, PAN_ID, protocol, set_pan, set_pan_zb, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00351 { 00352 int8_t error=2; 00353 00354 if( (protocol==XBEE_802_15_4) || (protocol==DIGIMESH) || (protocol==XBEE_900) || (protocol==XBEE_868) ) 00355 { 00356 error_AT=2; 00357 gen_data(set_pan,PANID); 00358 gen_checksum(set_pan); 00359 error=gen_send(set_pan); 00360 } 00361 00362 if(protocol==ZIGBEE) 00363 { 00364 error_AT=2; 00365 gen_data(set_pan_zb,PANID); 00366 gen_checksum(set_pan_zb); 00367 error=gen_send(set_pan_zb); 00368 } 00369 00370 if(!error) 00371 { 00372 if( (protocol==XBEE_802_15_4) || (protocol==DIGIMESH) || (protocol==XBEE_900) || (protocol==XBEE_868) ) 00373 { 00374 for(it=0;it<2;it++) 00375 { 00376 PAN_ID[it]=PANID[it]; 00377 } 00378 } 00379 if(protocol==ZIGBEE) 00380 { 00381 for(it=0;it<8;it++) 00382 { 00383 PAN_ID[it]=PANID[it]; 00384 } 00385 } 00386 } 00387 return error; 00388 }

| uint8_t WaspXBeeCore::getPAN | ( | ) |
It gets the PAN ID.
It stores in global 'PAN_ID' the PAN ID
Definition at line 399 of file WaspXBeeCore.cpp.
References data, delay(), DIGIMESH, error_AT, gen_data(), gen_send(), get_pan, it, PAN_ID, protocol, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00400 { 00401 int8_t error=2; 00402 00403 error_AT=2; 00404 gen_data(get_pan); 00405 if( protocol==ZIGBEE ) error=gen_send(get_pan); 00406 else error=gen_send(get_pan); 00407 00408 if(!error) 00409 { 00410 if( (protocol==XBEE_802_15_4) || (protocol==DIGIMESH) || (protocol==XBEE_900) || (protocol==XBEE_868) ) 00411 { 00412 for(it=0;it<2;it++) 00413 { 00414 PAN_ID[it]=data[it]; 00415 delay(20); 00416 } 00417 } 00418 if(protocol==ZIGBEE) 00419 { 00420 for(it=0;it<8;it++) 00421 { 00422 PAN_ID[it]=data[it]; 00423 delay(20); 00424 } 00425 } 00426 } 00427 return error; 00428 }

| uint8_t WaspXBeeCore::setSleepMode | ( | uint8_t | sleep | ) |
It sets the sleep mode.
| uint8_t | sleep : the sleep mode (range [0-5]) |
Definition at line 440 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), set_sleep_mode_xbee, and sleepMode.
Referenced by WaspXBee::setMode().
00441 { 00442 int8_t error=2; 00443 00444 error_AT=2; 00445 gen_data(set_sleep_mode_xbee,sleep); 00446 gen_checksum(set_sleep_mode_xbee); 00447 error=gen_send(set_sleep_mode_xbee); 00448 00449 if(!error) 00450 { 00451 sleepMode=sleep; 00452 } 00453 return error; 00454 }


| uint8_t WaspXBeeCore::getSleepMode | ( | ) |
It gets the sleep mode.
It stores in global 'sleepMode' the sleep mode
Definition at line 464 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_sleep_mode_xbee, and sleepMode.
00465 { 00466 int8_t error=2; 00467 00468 error_AT=2; 00469 gen_data(get_sleep_mode_xbee); 00470 error=gen_send(get_sleep_mode_xbee); 00471 00472 if(error==0) 00473 { 00474 sleepMode=data[0]; 00475 } 00476 return error; 00477 }

| uint8_t WaspXBeeCore::setAwakeTime | ( | uint8_t * | awake | ) |
It sets the time awake before sleeping.
| uint8_t* | awake : the time awake before sleeping (range depends on the XBee module) |
Definition at line 490 of file WaspXBeeCore.cpp.
References awakeTime, DIGIMESH, error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_awake_time, set_awake_time_DM, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00491 { 00492 int8_t error=2; 00493 00494 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_868) ) 00495 { 00496 error_AT=2; 00497 gen_data(set_awake_time,awake); 00498 gen_checksum(set_awake_time); 00499 error=gen_send(set_awake_time); 00500 } 00501 00502 if( (protocol==DIGIMESH) || (protocol==XBEE_900) ) 00503 { 00504 error_AT=2; 00505 gen_data(set_awake_time_DM,awake); 00506 gen_checksum(set_awake_time_DM); 00507 error=gen_send(set_awake_time_DM); 00508 } 00509 00510 if(!error) 00511 { 00512 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_868) ) 00513 { 00514 awakeTime[0]=awake[0]; 00515 awakeTime[1]=awake[1]; 00516 } 00517 if( (protocol==DIGIMESH) || (protocol==XBEE_900) ) 00518 { 00519 awakeTime[0]=awake[0]; 00520 awakeTime[1]=awake[1]; 00521 awakeTime[2]=awake[2]; 00522 } 00523 } 00524 return error; 00525 }

| uint8_t WaspXBeeCore::setSleepTime | ( | uint8_t * | sleep | ) |
It sets time the module is slept.
| uint8_t* | sleep : the module is slept (range depends on the XBee module) |
Definition at line 538 of file WaspXBeeCore.cpp.
References DIGIMESH, error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_sleep_time, set_sleep_time_DM, sleepTime, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00539 { 00540 int8_t error=2; 00541 00542 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_868) ) 00543 { 00544 error_AT=2; 00545 gen_data(set_sleep_time,sleep); 00546 gen_checksum(set_sleep_time); 00547 error=gen_send(set_sleep_time); 00548 } 00549 00550 if( (protocol==DIGIMESH) || (protocol==XBEE_900) ) 00551 { 00552 error_AT=2; 00553 gen_data(set_sleep_time_DM,sleep); 00554 gen_checksum(set_sleep_time_DM); 00555 error=gen_send(set_sleep_time_DM); 00556 } 00557 00558 if(!error) 00559 { 00560 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_868) ) 00561 { 00562 sleepTime[0]=sleep[0]; 00563 sleepTime[1]=sleep[1]; 00564 } 00565 if( (protocol==DIGIMESH) || (protocol==XBEE_900) ) 00566 { 00567 sleepTime[0]=sleep[0]; 00568 sleepTime[1]=sleep[1]; 00569 sleepTime[2]=sleep[2]; 00570 } 00571 } 00572 return error; 00573 }

| uint8_t WaspXBeeCore::setChannel | ( | uint8_t | _channel | ) |
It sets the channel frequency where module is working on.
| uint8_t | _channel : the channel frequency where module is working on (range depends on the XBee module) |
Definition at line 586 of file WaspXBeeCore.cpp.
References channel, DIGIMESH, error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_channel, XBEE_802_15_4, and XBEE_900.
00587 { 00588 int8_t error=2; 00589 00590 00591 if( (protocol==XBEE_802_15_4) || (protocol==DIGIMESH) || (protocol==XBEE_900) ) 00592 { 00593 error_AT=2; 00594 gen_data(set_channel,_channel); 00595 gen_checksum(set_channel); 00596 error=gen_send(set_channel); 00597 } 00598 else 00599 { 00600 error_AT=-1; 00601 error=-1; 00602 } 00603 if(!error) 00604 { 00605 channel=_channel; 00606 } 00607 00608 return error; 00609 }

| uint8_t WaspXBeeCore::getChannel | ( | ) |
It gets the channel frequency where module is working on.
It stores in global 'channel' the channel frequency where module is working on
Definition at line 619 of file WaspXBeeCore.cpp.
References channel, data, error_AT, gen_data(), gen_send(), and get_channel.
00620 { 00621 int8_t error=2; 00622 00623 error_AT=2; 00624 gen_data(get_channel); 00625 error=gen_send(get_channel); 00626 00627 if(!error) 00628 { 00629 channel=data[0]; 00630 } 00631 return error; 00632 }

| uint8_t WaspXBeeCore::setNodeIdentifier | ( | char * | node | ) |
It sets the Node Identifier.
| char* | node : the NI must be a 20 character max string |
Definition at line 646 of file WaspXBeeCore.cpp.
References BYTE, clearCommand(), command, error_AT, it, nodeID, parse_message(), WaspXBee::print(), WAIT_TIME, and XBee.
00647 { 00648 uint8_t* NI = (uint8_t*) calloc(30,sizeof(uint8_t)); //{0x7E, 0x00, 0x00, 0x08, 0x52, 0x4E, 0x49, 0x02}; 00649 NI[0]=0x7E; 00650 NI[1]=0x00; 00651 NI[3]=0x08; 00652 NI[4]=0x52; 00653 NI[5]=0x4E; 00654 NI[6]=0x49; 00655 uint8_t num_NI; 00656 int8_t error=2; 00657 uint8_t* ByteIN = (uint8_t*) calloc(20,sizeof(uint8_t)); 00658 00659 uint8_t counter=0; 00660 uint8_t counter3=0; 00661 uint8_t est=1; 00662 uint8_t frame_ID=NI[4]; 00663 uint8_t end=0; 00664 uint16_t interval=WAIT_TIME; 00665 uint8_t checksum=0; 00666 uint8_t numberBytes=9; 00667 uint8_t status=0; 00668 uint8_t undesired=0; 00669 00670 00671 it=0; 00672 error_AT=2; 00673 while( (node[it]!='\0') ) 00674 { 00675 NI[it+7]=uint8_t(node[it]); 00676 it++; 00677 } 00678 NI[2]=4+it; 00679 for(it=3;it<(7+(NI[2]-4));it++) 00680 { 00681 checksum=checksum+NI[it]; 00682 } 00683 while( (checksum>255)) 00684 { 00685 checksum=checksum-256; 00686 } 00687 checksum=255-checksum; 00688 NI[7+NI[2]-4]=checksum; 00689 while(counter<(8+NI[2]-4)) 00690 { 00691 XBee.print(NI[counter], BYTE); 00692 counter++; 00693 } 00694 counter=0; 00695 clearCommand(); 00696 command[5]=0x4E; 00697 command[6]=0x49; 00698 error=parse_message(command); 00699 00700 if(error==0) 00701 { 00702 for(it=0;it<NI[2]-4;it++) 00703 { 00704 nodeID[it]=node[it]; 00705 } 00706 } 00707 free(NI); 00708 free(ByteIN); 00709 NI=NULL; 00710 ByteIN=NULL; 00711 return error; 00712 }

| uint8_t WaspXBeeCore::getNodeIdentifier | ( | ) |
It gets the Node Identifier.
It stores in global 'nodeID' the Node Identifier
Definition at line 722 of file WaspXBeeCore.cpp.
References data, data_length, error_AT, gen_data(), gen_send(), get_NI, it, and nodeID.
00723 { 00724 int8_t error=2; 00725 00726 error_AT=2; 00727 gen_data(get_NI); 00728 error=gen_send(get_NI); 00729 00730 if(!error) 00731 { 00732 for(it=0;it<data_length;it++) 00733 { 00734 nodeID[it]=char(data[it]); 00735 } 00736 } 00737 return error; 00738 }

| uint8_t WaspXBeeCore::scanNetwork | ( | ) |
It scans for brothers in the same channel and same PAN ID.
It stores the given info (SH,SL,MY,RSSI,NI) in global array "scannedBrothers" variable It stores in global "totalScannedBrothers" the number of found brothers
Definition at line 749 of file WaspXBeeCore.cpp.
References error_AT, gen_data(), gen_send(), scan_network, and totalScannedBrothers.
00750 { 00751 uint8_t error=2; 00752 00753 error_AT=2; 00754 totalScannedBrothers=0; 00755 gen_data(scan_network); 00756 error=gen_send(scan_network); 00757 00758 return error; 00759 }

| uint8_t WaspXBeeCore::scanNetwork | ( | char * | node | ) |
It scans for a brother in the same channel and same PAN ID.
It stores the given info (SH,SL,MY,RSSI,NI) in global array "scannedBrothers" variable It stores in global "totalScannedBrothers" the number of found brothers
| char* | node : 20-byte max string containing NI of the node to search |
Definition at line 772 of file WaspXBeeCore.cpp.
References BYTE, clearCommand(), command, DIGIMESH, error_AT, finish, it, parse_message(), WaspXBee::print(), protocol, totalScannedBrothers, WAIT_TIME2, XBee, XBEE_868, and XBEE_900.
00773 { 00774 uint8_t* ND = (uint8_t*) calloc(30,sizeof(uint8_t)); //{0x7E, 0x00, 0x04, 0x08, 0x52, 0x4E, 0x44, 0x13}; 00775 ND[0]=0x7E; 00776 ND[1]=0x00; 00777 ND[3]=0x08; 00778 ND[4]=0x52; 00779 ND[5]=0x4E; 00780 ND[6]=0x44; 00781 uint8_t num_ND; 00782 int8_t error=2; 00783 uint8_t* ByteIN = (uint8_t*) calloc(20,sizeof(uint8_t)); 00784 00785 uint8_t cont=1; 00786 uint8_t cont2=0; 00787 uint8_t counter=0; 00788 uint8_t counter3=0; 00789 uint8_t est=1; 00790 uint8_t frame_ID=ND[4]; 00791 uint8_t end=0; 00792 uint16_t interval=WAIT_TIME2; 00793 uint16_t length=0; 00794 uint16_t aux=0; 00795 uint8_t existsNI=0; 00796 uint8_t length_NI=0; 00797 uint16_t checksum=0; 00798 uint8_t finish=0; 00799 00800 error_AT=2; 00801 totalScannedBrothers=0; 00802 if( (protocol==DIGIMESH) || (protocol==XBEE_900) || (protocol==XBEE_868) ) 00803 { 00804 interval=14000; 00805 } 00806 it=0; 00807 while( (node[it]!='\0') ) 00808 { 00809 ND[it+7]=uint8_t(node[it]); 00810 it++; 00811 } 00812 ND[2]=4+it; 00813 for(it=3;it<(7+(ND[2]-4));it++) 00814 { 00815 checksum=checksum+ND[it]; 00816 } 00817 while( (checksum>255)) 00818 { 00819 checksum=checksum-256; 00820 } 00821 checksum=255-checksum; 00822 ND[7+ND[2]-4]=checksum; 00823 while(counter<(8+ND[2]-4)) 00824 { 00825 XBee.print(ND[counter], BYTE); 00826 counter++; 00827 } 00828 counter=0; 00829 clearCommand(); 00830 command[5]=ND[5]; 00831 command[6]=ND[6]; 00832 error=parse_message(command); 00833 00834 free(ND); 00835 free(ByteIN); 00836 ND=NULL; 00837 ByteIN=NULL; 00838 return error; 00839 }

| uint8_t WaspXBeeCore::setScanningTime | ( | uint8_t * | time | ) |
It sets the time the Node Discovery is scanning.
| uint8_t* | time : the time the Node Discovery is scanning (range [0x01-0xFC]) |
Definition at line 853 of file WaspXBeeCore.cpp.
References DIGIMESH, error_AT, gen_checksum(), gen_data(), gen_send(), protocol, scanTime, set_scanning_time, set_scanning_time_DM, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00854 { 00855 int8_t error=2; 00856 00857 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_900) ) 00858 { 00859 error_AT=2; 00860 gen_data(set_scanning_time,time); 00861 gen_checksum(set_scanning_time); 00862 error=gen_send(set_scanning_time); 00863 } 00864 00865 if( (protocol==DIGIMESH) || (protocol==XBEE_868) ) 00866 { 00867 error_AT=2; 00868 gen_data(set_scanning_time_DM,time); 00869 gen_checksum(set_scanning_time_DM); 00870 error=gen_send(set_scanning_time_DM); 00871 } 00872 00873 00874 if(!error) 00875 { 00876 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) || (protocol==XBEE_900) ) 00877 { 00878 scanTime[0]=time[0]; 00879 } 00880 if( (protocol==DIGIMESH) || (protocol==XBEE_868) ) 00881 { 00882 scanTime[0]=time[0]; 00883 scanTime[1]=time[1]; 00884 } 00885 } 00886 return error; 00887 }

| uint8_t WaspXBeeCore::getScanningTime | ( | ) |
It gets the time the Node Discovery is scanning.
It stores in global 'scanTime' the time the Node Discovery is scanning
Definition at line 898 of file WaspXBeeCore.cpp.
References data, DIGIMESH, error_AT, gen_data(), gen_send(), get_scanning_time, protocol, scanTime, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
00899 { 00900 int8_t error=2; 00901 00902 error_AT=2; 00903 gen_data(get_scanning_time); 00904 if( (protocol==DIGIMESH) || (protocol==XBEE_868) || (protocol==ZIGBEE) || (protocol==XBEE_900) ) error=gen_send(get_scanning_time); 00905 else error=gen_send(get_scanning_time); 00906 00907 if(!error) 00908 { 00909 if( (protocol==XBEE_802_15_4) ) 00910 { 00911 scanTime[0]=data[0]; 00912 } 00913 if( (protocol==ZIGBEE) || (protocol==XBEE_900) ) 00914 { 00915 scanTime[0]=data[1]; 00916 } 00917 if( (protocol==DIGIMESH) || (protocol==XBEE_868) ) 00918 { 00919 scanTime[0]=data[0]; 00920 scanTime[1]=data[1]; 00921 } 00922 } 00923 return error; 00924 }

| uint8_t WaspXBeeCore::setDiscoveryOptions | ( | uint8_t | options | ) |
It sets the options for the network discovery command.
| uint8_t | options : the options for the network discovery command (range [0x00-0x03]) |
Definition at line 936 of file WaspXBeeCore.cpp.
References discoveryOptions, error_AT, gen_checksum(), gen_data(), gen_send(), protocol, set_discov_options, XBEE_802_15_4, and ZIGBEE.
00937 { 00938 int8_t error=2; 00939 00940 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 00941 { 00942 error_AT=2; 00943 gen_data(set_discov_options,options); 00944 gen_checksum(set_discov_options); 00945 error=gen_send(set_discov_options); 00946 } 00947 else 00948 { 00949 error_AT=-1; 00950 error=-1; 00951 } 00952 if(!error) 00953 { 00954 discoveryOptions=options; 00955 } 00956 return error; 00957 }

| uint8_t WaspXBeeCore::getDiscoveryOptions | ( | ) |
It gets the options for the network discovery command.
It stores in global 'discoveryOptions' the options for the network discovery command
Definition at line 967 of file WaspXBeeCore.cpp.
References data, discoveryOptions, error_AT, gen_data(), gen_send(), get_discov_options, protocol, XBEE_802_15_4, and ZIGBEE.
00968 { 00969 int8_t error=2; 00970 00971 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 00972 { 00973 error_AT=2; 00974 gen_data(get_discov_options); 00975 error=gen_send(get_discov_options); 00976 } 00977 else 00978 { 00979 error_AT=-1; 00980 error=-1; 00981 } 00982 if(error==0) 00983 { 00984 discoveryOptions=data[0]; 00985 } 00986 return error; 00987 }

| uint8_t WaspXBeeCore::nodeSearch | ( | char * | node, | |
| struct packetXBee * | paq | |||
| ) |
It performs a quick search of a specific node. Depending on the XBee module it stores different information.
It stores the given info (SH,SL,MY,RSSI,NI) in global array "scannedBrothers" variable It stores in global "totalScannedBrothers" the number of found brothers
| char* | node : 20-byte max string containing NI of the node to search | |
| struct | packetXBee* paq : a packetXBee structure to store the node information |
Definition at line 1003 of file WaspXBeeCore.cpp.
References BYTE, clearCommand(), command, data, DIGIMESH, error_AT, it, packetXBee::macDH, packetXBee::macDL, packetXBee::naD, parse_message(), WaspXBee::print(), protocol, XBee, XBEE_868, XBEE_900, and ZIGBEE.
01004 { 01005 uint8_t* DN = (uint8_t*) calloc(30,sizeof(uint8_t)); //{0x7E, 0x00, 0x00, 0x08, 0x52, 0x44, 0x4E, 0xE3}; 01006 DN[0]=0x7E; 01007 DN[1]=0x00; 01008 DN[3]=0x08; 01009 DN[4]=0x52; 01010 DN[5]=0x44; 01011 DN[6]=0x4E; 01012 uint8_t num_DN; 01013 int8_t error=2; 01014 uint8_t* ByteIN = (uint8_t*) calloc(25,sizeof(uint8_t)); 01015 01016 uint8_t counter=0; 01017 uint8_t counter3=0; 01018 uint8_t est=1; 01019 uint8_t frame_ID=DN[4]; 01020 uint8_t end=0; 01021 uint16_t interval=2000; 01022 uint8_t checksum=0; 01023 uint8_t status=0; 01024 uint8_t undesired=0; 01025 01026 01027 error_AT=2; 01028 if(protocol==DIGIMESH) 01029 { 01030 interval=14000; 01031 } 01032 it=0; 01033 while( (node[it]!='\0') ) 01034 { 01035 DN[it+7]=uint8_t(node[it]); 01036 it++; 01037 } 01038 DN[2]=4+it; 01039 for(it=3;it<(7+(DN[2]-4));it++) 01040 { 01041 checksum=checksum+DN[it]; 01042 } 01043 while( (checksum>255)) 01044 { 01045 checksum=checksum-256; 01046 } 01047 checksum=255-checksum; 01048 DN[7+DN[2]-4]=checksum; 01049 while(counter<(8+DN[2]-4)) 01050 { 01051 XBee.print(DN[counter], BYTE); 01052 counter++; 01053 } 01054 01055 counter=0; 01056 clearCommand(); 01057 command[5]=0x44; 01058 command[6]=0x4E; 01059 error=parse_message(command); 01060 01061 if(error==0) 01062 { 01063 if( (protocol==ZIGBEE) || (protocol==XBEE_900) || (protocol==XBEE_868) ) 01064 { 01065 for(it=0;it<2;it++) 01066 { 01067 paq->naD[it]=data[it]; 01068 } 01069 for(it=0;it<4;it++) 01070 { 01071 paq->macDH[it]=data[it+2]; 01072 } 01073 for(it=0;it<4;it++) 01074 { 01075 paq->macDL[it]=data[it+6]; 01076 } 01077 } 01078 if(protocol==DIGIMESH) 01079 { 01080 for(it=0;it<4;it++) 01081 { 01082 paq->macDH[it]=data[it]; 01083 } 01084 for(it=0;it<4;it++) 01085 { 01086 paq->macDL[it]=data[it+4]; 01087 } 01088 } 01089 } 01090 free(DN); 01091 free(ByteIN); 01092 DN=NULL; 01093 ByteIN=NULL; 01094 return error; 01095 }

| uint8_t WaspXBeeCore::setScanningChannels | ( | uint8_t | channel_H, | |
| uint8_t | channel_L | |||
| ) |
It sets the list of channels to scan when performing an energy scan.
| uint8_t | channel_H : higher channel list byte (range [0x00-0xFF]) | |
| uint8_t | channel_L : lower channel list byte (range [0x00-0xFF]) |
Definition at line 1128 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), protocol, scanChannels, set_scanning_channel, XBEE_802_15_4, and ZIGBEE.
01129 { 01130 int8_t error=2; 01131 01132 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 01133 { 01134 error_AT=2; 01135 gen_data(set_scanning_channel,channel_H,channel_L); 01136 gen_checksum(set_scanning_channel); 01137 error=gen_send(set_scanning_channel); 01138 } 01139 else 01140 { 01141 error_AT=-1; 01142 error=-1; 01143 } 01144 if(error==0) 01145 { 01146 scanChannels[0]=channel_H; 01147 scanChannels[1]=channel_L; 01148 } 01149 return error; 01150 }

| uint8_t WaspXBeeCore::getScanningChannels | ( | ) |
It gets the list of channels to scan when performing an energy scan.
It stores in global 'scanChannels' the list of channels to scan when performing an energy scan
Definition at line 1161 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_scanning_channel, it, protocol, scanChannels, XBEE_802_15_4, and ZIGBEE.
01162 { 01163 int8_t error=2; 01164 01165 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 01166 { 01167 error_AT=2; 01168 gen_data(get_scanning_channel); 01169 error=gen_send(get_scanning_channel); 01170 } 01171 else 01172 { 01173 error_AT=-1; 01174 error=-1; 01175 } 01176 if(error==0) 01177 { 01178 for(it=0;it<2;it++) 01179 { 01180 scanChannels[it]=data[it]; 01181 } 01182 } 01183 return error; 01184 }

| uint8_t WaspXBeeCore::setDurationEnergyChannels | ( | uint8_t | duration | ) |
It sets the time the Energy Scan will be performed.
It stores the energy on each channel in global 'energyChannel' variable
| uint8_t | duration : time the energy scan will be performed (range [0-6]) |
Definition at line 1197 of file WaspXBeeCore.cpp.
References data, data_length, energyChannel, error_AT, gen_checksum(), gen_data(), gen_send(), it, protocol, set_duration_energy, set_duration_energy_ZB, timeEnergyChannel, XBEE_802_15_4, and ZIGBEE.
01198 { 01199 int8_t error=2; 01200 01201 if( (protocol==XBEE_802_15_4) ) 01202 { 01203 error_AT=2; 01204 gen_data(set_duration_energy,duration); 01205 gen_checksum(set_duration_energy); 01206 error=gen_send(set_duration_energy); 01207 } 01208 else if( (protocol==ZIGBEE) ) 01209 { 01210 error_AT=2; 01211 gen_data(set_duration_energy_ZB,duration); 01212 gen_checksum(set_duration_energy_ZB); 01213 error=gen_send(set_duration_energy_ZB); 01214 } 01215 else 01216 { 01217 error_AT=-1; 01218 error=-1; 01219 } 01220 01221 if(error==0) 01222 { 01223 if(protocol==XBEE_802_15_4) 01224 { 01225 for(it=0;it<data_length;it++) 01226 { 01227 energyChannel[it]=data[it]; 01228 } 01229 } 01230 if(protocol==ZIGBEE) 01231 { 01232 timeEnergyChannel=data[0]; 01233 } 01234 } 01235 return error; 01236 }

| uint8_t WaspXBeeCore::getDurationEnergyChannels | ( | ) |
It gets the time the Energy Scan will be performed.
It stores in global 'timeEnergyChannel' the time the Energy Scan will be performed
Definition at line 1248 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_duration_energy, protocol, timeEnergyChannel, XBEE_802_15_4, and ZIGBEE.
01249 { 01250 int8_t error=2; 01251 01252 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 01253 { 01254 error_AT=2; 01255 gen_data(get_duration_energy); 01256 error=gen_send(get_duration_energy); 01257 } 01258 else 01259 { 01260 error_AT=-1; 01261 error=-1; 01262 } 01263 if(!error) 01264 { 01265 timeEnergyChannel=data[0]; 01266 } 01267 return error; 01268 }

| uint8_t WaspXBeeCore::setLinkKey | ( | char * | key | ) |
It sets the link key to use in the 128b AES algorithm.
| char* | key : the 128-bit AES encryption key (range [0-0xFFFFFFFFFFFFFFFF]) |
Definition at line 1280 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), it, linkKey, and set_link_key.
01281 { 01282 int8_t error=2; 01283 01284 error_AT=2; 01285 gen_data(set_link_key,key); 01286 gen_checksum(set_link_key); 01287 error=gen_send(set_link_key); 01288 01289 if(!error) 01290 { 01291 for(it=0;it<16;it++) 01292 { 01293 linkKey[it]=char(key[it]); 01294 } 01295 } 01296 return error; 01297 }

| uint8_t WaspXBeeCore::encryptionMode | ( | uint8_t | mode | ) |
It sets the encryption mode ON/OFF.
| uint8_t | mode : the encryption mode (range [0-1]) |
Definition at line 1309 of file WaspXBeeCore.cpp.
References encryptMode, error_AT, gen_checksum(), gen_data(), gen_send(), and set_encryption.
01310 { 01311 int8_t error=2; 01312 01313 error_AT=2; 01314 gen_data(set_encryption,mode); 01315 gen_checksum(set_encryption); 01316 error=gen_send(set_encryption); 01317 if(!error) 01318 { 01319 encryptMode=mode; 01320 } 01321 return error; 01322 }

| uint8_t WaspXBeeCore::setPowerLevel | ( | uint8_t | value | ) |
It sets the power level at which RF module transmits.
| uint8_t | mode : power level at which RF module transmits (depends on the XBee module - range [0-4]) |
Definition at line 1334 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), powerLevel, protocol, set_power_level, and XBEE_900.
01335 { 01336 int8_t error=2; 01337 01338 if(protocol!=XBEE_900) 01339 { 01340 error_AT=2; 01341 gen_data(set_power_level,value); 01342 gen_checksum(set_power_level); 01343 error=gen_send(set_power_level); 01344 } 01345 if(!error) 01346 { 01347 powerLevel=value; 01348 } 01349 return error; 01350 }

| uint8_t WaspXBeeCore::getRSSI | ( | ) |
It gets the Received Signal Strength Indicator.
It stores in global 'valueRSSI' the Received Signal Strength Indicator
Definition at line 1360 of file WaspXBeeCore.cpp.
References WaspXBee::available(), data, delay(), DIGIMESH, error_AT, WaspXBee::flush(), gen_data(), gen_send(), get_RSSI, WaspXBee::print(), WaspXBee::println(), protocol, WaspXBee::read(), WaspUtils::str2hex(), Utils, valueRSSI, XBee, XBEE_802_15_4, XBEE_868, XBEE_900, and ZIGBEE.
01361 { 01362 int8_t error=2; 01363 uint8_t* ByteIN = (uint8_t*) calloc(40,sizeof(uint8_t)); 01364 uint8_t i=0; 01365 01366 if( (protocol == XBEE_802_15_4 ) || (protocol==ZIGBEE) ) 01367 { 01368 error_AT=2; 01369 gen_data(get_RSSI); 01370 error=gen_send(get_RSSI); 01371 } 01372 else if( (protocol== DIGIMESH) || (protocol==XBEE_868) || (protocol==XBEE_900) ) 01373 { 01374 delay(2000); 01375 XBee.print("+++"); 01376 delay(2000); 01377 XBee.flush(); 01378 XBee.println("atdb"); 01379 delay(1000); 01380 error_AT=2; 01381 while(XBee.available()>0) 01382 { 01383 ByteIN[i]=XBee.read(); 01384 error=0; 01385 i++; 01386 error_AT=0; 01387 } 01388 i=0; 01389 XBee.println("atcn"); 01390 delay(1000); 01391 valueRSSI[0]=Utils.str2hex(ByteIN); 01392 } 01393 if(error==0) 01394 { 01395 if( (protocol==XBEE_802_15_4) || (protocol==ZIGBEE) ) 01396 { 01397 valueRSSI[0]=data[0]; 01398 } 01399 } 01400 free(ByteIN); 01401 ByteIN=NULL; 01402 return error; 01403 }

| uint8_t WaspXBeeCore::getHardVersion | ( | ) |
It gets the Hardware Version.
It stores in global 'hardVersion' the Hardware Version
Definition at line 1413 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_hard_version, and hardVersion.
01414 { 01415 int8_t error=2; 01416 01417 error_AT=2; 01418 gen_data(get_hard_version); 01419 error=gen_send(get_hard_version); 01420 if(!error) 01421 { 01422 hardVersion[0]=data[0]; 01423 hardVersion[1]=data[1]; 01424 } 01425 return error; 01426 }

| uint8_t WaspXBeeCore::getSoftVersion | ( | ) |
It gets the Software Version.
It stores in global 'softVersion' the Software Version
Definition at line 1436 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_soft_version, and softVersion.
01437 { 01438 int8_t error=2; 01439 01440 error_AT=2; 01441 gen_data(get_soft_version); 01442 error=gen_send(get_soft_version); 01443 if(error==0) 01444 { 01445 softVersion[0]=data[0]; 01446 softVersion[1]=data[1]; 01447 } 01448 return error; 01449 }

| uint8_t WaspXBeeCore::setRSSItime | ( | uint8_t | time | ) |
It sets the RSSI time.
| uint8_t | time : amount of time to do the PWM (range [0x00-0xFF]) |
Definition at line 1462 of file WaspXBeeCore.cpp.
References error_AT, gen_checksum(), gen_data(), gen_send(), set_RSSI_time, and timeRSSI.
01463 { 01464 int8_t error=2; 01465 01466 error_AT=2; 01467 gen_data(set_RSSI_time,time); 01468 gen_checksum(set_RSSI_time); 01469 error=gen_send(set_RSSI_time); 01470 if(!error) 01471 { 01472 timeRSSI=time; 01473 } 01474 return error; 01475 }

| uint8_t WaspXBeeCore::getRSSItime | ( | ) |
It gets the RSSI time.
It stores in global 'timeRSSI' the RSSI time
Definition at line 1485 of file WaspXBeeCore.cpp.
References data, error_AT, gen_data(), gen_send(), get_RSSI_time, and timeRSSI.
01486 { 01487 int8_t error=2; 01488 01489 error_AT=2; 01490 gen_data(get_RSSI_time); 01491 error=gen_send(get_RSSI_time); 01492 if(!error) 01493 { 01494 timeRSSI=data[0]; 01495 } 01496 return error; 01497 }

| uint8_t WaspXBeeCore::writeValues | ( | ) |
It writes the parameters changed into non-volatil memory, being applied when the XBee is s