/** * @brief Notify the application of the status of its request to start a network. * * The NLME-START.confirm primitive allows the NLME to notify the application of * the status of its request to start a network. * * @param Status nwk status */ void nlme_start_confirm(nwk_enum_t Status) { if (node_status == ALL_IN_ONE_START) { /* Fix a channel, basic functionality */ uint8_t channel = 25; nlme_set_request(nwkBaseChannel, 0, &channel); } }
/** * @brief Prints the sub menu for the base channel change. */ static void print_ch_change_submenu(void) { char input_char[3] = {0, 0, 0}; uint8_t channel; uint8_t i; uint8_t input; #if (RF_BAND == BAND_900) printf("Enter new base channel (1, 4, or 7): \r\n"); #else printf("Enter new base channel (15, 20, or 25): \r\n"); #endif for (i = 0; i < 3; i++) { input = (char)sio2host_getchar(); if (isdigit(input)) { input_char[i] = input; } else { break; } } channel = atol(input_char); #if (RF_BAND == BAND_900) if ((channel == 1) || (channel == 4) || (channel == 7)) #else if ((channel == 15) || (channel == 20) || (channel == 25)) #endif { nlme_set_request(nwkBaseChannel, 0, &channel, (FUNC_PTR)nlme_set_confirm ); node_status = BASE_CHANNEL_CHANGE; } else { printf( "Entered channel is not valid - press Enter to return to main menu.\r\n "); return; } }
/** * @brief Prints the sub menu for the channel agility. */ static void print_sub_mode_ch_ag_setup(void) { int8_t input_char; uint8_t input; printf("\n"); printf( "Configuration of channel agility, select a configration parameter\r\n"); printf("(Scan interval > 4*scan duration)\r\n\r\n"); printf("(F) : Noise threshold, current value: %d\r\n", nwk_Private_ChAgEdThreshold); printf("(G) : Scan interval, current value: 0x%.8lX\r\n", nwk_Private_ChAgScanInterval); printf("(E) : Scan duration, current value: %d\r\n", nwk_ScanDuration); printf(">\r\n"); /* Check for incoming characters from terminal program. */ while (1) { input_char = sio2host_getchar_nowait(); if (input_char != -1) { break; } } switch (toupper(input_char)) { case 'F': /* Noise Threshold */ { char input_char2[3] = {0, 0, 0}; uint8_t threshold; printf( "Enter new noise threshold (Valid Range:0 = -91dBm to 84 = -35dBm).\r\n"); printf("Default: 10 = -80 dBm, new value: \r\n"); for (uint8_t i = 0; i < 2; i++) { input = (char)sio2host_getchar(); if (isdigit(input)) { input_char2[i] = input; } else if (input == 0x0D) { break; } else { printf("Invalid value. \r\n\r\n"); printf( "> Press Enter to return to main menu:\r\n "); return; } } threshold = atol(input_char2); if (threshold <= 84) { nlme_set_request(nwkPrivateChAgEdThreshold, 0, &threshold, (FUNC_PTR)nlme_set_confirm ); } else { printf("Invalid threshold value. \r\n\r\n"); printf("> Press Enter to return to main menu:\r\n "); return; } } break; case 'G': /* Scan interval */ { char input_char2[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; char input_char3[9] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; uint32_t threshold = 0; printf( "Enter new scan interval (0x00000000 ... 0xFFFFFFFF), enter 32-bit value \r\n"); printf( "Default: 0x00393870 symbols = 60 sec, new value: 0x \r\n"); for (uint8_t i = 0; i < 8; i++) { input = (char)sio2host_getchar(); input = (uint8_t)toupper(input); if (((input >= '0') && (input <= '9')) || ((input >= 'A') && (input <= 'F'))) { input_char2[i] = input; } else { if (input == 0x0D) { break; } else { printf("Invalid value. \r\n\r\n"); printf( "> Press Enter to return to main menu:\r\n "); return; } } } for (uint8_t i = 7; i > 0; i--) { if (input_char2[i] != 0x00) { memcpy(&input_char3[7 - i], input_char2, i + 1); break; } } for (uint8_t i = 0; i < 8; i++) { if (input_char3[i] != 0x00) { if ((input_char3[i] >= '0') && (input_char3[i] <= '9')) { input_char3[i] -= '0'; } else { input_char3[i] -= 55; } threshold += (uint32_t)input_char3[i] << ((7 - i) * 4); } } nlme_set_request(nwkPrivateChAgScanInterval, 0, (uint8_t *)&threshold, (FUNC_PTR)nlme_set_confirm ); } break; case 'E': { char input_char2[3] = {0, 0, 0}; uint8_t scan_dur; printf( "Enter new scan duration (0 = 30 msec, 6 = 1 sec, 14 = 14 min).\r\n"); printf("Default: 6 = 1 sec, new value: \r\n"); for (uint8_t i = 0; i < 2; i++) { input = (char)sio2host_getchar(); if (isdigit(input)) { input_char2[i] = input; } else if (input == 0x0D) { break; } else { printf("Invalid value. \r\n\r\n"); printf( "> Press Enter to return to main menu:\r\n "); return; } } scan_dur = atol(input_char2); if ((scan_dur >= 0) && (scan_dur <= 14)) { nlme_set_request(nwkScanDuration, 0, &scan_dur, (FUNC_PTR)nlme_set_confirm ); } else { printf("Invalid value. \r\n\r\n"); printf("> Press Enter to return to main menu:\r\n "); return; } } break; default: printf("Invalid input\r\n"); } printf("\r\n\r\n"); printf("> Press Enter to return to main menu:\r\n "); }
static inline void handle_incoming_msg(void) { bool ret_val; switch (sio_rx_buf[1]) { /* message type */ case NLDE_DATA_REQUEST: /* Attention: The TxOption field is moved before the nsduLength * field! */ ret_val = nlde_data_request(sio_rx_buf[2], (profile_id_t)sio_rx_buf[3], ((uint16_t)sio_rx_buf[4] | ((uint16_t)sio_rx_buf[5] << 8)), /* * * *VendorId **/ sio_rx_buf[7], /* nsduLength */ &sio_rx_buf[8], sio_rx_buf[6], /* TxOptions */ 1, (FUNC_PTR)nlde_data_confirm ); break; #if (defined RF4CE_TARGET) || (defined RF4CE_PLATFORM) case NLME_AUTO_DISCOVERY_REQUEST: { dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE]; profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE]; uint32_t AutoDiscDuration; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { RecDevTypeList[i] = (dev_type_t)sio_rx_buf[3 + i]; } for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { RecProfileIdList[i] = (profile_id_t)sio_rx_buf[6 + i]; } MEMCPY_ENDIAN(&AutoDiscDuration, &sio_rx_buf[13], sizeof(uint32_t)); ret_val = nlme_auto_discovery_request(sio_rx_buf[2], /* * * *RecAppCapabilities **/ RecDevTypeList, /* * *(dev_type_t * ***)&sio_rx_buf[3], **/ RecProfileIdList, /* * *(profile_id_t * ***)&sio_rx_buf[3 * + 3], **/ AutoDiscDuration, /* * **(uint32_t * ***)&sio_rx_buf[3 * + 3 + * 7]); */ (FUNC_PTR)nlme_auto_discovery_confirm ); } break; #endif case NLME_DISCOVERY_REQUEST: { #if (UC3) uint16_t PANId = ((uint16_t)sio_rx_buf[2] << 8) | (uint16_t)sio_rx_buf[3]; uint16_t NwkAddr = ((uint16_t)sio_rx_buf[4] << 8) | (uint16_t)sio_rx_buf[5]; #else uint16_t PANId = (uint16_t)sio_rx_buf[2] | ((uint16_t)sio_rx_buf[3] << 8); uint16_t NwkAddr = (uint16_t)sio_rx_buf[4] | ((uint16_t)sio_rx_buf[5] << 8); #endif dev_type_t dev_type_list[DEVICE_TYPE_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { dev_type_list[i] = (dev_type_t)sio_rx_buf[7 + i]; } profile_id_t org_profile_id_list[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { org_profile_id_list[i] = (profile_id_t)sio_rx_buf[10 + i]; } profile_id_t disc_profile_id_list[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { disc_profile_id_list[i] = (profile_id_t)sio_rx_buf[19 + i]; } uint32_t disc_duration; MEMCPY_ENDIAN(&disc_duration, &sio_rx_buf[26], sizeof(uint32_t)); ret_val = nlme_discovery_request(PANId, NwkAddr, sio_rx_buf[6], /* uint8_t * * *OrgAppCapabilities, **/ dev_type_list, /* uint8_t * * *OrgDevTypeList[DEVICE_TYPE_LIST_SIZE], **/ org_profile_id_list, /* * *uint8_t * * *OrgProfileIdList[DEVICE_TYPE_LIST_SIZE], **/ (dev_type_t)sio_rx_buf[7 + 3 /*num_dev_types*/ + 7 /*num_profiles*/], /* * *uint8_t * * *SearchDevType, **/ sio_rx_buf[8 + 3 + 7], /* * *uint8_t * * *DiscProfileIdListSize, **/ disc_profile_id_list, /* * *uint8_t * * *DiscProfileIdList[PROFILE_ID_LIST_SIZE], **/ disc_duration, /* uint32_t * * *DiscDuration); **/ (FUNC_PTR)nlme_discovery_confirm ); } break; #if (defined RF4CE_TARGET) || (defined RF4CE_PLATFORM) case NLME_DISCOVERY_RESPONSE: { nwk_enum_t Status = (nwk_enum_t)sio_rx_buf[2]; uint64_t DstIEEEAddr; memcpy(&DstIEEEAddr, &sio_rx_buf[3], 8); dev_type_t dev_type_list[DEVICE_TYPE_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { dev_type_list[i] = (dev_type_t)sio_rx_buf[12 + i]; } profile_id_t profile_id_list[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { profile_id_list[i] = (profile_id_t)sio_rx_buf[15 + i]; } ret_val = nlme_discovery_response(Status, /* nwk_enum_t * Status, */ DstIEEEAddr, /* uint64_t * DstIEEEAddr, **/ sio_rx_buf[11], /* * *uint8_t * * *RecAppCapabilities, **/ dev_type_list, /* uint8_t * * *RecDevTypeList[DEVICE_TYPE_LIST_SIZE], **/ profile_id_list, /* uint8_t * * *RecProfileIdList[PROFILE_ID_LIST_SIZE], **/ sio_rx_buf[12 + 3 + 7]); /* * *uint8_t * * *DiscReqLQI); **/ } break; #endif #if (defined RF4CE_TARGET) || (defined RF4CE_PLATFORM) case NLME_PAIR_RESPONSE: { nwk_enum_t Status = (nwk_enum_t)sio_rx_buf[2]; #if (UC3) uint16_t DstPANId = ((uint16_t)sio_rx_buf[3] << 8) | (uint16_t)sio_rx_buf[4]; #else uint16_t DstPANId = (uint16_t)sio_rx_buf[3] | ((uint16_t)sio_rx_buf[4] << 8); #endif uint64_t DstIEEEAddr; memcpy(&DstIEEEAddr, &sio_rx_buf[5], 8); dev_type_t dev_type_list[DEVICE_TYPE_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { dev_type_list[i] = (dev_type_t)sio_rx_buf[14 + i]; } profile_id_t profile_id_list[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { profile_id_list[i] = (profile_id_t)sio_rx_buf[17 + i]; } ret_val = nlme_pair_response(Status, /* nwk_enum_t Status, */ DstPANId, /* uint16_t DstPANId, **/ DstIEEEAddr, /* uint64_t * DstIEEEAddr, */ sio_rx_buf[13], /* * *uint8_t * * *RecAppCapabilities, **/ dev_type_list, /* uint8_t * * *RecDevTypeList[DEVICE_TYPE_LIST_SIZE], **/ profile_id_list, /* uint8_t * * *RecProfileIdList[PROFILE_ID_LIST_SIZE], **/ sio_rx_buf[14 + 3 + 7]); /* * *uint8_t * * *ProvPairingRef); **/ } break; #endif case NLME_RESET_REQUEST: ret_val = nlme_reset_request(sio_rx_buf[2], (FUNC_PTR)nlme_reset_confirm ); break; case NLME_PAIR_REQUEST: { #if (UC3) uint16_t DstPANId = ((uint16_t)sio_rx_buf[3] << 8) | (uint16_t)sio_rx_buf[4]; #else uint16_t DstPANId = (uint16_t)sio_rx_buf[3] | ((uint16_t)sio_rx_buf[4] << 8); #endif uint64_t DstIEEEAddr; memcpy(&DstIEEEAddr, &sio_rx_buf[5], 8); dev_type_t dev_type_list[DEVICE_TYPE_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { dev_type_list[i] = (dev_type_t)sio_rx_buf[14 + i]; } profile_id_t profile_id_list[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { profile_id_list[i] = (profile_id_t)sio_rx_buf[17 + i]; } ret_val = nlme_pair_request(sio_rx_buf[2], /* uint8_t * LogicalChannel, **/ DstPANId, /* uint16_t DstPANId, **/ DstIEEEAddr, /* uint64_t * DstIEEEAddr, */ sio_rx_buf[13], /* uint8_t * * *OrgAppCapabilities, **/ dev_type_list, /* uint8_t * * *OrgDevTypeList[DEVICE_TYPE_LIST_SIZE], **/ profile_id_list, /* uint8_t * * *OrgProfileIdList[PROFILE_ID_LIST_SIZE], **/ sio_rx_buf[14 + 3 + 7], /* uint8_t * * *KeyExTransferCount); **/ (FUNC_PTR)nlme_pair_confirm ); } break; #if (NWK_GET == 1) case NLME_GET_REQUEST: ret_val = nlme_get_request((nib_attribute_t)sio_rx_buf[2], sio_rx_buf[3], (FUNC_PTR)nlme_get_confirm ); break; #endif case NLME_RX_ENABLE_REQUEST: { uint32_t rx_on_duration; MEMCPY_ENDIAN(&rx_on_duration, &sio_rx_buf[2], sizeof(uint32_t)); ret_val = nlme_rx_enable_request(rx_on_duration, (FUNC_PTR)nlme_rx_enable_confirm ); } break; #if (NWK_SET == 1) case NLME_SET_REQUEST: ret_val = nlme_set_request((nib_attribute_t)sio_rx_buf[2], sio_rx_buf[3], &sio_rx_buf[5], (FUNC_PTR)nlme_set_confirm ); break; #endif case NLME_START_REQUEST: ret_val = nlme_start_request( (FUNC_PTR)nlme_start_confirm ); break; #if (NWK_UNPAIR_REQ_CONF == 1) case NLME_UNPAIR_REQUEST: ret_val = nlme_unpair_request(sio_rx_buf[2], (FUNC_PTR)nlme_unpair_confirm ); break; #endif #if (NWK_UNPAIR_IND_RESP == 1) case NLME_UNPAIR_RESPONSE: ret_val = nlme_unpair_response(sio_rx_buf[2]); break; #endif #if ((NWK_UPDATE_KEY == 1) && (defined RF4CE_SECURITY)) || \ (defined RF4CE_PLATFORM) case NLME_UPDATE_KEY_REQUEST: ret_val = nlme_update_key_request(sio_rx_buf[2], &sio_rx_buf[3], (FUNC_PTR)nlme_update_key_confirm ); break; #endif #if (defined CHANNEL_AGILITY) || (defined RF4CE_PLATFORM) case NWK_CH_AGILITY_REQUEST: ret_val = nwk_ch_agility_request( (nwk_agility_mode_t)sio_rx_buf[2], (FUNC_PTR)nwk_ch_agility_confirm ); break; #endif #ifdef PBP_ORG case PBP_ORG_PAIR_REQUEST: { dev_type_t OrgDevTypeList[DEVICE_TYPE_LIST_SIZE]; profile_id_t OrgProfileIdList[PROFILE_ID_LIST_SIZE]; profile_id_t DiscProfileIdList[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { OrgDevTypeList[i] = (dev_type_t)sio_rx_buf[3 + i]; } for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { OrgProfileIdList[i] = (profile_id_t)sio_rx_buf[6 + i]; } for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { DiscProfileIdList[i] = (profile_id_t)sio_rx_buf[13 + 2 + i]; } ret_val = pbp_org_pair_request(sio_rx_buf[2], /* * * *OrgAppCapabilities **/ OrgDevTypeList, /* * *OrgDevTypeList **/ OrgProfileIdList, /* * *OrgProfileIdList **/ (dev_type_t)sio_rx_buf[13], /* * * *SearchDevType **/ sio_rx_buf[14], /* * *DiscProfileIdListSize **/ DiscProfileIdList, /* * *DiscProfileIdList, **/ (FUNC_PTR)pbp_org_pair_confirm ); } break; #endif #ifdef PBP_REC case PBP_REC_PAIR_REQUEST: { dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE]; profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE]; for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) { RecDevTypeList[i] = (dev_type_t)sio_rx_buf[3 + i]; } for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) { RecProfileIdList[i] = (profile_id_t)sio_rx_buf[6 + i]; } ret_val = pbp_rec_pair_request(sio_rx_buf[2], /* * * *RecAppCapabilities **/ RecDevTypeList, /* (dev_type_t * ***)&sio_rx_buf[3], **/ RecProfileIdList, /* (profile_id_t * ***)&sio_rx_buf[3 * + 3], */ (FUNC_PTR)pbp_rec_pair_confirm ); } break; #endif #ifdef ZRC_PROFILE #if ((!defined RF4CE_TARGET) || (defined RF4CE_PLATFORM)) case ZRC_CMD_REQUEST: ret_val = zrc_cmd_request(sio_rx_buf[2], /* pair_ref */ (uint16_t)sio_rx_buf[3] | ((uint16_t)sio_rx_buf[4] << 8), /*uint16_t * * *VendorId,*/ (zrc_cmd_code_t)sio_rx_buf[5], /* * * *zrc_cmd_code_t * * *cerc_cmd_code, **/ sio_rx_buf[7], /* uint8_t cmd_length,*/ &sio_rx_buf[8], /*uint8_t *cmd_payload, */ sio_rx_buf[6], /* uint8_t tx_options */ (FUNC_PTR)zrc_cmd_confirm ); break; #endif #endif /* #ifdef ZRC_PROFILE */ #ifdef ZRC_CMD_DISCOVERY case ZRC_CMD_DISCOVERY_REQUEST: ret_val = zrc_cmd_disc_request(sio_rx_buf[2], /* PairingRef */ (FUNC_PTR)zrc_cmd_disc_confirm ); break; #endif #ifdef ZRC_CMD_DISCOVERY case ZRC_CMD_DISCOVERY_RESPONSE: ret_val = zrc_cmd_disc_response(sio_rx_buf[2], &sio_rx_buf[3]); break; #endif #ifdef VENDOR_DATA case VENDOR_DATA_REQUEST: ret_val = nlde_data_request(sio_rx_buf[2], /*uint8_t * PairingRef,*/ PROFILE_ID_ZRC, (uint16_t)sio_rx_buf[4] | ((uint16_t)sio_rx_buf[5] << 8), /*uint16_t * * *VendorId,*/ sio_rx_buf[7], /*uint8_t nsduLength,*/ &sio_rx_buf[8], /*uint8_t *nsdu,*/ sio_rx_buf[6], /*uint8_t TxOptions*/ 1, (FUNC_PTR)vendor_data_confirm ); break; #endif default: { } Assert("???" == 0); break; } if (ret_val == false) { Assert("Buffer is not available (Test harness)" == 0); } }