int8_t _dynamixel_rtu_check_integrity(dynamixel_t *ctx, uint8_t *msg, uint8_t msg_length) { uint8_t checksum_calculated; uint8_t checksum_received; checksum_calculated = gen_checksum(msg, msg_length - 1); checksum_received = msg[msg_length - 1]; /* Check Checksum of msg */ if (checksum_calculated == checksum_received) { memmove( msg, msg+_DYNAMIXEL_RTU_HEADER_LENGTH, msg_length-_DYNAMIXEL_RTU_HEADER_LENGTH-_DYNAMIXEL_RTU_CHECKSUM_LENGTH ); msg_length=msg_length-_DYNAMIXEL_RTU_HEADER_LENGTH-_DYNAMIXEL_RTU_CHECKSUM_LENGTH; return msg_length; } else { if (ctx->debug) { fprintf(stderr, "ERROR Checksum received %0X != Checksum calculated %0X\n", checksum_received, checksum_calculated); } if (ctx->error_recovery & DYNAMIXEL_ERROR_RECOVERY_PROTOCOL) { _dynamixel_rtu_flush(ctx); } errno = E_DYNAMIXEL_BADCHECKSUM; return -1; } }
/* Function: Reset the Network Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NR command Parameters: reset --> Possible values are 0/1 0: reset the node network interface 1: reset the entirely network */ uint8_t WaspXBeeZB::resetNetwork(uint8_t reset) { int8_t error=2; error_AT=2; gen_data(reset_network_ZB,reset); gen_checksum(reset_network_ZB); error=gen_send(reset_network_ZB); return error; }
/* Function: Specifies the number of retries than can be sent for a given unicast RF packet Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the RR command Parameters: macretries: number of retries than can be sent for a given unicast RF packet (0x00-0x0F) */ uint8_t WaspXBee868::setMacRetries(uint8_t macretries) { int8_t error=2; error_AT=2; gen_data(set_retries_868,macretries); gen_checksum(set_retries_868); error=gen_send(set_retries_868); if(error==0) { macRetries=macretries; } return error; }
/* Function: Specifies the number of additional broadcast retransmissions Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the MT command Parameters: mtrans: number of additional broadcast retransmissions (0x00-0x0F) */ uint8_t WaspXBee868::setMultipleBroadcast(uint8_t mtrans) { int8_t error=2; error_AT=2; gen_data(set_mult_broadcast_868,mtrans); gen_checksum(set_mult_broadcast_868); error=gen_send(set_mult_broadcast_868); if(error==0) { multipleBroadcast=mtrans; } return error; }
/* Function: Set the CA threshold in the CCA process to detect energy on the channel Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the CA command Parameters: threshold: CA threshold in the CCA process (0x00-0x50) */ uint8_t WaspXBee802::setEnergyThreshold(uint8_t threshold) { int8_t error=2; error_AT=2; gen_data(set_energy_thres_802,threshold); gen_checksum(set_energy_thres_802); error=gen_send(set_energy_thres_802); if(!error) { energyThreshold=threshold; } return error; }
/* Function: Set the Mac Mode, choosen between the 4 options (0/1/2/3) Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the MM command Parameters: mac: set the mac mode to use (0-3) */ uint8_t WaspXBee802::setMacMode(uint8_t mac) { int8_t error=2; error_AT=2; gen_data(set_mac_mode_802,mac); gen_checksum(set_mac_mode_802); error=gen_send(set_mac_mode_802); if(!error) { macMode=mac; } return error; }
/* Function: Set the maximum hops limit Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NH command Parameters: hops: max number of hops that an unicast message can make (0x00-0xFF) */ uint8_t WaspXBeeZB::setMaxUnicastHops(uint8_t hops) { int8_t error=2; error_AT=2; gen_data(set_max_uni_hops_ZB,hops); gen_checksum(set_max_uni_hops_ZB); error=gen_send(set_max_uni_hops_ZB); if(error==0) { maxUnicastHops=hops; } return error; }
/* Function: Configure options for encryption Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the EO command Parameters: eoptions: options for encryption (0x00-0xFF) */ uint8_t WaspXBeeZB::setEncryptionOptions(uint8_t eoptions) { int8_t error=2; error_AT=2; gen_data(set_encryp_options_ZB,eoptions); gen_checksum(set_encryp_options_ZB); error=gen_send(set_encryp_options_ZB); if(error==0) { encryptOptions=eoptions; } return error; }
/* Function: Set the join notification setting Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the JN command Parameters: notif: join notification setting (0-1) */ uint8_t WaspXBeeZB::setJoinNotification(uint8_t notif) { int8_t error=2; error_AT=2; gen_data(set_join_notif_ZB,notif); gen_checksum(set_join_notif_ZB); error=gen_send(set_join_notif_ZB); if(error==0) { joinNotification=notif; } return error; }
/* Function: Set the time that a Coordinator/Router allows nodes to join Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NJ command Parameters: time: time allowed for joining (0x00-0xFF) */ uint8_t WaspXBeeZB::setJoinTime(uint8_t time) { int8_t error=2; error_AT=2; gen_data(set_join_time_ZB,time); gen_checksum(set_join_time_ZB); error=gen_send(set_join_time_ZB); if(error==0) { joinTime=time; } return error; }
/* Function: Set time between consecutive aggregate route broadcast messages Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the AR command Parameters: anotif: time between consecutive aggregate route broadcast messages (0x00-0xFF) */ uint8_t WaspXBeeZB::setAggregateNotification(uint8_t anotif) { int8_t error=2; error_AT=2; gen_data(set_aggreg_notif_ZB,anotif); gen_checksum(set_aggreg_notif_ZB); error=gen_send(set_aggreg_notif_ZB); if(error==0) { aggregateNotification=anotif; } return error; }
/* Function: Set the channel verification parameter Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the JV command Parameters: verif: channel verification parameter (0-1) */ uint8_t WaspXBeeZB::setChannelVerification(uint8_t verif) { int8_t error=2; error_AT=2; gen_data(set_channel_verif_ZB,verif); gen_checksum(set_channel_verif_ZB); error=gen_send(set_channel_verif_ZB); if(error==0) { channelVerification=verif; } return error; }
/* Function: Set the ZigBee Stack profile Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the ZS command Parameters: profile: choosen stack profile (0-2) */ uint8_t WaspXBeeZB::setStackProfile(uint8_t profile) { int8_t error=2; error_AT=2; gen_data(set_stack_profile_ZB,profile); gen_checksum(set_stack_profile_ZB); error=gen_send(set_stack_profile_ZB); if(error==0) { stackProfile=profile; } return error; }
/* Function: Set the maximum number of hops for each broadcast data transmission Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the BH command Parameters: bhops: max number of hops a bradcast message can make (0x00-0x20) */ uint8_t WaspXBeeZB::setMaxBroadcastHops(uint8_t bhops) { int8_t error=2; error_AT=2; gen_data(set_max_brd_hops_ZB,bhops); gen_checksum(set_max_brd_hops_ZB); error=gen_send(set_max_brd_hops_ZB); if(error==0) { maxBroadcastHops=bhops; } return error; }
/* Function: Set the power mode of the device Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the PM command Parameters: power: power mode (0-1) */ uint8_t WaspXBeeZB::setPowerMode(uint8_t power) { int8_t error=2; error_AT=2; gen_data(set_power_mode_ZB,power); gen_checksum(set_power_mode_ZB); error=gen_send(set_power_mode_ZB); if(error==0) { powerMode=power; } return error; }
/* Function: Set the minimun value of the back-off exponent in CSMA/CA Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the RN command Parameters: exponent: value of the back-off exponential (0-3) */ uint8_t WaspXBee802::setDelaySlots(uint8_t exponent) { int8_t error=2; error_AT=2; gen_data(set_delay_slots_802,exponent); gen_checksum(set_delay_slots_802); error=gen_send(set_delay_slots_802); if(!error) { delaySlots=exponent; } return error; }
/* Function: Set the number of Sleep Periods to not assert XBee pin Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the SN command Parameters: periods: array which contains the number of sleep periods to sleep */ uint8_t WaspXBeeZB::setPeriodSleep(uint8_t* periods) { int8_t error=2; error_AT=2; gen_data(set_period_sleep_ZB,periods); gen_checksum(set_period_sleep_ZB); error=gen_send(set_period_sleep_ZB); if(error==0) { periodSleep[0]=periods[0]; periodSleep[1]=periods[1]; } return error; }
/* Function: Reads the DBM level of the designated channel Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "channelRSSI" variable the DBM level of the designated channel Parameters: channel --> The channel to get the DBM value */ uint8_t WaspXBee868::getChannelRSSI(uint8_t channel) { int8_t error=2; error_AT=2; gen_data(get_channel_RSSI_868,channel); gen_checksum(get_channel_RSSI_868); error=gen_send(get_channel_RSSI_868); if(error==0) { channelRSSI=data[1]; delay(20); } return error; }
/* Function: Set the maximum number of retries to execute in addition to the three retries defined in the 802.15.4 protocol Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the RR command Parameters: retry: number of retries (0-6) */ uint8_t WaspXBee802::setRetries(uint8_t retry) { int8_t error=2; error_AT=2; gen_data(set_retries_802,retry); gen_checksum(set_retries_802); error=gen_send(set_retries_802); if(!error) { retries=retry; } return error; }
/* Function: Reads the DBM level of the designated channel Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "channelRSSI" variable the DBM level of the designated channel Parameters: channel --> The channel to get the DBM value */ uint8_t WaspXBeeDM::getChannelRSSI(uint8_t channel) { int8_t error=2; error_AT=2; gen_data(get_channel_RSSI_DM,channel); gen_checksum(get_channel_RSSI_DM); error=gen_send(get_channel_RSSI_DM); if(!error) { channelRSSI=data[1]; delay(20); } return error; }
/* Function: Set the maximum number of network packet delivery attempts Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the MR command Parameters: mesh: maximum number of attempts (0-7) */ uint8_t WaspXBeeDM::setMeshNetworkRetries(uint8_t mesh) { int8_t error=2; error_AT=2; char buffer[20]; // set_network_retries_DM strcpy_P(buffer, (char*)pgm_read_word(&(table_DM[10]))); gen_data(buffer,mesh); gen_checksum(buffer); error=gen_send(buffer); if(error==0) { meshNetRetries=mesh; } return error; }
/* Function: Set the maximum number of route discovery retries allowed to find a path to the destination node. Only valid for XBee900 protocol. Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NQ command Parameters: route: maximum number of route discovery retries (0-0x0A) */ uint8_t WaspXBeeDM::setNetworkRouteRequests(uint8_t route) { int8_t error=2; error_AT=2; char buffer[20]; // set_network_route_DM strcpy_P(buffer, (char*)pgm_read_word(&(table_DM[8]))); gen_data(buffer,route); gen_checksum(buffer); error=gen_send(buffer); if(error==0) { netRouteRequest=route; } return error; }
/* Function: Set the maximum random number of network delay slots before rebroadcasting a network packet Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NN command Parameters: dslots: maximum number of delay slots (0-0x0A) */ uint8_t WaspXBeeDM::setNetworkDelaySlots(uint8_t dslots) { int8_t error=2; error_AT=2; char buffer[20]; // set_network_delay_DM strcpy_P(buffer, (char*)pgm_read_word(&(table_DM[6]))); gen_data(buffer,dslots); gen_checksum(buffer); error=gen_send(buffer); if(error==0) { netDelaySlots=dslots; } return error; }
/* Function: Set the maximum number of retries to execute in addition to the three retries defined in the 802.15.4 protocol Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the RR command Parameters: retry: number of retries (0-6) */ uint8_t WaspXBee802::setRetries(uint8_t retry) { int8_t error=2; error_AT=2; char buffer[20]; strcpy_P(buffer, (char*)pgm_read_word(&(table_802[0])));//set_retries_802 gen_data(buffer,retry); gen_checksum(buffer); error=gen_send(buffer); if(!error) { retries=retry; } return error; }
/* Function: Set the current device type Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the DD command Parameters: type: current device type (0-0xFFFFFFFF) */ uint8_t WaspXBeeZB::setDeviceType(uint8_t* type) { int8_t error=2; error_AT=2; gen_data(set_device_type_ZB,type); gen_checksum(set_device_type_ZB); error=gen_send(set_device_type_ZB); if(error==0) { for(it=0;it<4;it++) { deviceType[it]=type[it]; } } return error; }
/* Function: Set the 128-bit AES encryption key Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NK command Parameters: key: 16 position array that contains the 128b AES key (0-0xFFFFFFFFFFFFFFFF) */ uint8_t WaspXBeeZB::setNetworkKey(const char* key) { int8_t error=2; error_AT=2; gen_data(set_netwk_key_ZB,key); gen_checksum(set_netwk_key_ZB); error=gen_send(set_netwk_key_ZB); if(error==0) { for(it=0;it<16;it++) { networkKey[it]=key[it]; } } return error; }
/* Function: Set the maximum number of hops expected to be seen in a network route Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NH command Parameters: nhops: maximum number of hops (1-0xFF) */ uint8_t WaspXBeeDM::setNetworkHops(uint8_t nhops) { int8_t error=2; error_AT=2; char buffer[20]; // set_network_hops_DM strcpy_P(buffer, (char*)pgm_read_word(&(table_DM[4]))); gen_data(buffer,nhops); gen_checksum(buffer); error=gen_send(buffer); if(!error) { networkHops=nhops; } return error; }
/* Function: Reads the DBM level of the designated channel Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "channelRSSI" variable the DBM level of the designated channel Parameters: channel --> The channel to get the DBM value */ uint8_t WaspXBeeDM::getChannelRSSI(uint8_t channel) { int8_t error=2; error_AT=2; char buffer[20]; // get_channel_RSSI_DM strcpy_P(buffer, (char*)pgm_read_word(&(table_DM[2]))); gen_data(buffer,channel); gen_checksum(buffer); error=gen_send(buffer); if(!error) { channelRSSI=data[1]; } return error; }
/* Function: Specifies the number of retries than can be sent for a given unicast RF packet Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the RR command Parameters: macretries: number of retries than can be sent for a given unicast RF packet (0x00-0x0F) Default value: 0x0A */ uint8_t WaspXBee868::setMacRetries(uint8_t macretries) { int8_t error=2; error_AT=2; char buffer[20]; // set_retries_868 strcpy_P(buffer, (char*)pgm_read_word(&(table_868[10]))); gen_data(buffer,macretries); gen_checksum(buffer); error=gen_send(buffer); if(error==0) { macRetries=macretries; } return error; }
/* Function: Specifies the number of additional broadcast retransmissions Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the MT command Parameters: mtrans: number of additional broadcast retransmissions (Range: 0x00-0x0F). Default: 0x03 */ uint8_t WaspXBee868::setMultipleBroadcast(uint8_t mtrans) { int8_t error=2; error_AT=2; char buffer[20]; // set_mult_broadcast_868 strcpy_P(buffer, (char*)pgm_read_word(&(table_868[8]))); gen_data(buffer,mtrans); gen_checksum(buffer); error=gen_send(buffer); if(error==0) { multipleBroadcast=mtrans; } return error; }