Esempio n. 1
0
/**
 * Main function, initialization and main message loop
 *
 */
int main(void)
{
    irq_initialize_vectors();

    /* Initialize the board.*/	
    board_init();    

	/* Initialize the Software timer */
    sw_timer_init();       
    
	/* Init the RF4CE Network layer */
    if (nwk_init()!= NWK_SUCCESS)
    {
        app_alert();
    }

#ifdef RF4CE_CALLBACK_PARAM
	/* Register the ZID Callback indication */
    zid_ind.zid_report_data_indication_cb = zid_report_data_indication;
    zid_ind.zid_get_report_indication_cb = zid_get_report_indication;
    register_zid_indication_callback(&zid_ind);
#endif
    /*
     * The stack is initialized above,
     * hence the global interrupts are enabled here.
     */
     cpu_irq_enable();
	 sw_timer_get_id(&APP_TIMER_ACC_READ);
    if (get_zid_keyrc_button(button_scan()) == ZID_COLD_START)
    {        
        /* Cold start */
        LED_On(ZID_APP_LED);
        node_status = COLD_START;
        nlme_reset_request(true
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
    }
    else
    {
        /* Warm start */
        node_status = WARM_START;
        nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
    }

    /* Endless while loop */
    while (1)
    {
        app_task(); /* Application task */
        nwk_task(); /* RF4CE network layer task */
    }
}
Esempio n. 2
0
/**
 * @brief Application task
 * @ingroup TApp_API 
 */
static void app_task(void)
{
    /**
     * To start NLME Reset procedure when application starts up
     */
    if (target_auto_start == true)
    {
        target_auto_start = false;
        node_status = ALL_IN_ONE_START;
        ch_ag_enabled = false;
        nlme_reset_request(true);
        return;
    }
    else 
    {
        if(node_status != IDLE)
            return;    
        if (Receive_Message() == 0)
            return;
            /**
             * To send out QTouch Studio commands over air 
             * to Touch Remote  
             */  
            vendor_data_request(0, PROFILE_ID_VENDOR_DATA,
                                NWKC_VENDOR_IDENTIFIER, RF4CE_RX_Buffer[2], RF4CE_RX_Buffer,
                                TXO_UNICAST | TXO_DST_ADDR_IEEE | TXO_ACK_REQ | TXO_SEC_REQ | TXO_MULTI_CH | TXO_CH_NOT_SPEC | TXO_VEND_SPEC);  
                
    }/*end of else*/
       
}
Esempio n. 3
0
 /**
 * @brief zid_set_attribute_confirm ZID Set attribute confirm callback allows to 
 *        check whether attributes are sent to the ZID Adaptor.
 *
 * @param Status  status from the network layer corresponds to the zid_set_attribute_request
 * @param PairingRef current pairing ref
 * @param ZIDAttribute attribute name
 * @param ZIDAttributeIndex attribute index
 */
static void zid_set_attribute_confirm(nwk_enum_t status,uint8_t PairingRef, zid_attribute_t ZIDAttribute, uint8_t ZIDAttributeIndex)
{
   if(status == NWK_SUCCESS)
   {
       if(ZIDAttribute == aplHIDStdDescCompsList)
       {
          if(ZIDAttributeIndex >= (ZID_ATTRIBUTE_REQ_SIZE - 1))
          {
              set_attribute_index = 0;
              LED_Off(ZID_APP_LED);
              

              node_status = CONNECTING;

              dev_type_t OrgDevTypeList[1];;
              profile_id_t OrgProfileIdList[1];
              profile_id_t DiscProfileIdList[1];

              OrgDevTypeList[0] = DEV_TYPE_REMOTE_CONTROL;
              OrgProfileIdList[0] = PROFILE_ID_ZID;
              DiscProfileIdList[0] = PROFILE_ID_ZID;

              zid_org_connect_request(APP_CAPABILITIES, OrgDevTypeList, OrgProfileIdList,
                                   DEV_TYPE_WILDCARD, NUM_SUPPORTED_PROFILES, DiscProfileIdList
#ifdef RF4CE_CALLBACK_PARAM
                                    ,(FUNC_PTR)zid_connect_confirm
#endif
                                     );
          }
          else
          {
              set_attribute_index++;
          }
       }
   }
   else
   {
        if(node_status == COLD_START)
		{
			app_alert();
		}
		else
		{
		  indicate_fault_behavior();
		  /* Reset the network and start again */
		  /* Warm start */
			node_status = WARM_START;
			nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
		}
   }
   PairingRef = PairingRef;
   ZIDAttribute = ZIDAttribute;
   ZIDAttributeIndex =ZIDAttributeIndex;
}
Esempio n. 4
0
/**
 * @brief Application task
 */
static void app_task(void)
{
	if (target_auto_start == true) {
		target_auto_start = false;
		node_status = ALL_IN_ONE_START;
		nlme_reset_request(true,
				(FUNC_PTR)nlme_reset_confirm
				);
		return;
	}
}
static void run_nlme_reset_test(const struct test_case *test)
{
	nlme_reset_request(true
#ifdef RF4CE_CALLBACK_PARAM
			, (FUNC_PTR)nlme_reset_confirm
#endif
			);
	while (!nlme_reset_conf_rcvd) {
		nwk_task();
	}
	test_assert_true(test, nlme_reset_conf_status == NWK_SUCCESS,
			"NWK Reset request failed");
}
Esempio n. 6
0
static void nlme_reset_confirm(nwk_enum_t Status)
{
	if (Status == NWK_SUCCESS) {
		nlme_start_request(
				(FUNC_PTR)nlme_start_confirm
				);
	} else {
		/*Something Went wrong sending nlme_reset_request again*/
		nlme_reset_request(true,
				(FUNC_PTR)nlme_reset_confirm
				);
	}
}
Esempio n. 7
0
static
#endif
void nlme_reset_confirm(nwk_enum_t Status)
{
    if (Status != NWK_SUCCESS)
    {
		if(node_status == COLD_START)
		{
			while (1)
			{
			  indicate_fault_behavior();
			}
		}
		else
		{
		  indicate_fault_behavior();
		  /* Reset the network and start again */
		  /* Warm start */
			node_status = WARM_START;
			nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
		}
    }

    if (node_status == COLD_START)
    {
		/* cold start procedure starts here */
        pairing_ref = 0xFF;
        nlme_start_request(
#ifdef RF4CE_CALLBACK_PARAM
                           (FUNC_PTR)nlme_start_confirm
#endif

                           );
    }
    else    /* warm start procedure starts here */
    {
        pairing_ref = 0;
        /* Set power save mode: sleep */
        nlme_rx_enable_request(0/*nwkcMinActivePeriod*/
#ifdef RF4CE_CALLBACK_PARAM
                           ,(FUNC_PTR)app_nlme_rx_enable_confirm
#endif

                           );
    }
}
Esempio n. 8
0
static
#endif
void app_nlme_rx_enable_confirm(nwk_enum_t Status)
{
    if (Status != NWK_SUCCESS)
    {
        if(node_status == COLD_START)
		{
			while (1)
			{
			  indicate_fault_behavior();
			}
		}
		else
		{
		  indicate_fault_behavior();
		  /* Reset the network and start again */
		  /* Warm start */
			node_status = WARM_START;
			nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
		}
    }

    if (node_status == COLD_START)
    {
        node_status = IDLE;

        /* LED handling */
        LED_On(ZID_APP_LED);
        delay_ms(1000);
        LED_Off(ZID_APP_LED);
    }
    else if (node_status == WARM_START)
    {
        node_status = IDLE;		
         LED_On(ZID_APP_LED);
         delay_ms(250);
         LED_Off(ZID_APP_LED);
    }
}
Esempio n. 9
0
static
#endif
void zid_connect_confirm(nwk_enum_t Status, uint8_t PairingRef)
{
    if (Status != NWK_SUCCESS)
    {
        if(node_status == COLD_START)
		{
			app_alert();
		}
		else
		{
		  indicate_fault_behavior();
		  /* Reset the network and start again */
		  /* Warm start */
			node_status = WARM_START;
			nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
		}
    }

    pairing_ref = PairingRef;

    /* Set power save mode */

    if (node_status == CONNECTING)
    {
        node_status = IDLE;
        zid_state = ZID_STATE_IDLE;

       /* LED handling */
	   LED_On(ZID_APP_LED);
	   delay_ms(1000);
	   LED_Off(ZID_APP_LED);
       LED_On(LED_1); 
       LED_Off(LED_2);
       LED_Off(LED_3);
       LED_Off(LED_4);
       LED_On(LED_5);       
    }
}
Esempio n. 10
0
static
#endif
void nlme_start_confirm(nwk_enum_t Status)
{
    if (Status != NWK_SUCCESS)
    {
		if(node_status == COLD_START)
		{
			app_alert();
		}
		else
		{
		  indicate_fault_behavior();
		  /* Reset the network and start again */
		  /* Warm start */
			node_status = WARM_START;
			nlme_reset_request(false
#ifdef RF4CE_CALLBACK_PARAM
                          ,(FUNC_PTR)nlme_reset_confirm
#endif
                           );
		}
    }

    if(node_status == COLD_START)
    {
        uint8_t value = ZID_ATTRIBUTE_REQ_SIZE;
        zid_set_attribute_request(0xFF, aplHIDNumStdDescComps, 0, &value
#ifdef RF4CE_CALLBACK_PARAM
                               , (FUNC_PTR)zid_set_attribute_confirm
#endif
                              );
        node_status = CONFIGURING_ATTRIBUTES;
    }

}
Esempio n. 11
0
/**
 * @brief Handle keyboard input
 *
 * @param input_char       character typed from input device.
 */
static void handle_input(uint8_t input_char)
{
	/* We allow user input if we are either in IDLE state ot POWER_SAVE
	 * state
	 * In case of POWER_SAVE state, we allow only reset & disabling
	 * POWER_SAVE req*/
	if (((node_status != IDLE) && (node_status != POWER_SAVE)) ||
			((node_status == POWER_SAVE) &&
			(!((input_char == 'Y') || (input_char == 'R') ||
			(input_char == 'A') || (input_char == 'W') ||
			(input_char == 0x0D))))) {
		printf(
				"Node is in power save mode.Press (R) to Reset/Press (Y) to Disable power save mode.\r\n");
		return;
	}

	switch (input_char) {
	case 'Y':
		if (node_status == POWER_SAVE) {
			printf(
					"Leaving standby (power save mode). Press Enter to return to main menu.\r\n ");
			nlme_rx_enable_request(RX_DURATION_INFINITY,
					(FUNC_PTR)nlme_rx_enable_confirm
					);
			node_status = IDLE;
		} else {
			printf(
					"Entering standby (power save mode). Press Enter to return to main menu.\r\n ");
			nlme_rx_enable_request(nwkcMinActivePeriod,
					(FUNC_PTR)nlme_rx_enable_confirm
					);
			node_status = POWER_SAVE;
		}

		break;

	case 'R':
		printf("Reset node - \r\n");
		node_status = RESETTING;
		ch_ag_enabled = false;
		nlme_reset_request(true,
				(FUNC_PTR)nlme_reset_confirm
				);
		break;

	case 'S':
		printf("Start node - \r\n");
		node_status = STARTING;
		nlme_start_request(
				(FUNC_PTR)nlme_start_confirm
				);
		break;

	case 'P':
		printf("Push button pairing -\r\n");
		node_status = PUSH_BUTTON_PAIRING;
		sw_timer_start(led_timer,
				500000,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_handling,
				NULL);
		LED_On(LED_NWK_SETUP);
		{
			dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE];
			profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE];

			RecDevTypeList[0] = (dev_type_t)SUPPORTED_DEV_TYPE_0;
			RecProfileIdList[0] = SUPPORTED_PROFILE_ID_0;

			pbp_rec_pair_request(APP_CAPABILITIES, RecDevTypeList,
					RecProfileIdList,
					(FUNC_PTR)pbp_rec_pair_confirm
					);
		}
		break;

	case 'A':
		printf("All-in-one start; wait until done.\r\n");
		node_status = ALL_IN_ONE_START;
		printf("\tReset node - ");
		ch_ag_enabled = false;
		nlme_reset_request(true,
				(FUNC_PTR)nlme_reset_confirm
				);
		break;

	case 'W':
		previous_node_status = node_status;
		printf("Warm start - \r\n");
		node_status = WARM_STARTING;
		nlme_reset_request(false,
				(FUNC_PTR)nlme_reset_confirm
				);
		break;

	case 'T':
		previous_node_status = node_status;
		node_status = PRINTING_PAIRING_TABLE;
		print_pairing_table(true, NULL, 0);
		break;

	case 'U':
		node_status = UNPAIRING;
		print_unpair_submenu();
		break;

	case 'C':
		if (ch_ag_enabled) {
			ch_ag_enabled = false;
			nwk_ch_agility_request(AG_STOP,
					(FUNC_PTR)nwk_ch_agility_confirm
					);
			printf(" - Channel agility is stopped ...\r\n");
		} else {
			ch_ag_enabled = true;
			node_status = CH_AGILITY_EXECUTION;
			printf(" - Channel agility is started ...\r\n");
			nwk_ch_agility_request(AG_PERIODIC,
					(FUNC_PTR)nwk_ch_agility_confirm
					);
		}

		break;

	case 'O':
		/* Start getting the NIBs value */
		node_status = GETTING_CH_AG_NIBS;
		nlme_get_request(nwkPrivateChAgEdThreshold, 0,
				(FUNC_PTR)nlme_get_confirm
				);
		break;

	case 'B':
		print_ch_change_submenu();
		break;

	case 'D':
		print_vendor_data_submenu(BATTERY_STATUS_REQ);
		break;

	case 'V':
		print_vendor_data_submenu(FW_VERSION_REQ);
		break;

	case 'Z':
		print_vendor_data_submenu(ALIVE_REQ);
		break;

	default:
		print_main_menu();
		break;
	}
}
Esempio n. 12
0
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);
	}
}