/** * \brief Configure the TAL PIB's relevant to the Performance analyzer * application * \ingroup group_app_init */ static void configure_pibs(void) { uint16_t temp_word; pib_value_t pib_value; uint8_t temp_byte; /* Set Default address. */ temp_word = CCPU_ENDIAN_TO_LE16(DEFAULT_ADDR); pib_value.pib_value_16bit = temp_word; tal_pib_set(macShortAddress, &pib_value); /* Set PAN ID. */ temp_word = CCPU_ENDIAN_TO_LE16(SRC_PAN_ID); pib_value.pib_value_16bit = temp_word; tal_pib_set(macPANId, &pib_value); /* Set channel. */ temp_byte = (uint8_t)DEFAULT_CHANNEL; pib_value.pib_value_8bit = temp_byte; tal_pib_set(phyCurrentChannel, &pib_value); /* Set IEEE address - To make sure that trx registers written properly **/ tal_pib_set(macIeeeAddress, (pib_value_t *)&tal_pib.IeeeAddress); }
/** * @brief Configure the frame sending * * Prepares the static contents of the frame buffer and * writes settings to the TAL pib. */ static void configure_frame_sending(void) { uint8_t temp_value_8; uint16_t temp_value_16; uint16_t fcf = 0; /* Set initial frame length to MHR length without additional MSDU. */ tx_buffer[0] = FRAME_OVERHEAD; /* Calculate FCF. */ fcf = FCF_FRAMETYPE_DATA | FCF_ACK_REQUEST; fcf |= FCF_SET_SOURCE_ADDR_MODE(FCF_SHORT_ADDR); fcf |= FCF_SET_DEST_ADDR_MODE(FCF_SHORT_ADDR); #if (DST_PAN_ID == SRC_PAN_ID) fcf |= FCF_PAN_ID_COMPRESSION; #endif /* Set FCF in frame. */ convert_16_bit_to_byte_array(fcf, &tx_buffer[PL_POS_FCF_1]); /* Set initial sequence number. */ tx_buffer[PL_POS_SEQ_NUM] = (uint8_t)rand(); /* Set Destination PAN-Id in frame. */ temp_value_16 = DEFAULT_PAN_ID; convert_16_bit_to_byte_array(temp_value_16, &tx_buffer[PL_POS_DST_PAN_ID_START]); /* Set Destination Address in frame. */ temp_value_16 = DST_SHORT_ADDR; convert_16_bit_to_byte_array(temp_value_16, &tx_buffer[PL_POS_DST_ADDR_START]); /* Set Source PAN-Id in frame. */ temp_value_16 = DEFAULT_PAN_ID; tal_pib_set(macPANId, (pib_value_t *)&temp_value_16); #if (DST_PAN_ID != SRC_PAN_ID) convert_16_bit_to_byte_array(temp_value_16, &tx_buffer[PL_POS_DST_ADDR_START + 2]); #endif /* Set Source Address in frame. */ temp_value_16 = OWN_SHORT_ADDR; tal_pib_set(macShortAddress, (pib_value_t *)&temp_value_16); #if (DST_PAN_ID != SRC_PAN_ID) convert_16_bit_to_byte_array(temp_value_16, &tx_buffer[PL_POS_DST_ADDR_START + 4]); #else convert_16_bit_to_byte_array(temp_value_16, &tx_buffer[PL_POS_DST_ADDR_START + 2]); #endif /* Set proper channel. */ temp_value_8 = DEFAULT_CHANNEL; tal_pib_set(phyCurrentChannel, (pib_value_t *)&temp_value_8); }
/** * \brief Peer rsp received state init function * * \arg argument to be used in init function */ static void peer_rsp_rcvd_init(void *arg) { /* Set the newly assigned address */ tal_pib_set(macShortAddress, (pib_value_t *)arg); if (send_peer_conf()) { /* Print messge if the Peer search failed in Range mode */ if (PEER_SEARCH_RANGE_TX == node_info.main_state) { print_event(PRINT_PEER_SEARCH_FAILED); } else if (PEER_SEARCH_PER_TX == node_info.main_state) { /* Send the confirmation to the PC application via Serial interface */ usr_perf_start_confirm(NO_PEER_FOUND, START_MODE_PER, NULL, NUL_VAL, NULL, NULL, NULL, NUL_VAL); } /* PEER CONF send failed - so change to WAIT_FOR_EVENT state*/ set_main_state(WAIT_FOR_EVENT, NULL); } }
/* * \brief Application task to start peer search * * \param arg arguments to start the peer search */ void peer_search_initiator_init(void *arg) { /* Change LED pattern */ app_led_event(LED_EVENT_START_PEER_SEARCH); /* Print the message if it is Range measurement mode */ if (PEER_SEARCH_RANGE_TX == node_info.main_state) { print_event(PRINT_PEER_SEARCH_INITATED); } /* Peer search process seq number */ seq_num = rand(); /* assign a random address */ do { node_info.peer_short_addr = (uint16_t)rand(); /* Make sure random number is not zero */ } while (!node_info.peer_short_addr); /* Reduce the TX power level to minium,if configuration mode is enabled */ if (true == node_info.configure_mode) { /* set the tx power to lowest in configuration mode */ uint8_t config_tx_pwr = CONFIG_MODE_TX_PWR; tal_pib_set(phyTransmitPower, (pib_value_t *)&config_tx_pwr); } /* Keep compiler happy */ arg = arg; }
/* * \brief Application task to start peer search * * \param mode starts the peer search in this particular mode */ void peer_search_receptor_init(void *arg) { pib_value_t pib_value; peer_search_receptor_arg_t *arg_ptr = (peer_search_receptor_arg_t *)arg; /* Change LED pattern */ app_led_event(LED_EVENT_START_PEER_SEARCH); /* Peer process seq number */ seq_num = rand(); /* assign a random address */ do { node_info.peer_short_addr = rand(); /* Make sure random number is not zero */ } while (!node_info.peer_short_addr); /* Set my address which my peer send me */ pib_value.pib_value_16bit = arg_ptr->my_short_addr; tal_pib_set(macShortAddress, &pib_value); #ifdef EXT_RF_FRONT_END_CTRL /* Disable RF front end control during peer search process*/ tal_ext_pa_ctrl(PA_EXT_DISABLE); /* Make sure that Tx power is at max, when PA_EXT is disabled */ tal_set_tx_pwr(REGISTER_VALUE, 0x00); #endif }
static void run_tal_pib_set_test(const struct test_case *test) { retval_t status; uint8_t temp; temp = DEFAULT_CHANNEL; status = tal_pib_set(phyCurrentChannel, (pib_value_t *)&temp); test_assert_true(test, status == MAC_SUCCESS, "AVR2025_MAC - TAL Setting Current Channel failed"); temp = DEFAULT_CHANNEL_PAGE; status = tal_pib_set(phyCurrentPage, (pib_value_t *)&temp); test_assert_true(test, status == MAC_SUCCESS, "AVR2025_MAC - TAL Setting Current Page failed"); }
/** * @brief Wakes-up the radio and sets the corresponding TAL PIB attribute * * @param attribute PIB attribute to be set * @param attribute_value Attribute value to be set * * @return Status of the attempt to set the TAL PIB attribute */ retval_t set_tal_pib_internal(uint8_t attribute, pib_value_t *attribute_value) { retval_t status; if (RADIO_SLEEPING == mac_radio_sleep_state) { /* Wake up the radio */ mac_trx_wakeup(); status = tal_pib_set(attribute, attribute_value); /* Set radio to sleep if allowed */ mac_sleep_trans(); } else { status = tal_pib_set(attribute, attribute_value); } return status; }
/** * \brief Recover all user settings before Start of CW transmission */ void recover_all_settings(void) { int8_t tx_pwr_dbm; uint8_t temp_var; pib_value_t pib_value; #if (ANTENNA_DIVERSITY == 1) if (ANT_DIV_DISABLE == ant_div_before_ct) { tal_ant_div_config(ANT_DIVERSITY_DISABLE, ant_sel_before_ct); } #endif #if (TAL_TYPE == AT86RF233) /* Set the ISM frequency back */ if (CC_BAND_0 != cc_band_ct) { tal_set_frequency_regs(cc_band_ct, cc_number_ct); } #endif /* End of #if(TAL_TYPE == AT86RF233) */ /*RPC settings are reseted during tal_reset,hence reconfiguring based *on old config*/ #if ((TAL_TYPE == ATMEGARFR2)||(TAL_TYPE == AT86RF233)) if (true == curr_trx_config_params.rpc_enable) { /* RPC feature configuration. */ tal_rpc_mode_config(ENABLE_ALL_RPC_MODES); } else { tal_rpc_mode_config(DISABLE_ALL_RPC_MODES); } #endif #if (TAL_TYPE != AT86RF230B) /* set the desensitization settings back */ if (true == curr_trx_config_params.rx_desensitize) { tal_set_rx_sensitivity_level(RX_DESENSITIZE_LEVEL); } #endif #if ((TAL_TYPE != AT86RF212) && (TAL_TYPE != AT86RF212B)) if (last_tx_power_format_set == 0) { uint8_t tx_pwr_reg = curr_trx_config_params.tx_power_reg; tal_set_tx_pwr(REGISTER_VALUE, tx_pwr_reg); } else #endif { tx_pwr_dbm = curr_trx_config_params.tx_power_dbm; temp_var = CONV_DBM_TO_phyTransmitPower(tx_pwr_dbm); pib_value.pib_value_8bit = temp_var; tal_pib_set(phyTransmitPower, &pib_value); } }
retval_t tal_set_tx_pwr(bool type, int8_t pwr_value) { uint64_t temp_var; int8_t tx_pwr_dbm = 0; /* modify the register for tx_pwr and set the tal_pib accordingly */ if (true == type) { if (MAC_SUCCESS == tal_convert_reg_value_to_dBm(pwr_value, &tx_pwr_dbm)) { temp_var = CONV_DBM_TO_phyTransmitPower(tx_pwr_dbm); tal_pib_set(phyTransmitPower, (pib_value_t *)&temp_var); /* To make sure that TX_PWR register is updated with the * value whatever user povided.Otherwise lowest dBm * power * (highest reg value will be taken) */ trx_bit_write(SR_TX_PWR, pwr_value); #if (TAL_TYPE == ATMEGARFA1) CONF_REG_WRITE(); #endif /* TAL_TYPE == ATMEGA128RFA1 */ return MAC_SUCCESS; } else { /* return invalid parameter if out of range */ return MAC_INVALID_PARAMETER; } } else { temp_var = CONV_DBM_TO_phyTransmitPower(pwr_value); tal_pib_set(phyTransmitPower, (pib_value_t *)&temp_var); } uint8_t reg_value = convert_phyTransmitPower_to_reg_value( tal_pib.TransmitPower); /* check the value written in the transceiver register */ uint8_t temp = trx_bit_read(SR_TX_PWR); if (temp == reg_value) { return MAC_SUCCESS; } else { return FAILURE; } }
/** * \brief Function to exit the peer rsp rcvd state. * * This function * - Implements the peer search state machine. */ static void peer_rsp_rcvd_exit() { /* Disable the configuration mode if the peer search is failed*/ if (true == node_info.configure_mode) { /* set the TX power to default level */ uint8_t config_tx_pwr = TAL_TRANSMIT_POWER_DEFAULT; node_info.configure_mode = false; tal_pib_set(phyTransmitPower, (pib_value_t *)&config_tx_pwr); } }
/* * \brief handle the tx power settings in case of External PA enabled, * and the channel changes from or to 26.This is to meet the FCC compliance * * \param Current channel and Previous channel */ void limit_tx_power_in_ch26(uint8_t curr_chnl, uint8_t prev_chnl) { pib_value_t pib_value; /* If the cuurent channel set to 26*/ if (curr_chnl == CHANNEL_26) { /* Get last previous non 26 channel tx power */ if (prev_chnl != CHANNEL_26) { tal_pib_get(phyTransmitPower, &prev_non_26chn_tx_power); } /* If the Tx power is more than 13dBm, i.e. TX_PWR < 0x0d */ if (trx_bit_read(SR_TX_PWR) <= MAX_TX_PWR_REG_VAL_CH26) { pib_value.pib_value_8bit = DEFAULT_TX_POWER_CH26; tal_pib_set(phyTransmitPower, &pib_value); curr_trx_config_params.tx_power_reg = trx_bit_read( SR_TX_PWR); curr_trx_config_params.tx_power_dbm = CONV_phyTransmitPower_TO_DBM( pib_value.pib_value_8bit); } } else { /* if the channel changed from 26 to other */ if (prev_chnl == CHANNEL_26) { /* Set back the tx power to default value i.e. 20dBm, *TX_PWR 0x09 */ pib_value.pib_value_8bit = prev_non_26chn_tx_power; tal_pib_set(phyTransmitPower, &pib_value); curr_trx_config_params.tx_power_reg = trx_bit_read( SR_TX_PWR); curr_trx_config_params.tx_power_dbm = CONV_phyTransmitPower_TO_DBM( pib_value.pib_value_8bit); } } }
/* * \brief Application task to start peer search * * \param mode starts the peer search in this particular mode */ void peer_search_receptor_init(trx_id_t trx, void *arg) { peer_search_receptor_arg_t *arg_ptr = (peer_search_receptor_arg_t *)arg; /* Change LED pattern */ app_led_event(LED_EVENT_START_PEER_SEARCH); /* Peer process seq number */ seq_num[trx] = rand(); /* assign a random address */ do { node_info[trx].peer_short_addr = rand(); /* Make sure random number is not zero */ } while (!node_info[trx].peer_short_addr); /* Set my address which my peer send me */ tal_pib_set(trx, macShortAddress, (pib_value_t *)&(arg_ptr->my_short_addr)); }
/* * \brief Application task to start peer search * * \param arg arguments to start the peer search */ void peer_search_initiator_init(void *arg) { pib_value_t pib_value_temp; /* Change LED pattern */ app_led_event(LED_EVENT_START_PEER_SEARCH); /* Print the message if it is Range measurement mode */ if (PEER_SEARCH_RANGE_TX == node_info.main_state) { print_event(PRINT_PEER_SEARCH_INITATED); } /* Peer search process seq number */ seq_num = rand(); /* assign a random address */ do { node_info.peer_short_addr = (uint16_t)rand(); /* Make sure random number is not zero */ } while (!node_info.peer_short_addr); #ifdef EXT_RF_FRONT_END_CTRL /* Disable RF front end control during peer search process*/ tal_ext_pa_ctrl(PA_EXT_DISABLE); /* Make sure that Tx power is at max, when PA_EXT is disabled */ tal_set_tx_pwr(REGISTER_VALUE, 0x00); #endif /* Reduce the TX power level to minium,if configuration mode is enabled **/ if (true == node_info.configure_mode) { /* set the tx power to lowest in configuration mode */ uint8_t config_tx_pwr = CONFIG_MODE_TX_PWR; pib_value_temp.pib_value_8bit = config_tx_pwr; tal_pib_set(phyTransmitPower, &pib_value_temp); } /* Keep compiler happy */ arg = arg; }
/** * \brief Function to set trx configure parameters * */ void config_per_test_parameters(void) { uint8_t temp; pib_value_t pib_value; /* Set the default values */ curr_trx_config_params.ack_request = default_trx_config_params.ack_request = true; curr_trx_config_params.csma_enabled = default_trx_config_params.csma_enabled = true; curr_trx_config_params.retry_enabled = default_trx_config_params.retry_enabled = false; #if (ANTENNA_DIVERSITY == 1) #if (TAL_TYPE == AT86RF233) /* Disable antenna diversity by default. */ curr_trx_config_params.antenna_diversity = default_trx_config_params.antenna_diversity = false; curr_trx_config_params.antenna_selected = default_trx_config_params.antenna_selected = ANT_CTRL_1; /* This is required for set default config request command to set the * config parameters to their defaults */ /* Disable antenna diversity by default */ /* Enable A1/X2 */ tal_ant_div_config(ANT_DIVERSITY_DISABLE, ANT_CTRL_1); /* Enable A1/X2 **/ #else curr_trx_config_params.antenna_diversity = default_trx_config_params.antenna_diversity = true; curr_trx_config_params.antenna_selected = default_trx_config_params.antenna_selected = ANT_CTRL_0; /* Enable Antenna Diversity*/ tal_ant_div_config(ANT_DIVERSITY_ENABLE, ANTENNA_DEFAULT); #endif /* end of (TAL_TYPE == AT86RF233) */ #endif #if (TAL_TYPE != AT86RF230B) /* Disable desensitization by default */ curr_trx_config_params.rx_desensitize = default_trx_config_params.rx_desensitize = false; /* Disable Rx desensitization */ tal_set_rx_sensitivity_level(NO_RX_DESENSITIZE_LEVEL); #endif /* End of #if(TAL_TYPE != AT86RF230B)*/ #if ((TAL_TYPE == AT86RF233) || (TAL_TYPE == ATMEGARFR2)) curr_trx_config_params.rpc_enable = default_trx_config_params.rpc_enable = false; /* Enable RPC feature by default */ tal_rpc_mode_config(DISABLE_ALL_RPC_MODES); /* Reset RX_SAFE Mode in TRX_CTRL_2 */ tal_trx_reg_write(RG_TRX_CTRL_2, ENABLE_RX_SAFE_MODE); #endif if (peer_found == true) { curr_trx_config_params.trx_state = default_trx_config_params.trx_state = RX_AACK_ON; } else { curr_trx_config_params.trx_state = default_trx_config_params.trx_state = TRX_OFF; } curr_trx_config_params.number_test_frames = default_trx_config_params.number_test_frames = DEFAULT_NO_OF_TEST_FRAMES; curr_trx_config_params.phy_frame_length = default_trx_config_params.phy_frame_length = DEFAULT_FRAME_LENGTH; /* As channel & channel page are already configured during * the application initialization so get it */ curr_trx_config_params.channel = default_trx_config_params.channel = DEFAULT_CHANNEL; pib_value.pib_value_8bit = (uint8_t)default_trx_config_params.channel; tal_pib_set(phyCurrentChannel, &pib_value); /* Make the ISM frequency as null as IEEE channel is set in default case **/ #if (TAL_TYPE == AT86RF233) curr_trx_config_params.ism_frequency = default_trx_config_params.ism_frequency = 0.0; #endif curr_trx_config_params.channel_page = default_trx_config_params.channel_page = TAL_CURRENT_PAGE_DEFAULT; pib_value.pib_value_8bit = default_trx_config_params.channel_page; tal_pib_set(phyCurrentPage, &pib_value); /* As tx power is already configure by TAL in tal_pib.c get it for * application*/ temp = TAL_TRANSMIT_POWER_DEFAULT; pib_value.pib_value_8bit = temp; tal_pib_set(phyTransmitPower, &pib_value); curr_trx_config_params.tx_power_dbm = default_trx_config_params.tx_power_dbm = CONV_phyTransmitPower_TO_DBM( TAL_TRANSMIT_POWER_DEFAULT); #if ((TAL_TYPE != AT86RF212) && (TAL_TYPE != AT86RF212B)) tal_get_curr_trx_config(TX_PWR, &(curr_trx_config_params.tx_power_reg)); tal_get_curr_trx_config(TX_PWR, &(default_trx_config_params.tx_power_reg)); #endif /* The following fields has no meaning if there is no peer */ if (true == peer_found) { #ifdef CRC_SETTING_ON_REMOTE_NODE curr_trx_config_params.crc_settings_on_peer = default_trx_config_params.crc_settings_on_peer = false; #endif /* Set the config parameters on peer node */ #if (ANTENNA_DIVERSITY == 1) #if (TAL_TYPE == AT86RF233) curr_trx_config_params.antenna_diversity_on_peer = default_trx_config_params. antenna_diversity_on_peer = false; curr_trx_config_params.antenna_selected_on_peer = default_trx_config_params. antenna_selected_on_peer = ANT_CTRL_1; #else curr_trx_config_params.antenna_diversity_on_peer = default_trx_config_params. antenna_diversity_on_peer = true; curr_trx_config_params.antenna_selected_on_peer = default_trx_config_params. antenna_selected_on_peer = ANT_CTRL_0; #endif /* End of #if(TAL_TYPE == AT86RF233) */ #endif /* End of #if (ANTENNA_DIVERSITY == 1) */ } }
retval_t mlme_set(uint8_t attribute, pib_value_t *attribute_value, bool set_trx_to_sleep) #endif { /* * Variables indicates whether the transceiver has been woken up for * setting a TAL PIB attribute. */ static bool trx_pib_wakeup; retval_t status = MAC_SUCCESS; switch (attribute) { #if (MAC_ASSOCIATION_REQUEST_CONFIRM == 1) case macAssociatedPANCoord: mac_pib.mac_AssociatedPANCoord = attribute_value->pib_value_8bit; break; #endif /* (MAC_ASSOCIATION_REQUEST_CONFIRM == 1) */ #if ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT)) case macMaxFrameTotalWaitTime: mac_pib.mac_MaxFrameTotalWaitTime = attribute_value->pib_value_16bit; break; #endif /* ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT)) */ case macResponseWaitTime: mac_pib.mac_ResponseWaitTime = attribute_value->pib_value_16bit; break; case macAutoRequest: #if (MAC_BEACON_NOTIFY_INDICATION == 1) /* * If the beacon notification indications are not included * in the build, macAutoRequest can be changed as desired, since * beacon frames will be indicated to the higher * layer if required as defined by IEEE 802.15.4. */ mac_pib.mac_AutoRequest = attribute_value->pib_value_8bit; break; #else /* * If the beacon notification indications are not included * in the build, macAutoRequest must not be changed, since * beacon frames will never be indicated to the higher * layer, i.e. the higher would not be able to act on * received beacon frame information itself. */ status = MAC_INVALID_PARAMETER; break; #endif /* (MAC_BEACON_NOTIFY_INDICATION == 1) */ #ifdef GTS_SUPPORT case macGTSPermit: mac_pib.mac_GTSPermit = attribute_value->pib_value_8bit; break; #endif /* GTS_SUPPORT */ case macBattLifeExtPeriods: mac_pib.mac_BattLifeExtPeriods = attribute_value->pib_value_8bit; break; #if (MAC_ASSOCIATION_INDICATION_RESPONSE == 1) case macAssociationPermit: mac_pib.mac_AssociationPermit = attribute_value->pib_value_8bit; break; #endif /* (MAC_ASSOCIATION_INDICATION_RESPONSE == 1) */ #if (MAC_START_REQUEST_CONFIRM == 1) case macBeaconPayload: memcpy(mac_beacon_payload, attribute_value, mac_pib.mac_BeaconPayloadLength); break; case macBeaconPayloadLength: #ifndef REDUCED_PARAM_CHECK /* * If the application sits directly on top of the MAC, * this is also checked in mac_api.c. */ if (attribute_value->pib_value_8bit > aMaxBeaconPayloadLength) { status = MAC_INVALID_PARAMETER; break; } #endif /* REDUCED_PARAM_CHECK */ mac_pib.mac_BeaconPayloadLength = attribute_value->pib_value_8bit; break; case macBSN: mac_pib.mac_BSN = attribute_value->pib_value_8bit; break; #endif /* (MAC_START_REQUEST_CONFIRM == 1) */ #if (MAC_INDIRECT_DATA_FFD == 1) case macTransactionPersistenceTime: mac_pib.mac_TransactionPersistenceTime = attribute_value->pib_value_16bit; break; #endif /* (MAC_INDIRECT_DATA_FFD == 1) */ case macCoordExtendedAddress: mac_pib.mac_CoordExtendedAddress = attribute_value->pib_value_64bit; break; case macCoordShortAddress: mac_pib.mac_CoordShortAddress = attribute_value->pib_value_16bit; break; case macDSN: mac_pib.mac_DSN = attribute_value->pib_value_8bit; break; case macRxOnWhenIdle: mac_pib.mac_RxOnWhenIdle = attribute_value->pib_value_8bit; /* Check whether radio state needs to change now, */ if (mac_pib.mac_RxOnWhenIdle) { /* Check whether the radio needs to be woken up. */ mac_trx_wakeup(); /* Set transceiver in rx mode, otherwise it may stay in * TRX_OFF). */ tal_rx_enable(PHY_RX_ON); } else { /* Check whether the radio needs to be put to sleep. */ mac_sleep_trans(); } break; case macBattLifeExt: case macBeaconOrder: case macMaxCSMABackoffs: case macMaxBE: case macMaxFrameRetries: case macMinBE: case macPANId: #ifdef PROMISCUOUS_MODE case macPromiscuousMode: #endif /* PROMISCUOUS_MODE */ case macShortAddress: case macSuperframeOrder: case macIeeeAddress: case phyCurrentChannel: case phyCurrentPage: case phyTransmitPower: case phyCCAMode: #ifdef TEST_HARNESS case macPrivateCCAFailure: case macPrivateDisableACK: #endif /* TEST_HARNESS */ { /* Now only TAL PIB attributes are handled anymore. */ status = tal_pib_set(attribute, attribute_value); if (status == TAL_TRX_ASLEEP) { /* * Wake up the transceiver and repeat the * attempt * to set the TAL PIB attribute. */ tal_trx_wakeup(); status = tal_pib_set(attribute, attribute_value); if (status == MAC_SUCCESS) { /* * Set flag indicating that the trx has * been woken up * during PIB setting. */ trx_pib_wakeup = true; } } #if ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT)) /* * In any case that the PIB setting was successful (no * matter * whether the trx had to be woken up or not), the PIB * attribute * recalculation needs to be done. */ if (status == MAC_SUCCESS) { /* * The value of the PIB attribute * macMaxFrameTotalWaitTime depends on the * values of the * following PIB attributes: * macMinBE * macMaxBE * macMaxCSMABackoffs * phyMaxFrameDuration * In order to save code space and since * changing of PIB * attributes is going to happen not too often, * this is done * always whenever a PIB attribute residing in * TAL is changed * (since all above mentioned PIB attributes are * in TAL). */ recalc_macMaxFrameTotalWaitTime(); } #endif /* ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT)) */ } break; case macAckWaitDuration: default: status = MAC_UNSUPPORTED_ATTRIBUTE; break; #if ((defined MAC_SECURITY_ZIP) || (defined MAC_SECURITY_2006)) case macSecurityEnabled: mac_pib.mac_SecurityEnabled = attribute_value->pib_value_8bit; break; case macKeyTable: if (attribute_index >= mac_sec_pib.KeyTableEntries) { status = MAC_INVALID_INDEX; } else { memcpy(&mac_sec_pib.KeyTable[attribute_index], attribute_value, sizeof(mac_key_table_t)); } break; case macKeyTableEntries: if (attribute_value->pib_value_8bit > MAC_ZIP_MAX_KEY_TABLE_ENTRIES) { status = MAC_INVALID_PARAMETER; } else { mac_sec_pib.KeyTableEntries = attribute_value->pib_value_8bit; } break; case macDeviceTable: if (attribute_index >= mac_sec_pib.DeviceTableEntries) { status = MAC_INVALID_INDEX; } else { uint8_t *attribute_temp_ptr = (uint8_t *)attribute_value; /* * Since the members of the mac_dev_table_t structure do * contain padding bytes, * each member needs to be filled in separately. */ /* PAN-Id */ memcpy((uint8_t *)&mac_sec_pib.DeviceTable[ attribute_index].DeviceDescriptor[ 0].PANId, attribute_temp_ptr, sizeof(uint16_t)); /* * *ADDR_COPY_DST_SRC_16(mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[0].PANId, *(uint16_t *)attribute_temp_ptr); */ attribute_temp_ptr += sizeof(uint16_t); /* Short Address */ memcpy((uint8_t *)&mac_sec_pib.DeviceTable[ attribute_index].DeviceDescriptor[ 0].ShortAddress, attribute_temp_ptr, sizeof(uint16_t)); /*ADDR_COPY_DST_SRC_16(mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[0].ShortAddress, *(uint16_t *)attribute_temp_ptr);*/ attribute_temp_ptr += sizeof(uint16_t); /* Extended Address */ memcpy((uint8_t *)&mac_sec_pib.DeviceTable[ attribute_index].DeviceDescriptor[ 0].ExtAddress, attribute_temp_ptr, sizeof(uint64_t)); /*ADDR_COPY_DST_SRC_64(mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[0].ExtAddress, *(uint64_t *)attribute_temp_ptr);*/ attribute_temp_ptr += sizeof(uint64_t); /* Extended Address */ memcpy( &mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[ 0].FrameCounter, attribute_temp_ptr, sizeof(uint32_t)); attribute_temp_ptr += sizeof(uint32_t); /* Exempt */ mac_sec_pib.DeviceTable[attribute_index]. DeviceDescriptor[0].Exempt = *attribute_temp_ptr; } break; case macDeviceTableEntries: if (attribute_value->pib_value_16bit > MAC_ZIP_MAX_DEV_TABLE_ENTRIES) { status = MAC_INVALID_PARAMETER; } else { mac_sec_pib.DeviceTableEntries = attribute_value->pib_value_16bit; } break; case macSecurityLevelTable: if (attribute_index >= mac_sec_pib.SecurityLevelTableEntries) { status = MAC_INVALID_INDEX; } else { memcpy(&mac_sec_pib.SecurityLevelTable[attribute_index], attribute_value, sizeof(mac_sec_lvl_table_t)); } break; case macSecurityLevelTableEntries: if (attribute_value->pib_value_8bit > MAC_ZIP_MAX_SEC_LVL_TABLE_ENTRIES) { status = MAC_INVALID_PARAMETER; } else { mac_sec_pib.SecurityLevelTableEntries = attribute_value->pib_value_8bit; } break; case macFrameCounter: mac_sec_pib.FrameCounter = attribute_value->pib_value_32bit; break; case macDefaultKeySource: /* Key Source length is 8 octets. */ memcpy(mac_sec_pib.DefaultKeySource, attribute_value, 8); break; case macPANCoordExtendedAddress: memcpy(mac_sec_pib.PANCoordExtendedAddress, attribute_value, 8); break; case macPANCoordShortAddress: mac_sec_pib.PANCoordShortAddress = attribute_value->pib_value_16bit; break; #endif /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */ #ifdef TEST_HARNESS case macPrivateIllegalFrameType: mac_pib.privateIllegalFrameType = attribute_value->pib_value_8bit; break; case macPrivateNoDataAfterAssocReq: mac_pib.privateNoDataAfterAssocReq = attribute_value->pib_value_8bit; break; case macPrivateVirtualPANs: mac_pib.privateVirtualPANs = attribute_value->pib_value_8bit; break; #endif /* TEST_HARNESS */ } /* * In case the transceiver shall be forced back to sleep and * has been woken up, it is put back to sleep again. */ if (set_trx_to_sleep && trx_pib_wakeup && !mac_pib.mac_RxOnWhenIdle) { #ifdef ENABLE_DEEP_SLEEP tal_trx_sleep(DEEP_SLEEP_MODE); #else tal_trx_sleep(SLEEP_MODE_1); #endif trx_pib_wakeup = false; } return status; }