Beispiel #1
0
bool nlme_discovery_response(nwk_enum_t Status, uint64_t DstIEEEAddr,
		uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3],
		profile_id_t RecProfileIdList[7], uint8_t DiscReqLQI)
{
	uint8_t *msg_buf;
	uint8_t i;
	msg_buf = get_next_tx_buffer();

	/* Check if buffer could not be allocated */
	if (NULL == msg_buf) {
		return false;
	}

	*msg_buf++ = NLME_DISCOVERY_RESP_LEN + RF4CONTROL_PID_LEN;
	*msg_buf++ = RF4CONTROL_PID;
	*msg_buf++ = NLME_DISCOVERY_RESPONSE;
	*msg_buf++ = Status;
	MEMCPY_ENDIAN(msg_buf, &DstIEEEAddr, sizeof(DstIEEEAddr));
	msg_buf += sizeof(uint64_t);
	*msg_buf++ = RecAppCapabilities;

	for (i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) {
		*msg_buf++ = RecDevTypeList[i];
	}
	for (i = 0; i < PROFILE_ID_LIST_SIZE; i++) {
		*msg_buf++ = RecProfileIdList[i];
	}
	*msg_buf++ = DiscReqLQI;
	*msg_buf = EOT;
	return true;
}
Beispiel #2
0
/* The NLME-RX-ENABLE.request primitive allows the application to request that
 * the
 * receiver is either enabled (for a finite period or until further notice) or
 * disabled. */
bool nlme_rx_enable_request(uint32_t RxOnDuration,
		FUNC_PTR confirm_cb
		)
{
	uint8_t *msg_buf;
	msg_buf = get_next_tx_buffer();

	/* Check if buffer could not be allocated */
	if (NULL == msg_buf) {
		return false;
	}

	if (confirm_cb == NULL) {
		return false;
	}

	nlme_rx_enable_confirm_cb = (nlme_rx_enable_confirm_cb_t)confirm_cb;

	*msg_buf++ = NLME_RX_ENABLE_REQ_LEN + RF4CONTROL_PID_LEN;
	*msg_buf++ = RF4CONTROL_PID;
	*msg_buf++ = NLME_RX_ENABLE_REQUEST;
	MEMCPY_ENDIAN(msg_buf, &RxOnDuration, sizeof(RxOnDuration));
	msg_buf += sizeof(uint32_t);
	*msg_buf = EOT;
	return true;
}
Beispiel #3
0
bool nlme_pair_response(nwk_enum_t Status, uint16_t DstPANId,
		uint64_t DstIEEEAddr,
		uint8_t RecAppCapabilities, dev_type_t RecDevTypeList[3],
		profile_id_t RecProfileIdList[7], uint8_t ProvPairingRef)
{
	uint8_t *msg_buf;
	uint8_t i;
	msg_buf = get_next_tx_buffer();

	/* Check if buffer could not be allocated */
	if (NULL == msg_buf) {
		return false;
	}

	*msg_buf++ = NLME_PAIR_RESP_LEN + RF4CONTROL_PID_LEN;
	*msg_buf++ = RF4CONTROL_PID;
	*msg_buf++ = NLME_PAIR_RESPONSE;
	*msg_buf++ = Status;
	*msg_buf++ = (uint8_t)DstPANId; /* LSB */
	*msg_buf++ = (uint8_t)(DstPANId >> 8); /* MSB */
	MEMCPY_ENDIAN(msg_buf, &DstIEEEAddr, sizeof(DstIEEEAddr));
	msg_buf += sizeof(uint64_t);
	*msg_buf++ = RecAppCapabilities;

	for (i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) {
		*msg_buf++ = RecDevTypeList[i];
	}
	for (i = 0; i < PROFILE_ID_LIST_SIZE; i++) {
		*msg_buf++ = RecProfileIdList[i];
	}
	*msg_buf++ = ProvPairingRef;
	*msg_buf = EOT;
	return true;
}
Beispiel #4
0
void pal_get_current_time(uint32_t *timer_count)
{
	uint32_t time_val;
	/* This will avoid the hard faults, due to aligned nature of access */
	time_val = sw_timer_get_time();
	MEMCPY_ENDIAN((uint8_t *)timer_count, (uint8_t *)&time_val,
			sizeof(time_val));
}
Beispiel #5
0
bool nlme_auto_discovery_request(uint8_t RecAppCapabilities,
		dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE],
		profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE],
		uint32_t AutoDiscDuration,
		FUNC_PTR confirm_cb
		)
{
	uint8_t *msg_buf;
	uint8_t i;
	msg_buf = get_next_tx_buffer();

	/* Check if buffer could not be allocated */
	if (NULL == msg_buf) {
		return false;
	}

	if (confirm_cb == NULL) {
		return false;
	}

	nlme_auto_discovery_confirm_cb
		= (nlme_auto_discovery_confirm_cb_t)confirm_cb;

	*msg_buf++ = NLME_AUTO_DISCOVERY_REQ_LEN + RF4CONTROL_PID_LEN;
	*msg_buf++ = RF4CONTROL_PID;
	*msg_buf++ = NLME_AUTO_DISCOVERY_REQUEST;
	*msg_buf++ = RecAppCapabilities;

	for (i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) {
		*msg_buf++ = RecDevTypeList[i];
	}
	for (i = 0; i < PROFILE_ID_LIST_SIZE; i++) {
		*msg_buf++ = RecProfileIdList[i];
	}
	MEMCPY_ENDIAN(msg_buf, &AutoDiscDuration, sizeof(uint32_t));
	msg_buf += sizeof(uint32_t);
	*msg_buf = EOT;
	return true;
}
Beispiel #6
0
static inline void handle_incoming_msg(void)
{
	switch (sio_rx_buf[1]) { /* message type */
	case NLME_RESET_CONFIRM:
	{
		nlme_reset_confirm_cb((nwk_enum_t)sio_rx_buf[2]);
	}
	break;

	case NLDE_DATA_CONFIRM:
	{
		nlde_data_confirm_cb((nwk_enum_t)sio_rx_buf[2], sio_rx_buf[3],
				(profile_id_t)sio_rx_buf[4], 1);
	}
	break;

	case NLME_AUTO_DISCOVERY_CONFIRM:
	{
		uint64_t SrcIEEEAddr;
		MEMCPY_ENDIAN(&SrcIEEEAddr, &sio_rx_buf[3], 8);

		nlme_auto_discovery_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				SrcIEEEAddr);
	}
	break;

	case NLME_DISCOVERY_CONFIRM:
	{
		node_desc_t NodeDescList[3];
		uint8_t i;
		uint8_t k;
		uint8_t numnodes = sio_rx_buf[3];
		uint8_t index = 5;
		for (i = 0; i < numnodes; i++) {
			NodeDescList[i].Status
				= (nwk_enum_t)sio_rx_buf[index++];
			NodeDescList[i].LogicalChannel = sio_rx_buf[index++];
			NodeDescList[i].PANId = sio_rx_buf[index++];
			NodeDescList[i].PANId |=  (sio_rx_buf[index++] << 8);
			MEMCPY_ENDIAN(&NodeDescList[i].IEEEAddr,
					&sio_rx_buf[index], 8);
			index += 8;
			NodeDescList[i].NodeCapabilities = sio_rx_buf[index++]; /*
				                                                 *17
				                                                 **/
			NodeDescList[i].VendorId = sio_rx_buf[index++];
			NodeDescList[i].VendorId |= (sio_rx_buf[index++] << 8);
			for (k = 0; k < 7; k++) {
				NodeDescList[i].VendorString[k]
					= sio_rx_buf[index++];                 /*
					                                        *20
					                                        **/
			}
			NodeDescList[i].AppCapabilities = sio_rx_buf[index++]; /*
				                                                *27
				                                                **/
			for (k = 0; k < 15; k++) {
				NodeDescList[i].UserString[k]
					= sio_rx_buf[index++];               /*
					                                      *28
					                                      **/
			}
			for (k = 0; k < DEVICE_TYPE_LIST_SIZE; k++) {
				NodeDescList[i].DevTypeList[k]
					= (dev_type_t)sio_rx_buf
						[index++];                                 /*
					                                                    *43
					                                                    **/
			}
			for (k = 0; k < PROFILE_ID_LIST_SIZE; k++) {
				NodeDescList[i].ProfileIdList[k]
					= (profile_id_t)
						sio_rx_buf[index++];                          /*
					                                                       *46
					                                                       **/
			}
			NodeDescList[i].DiscReqLQI = sio_rx_buf[index++]; /* 53
				                                           **/
		}

		nlme_discovery_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3], NodeDescList);
	}
	break;

	case NLME_GET_CONFIRM:
	{
		nlme_get_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				(nib_attribute_t)sio_rx_buf[3],
				sio_rx_buf[4], (void *)&sio_rx_buf[6]);
	}
	break;

	case NLME_PAIR_CONFIRM:
	{
		uint8_t RecVendorString[7];
		for (uint8_t i = 0; i < 7; i++) {
			RecVendorString[i] = (uint8_t)sio_rx_buf[6 + i];
		}
		uint8_t RecUserString[15];
		uint8_t index = 14;
		for (uint8_t i = 0; i < 15; i++) {
			RecUserString[i] = (uint8_t)sio_rx_buf[index++];
		}
		dev_type_t RecDevTypeList[DEVICE_TYPE_LIST_SIZE];
		for (uint8_t i = 0; i < DEVICE_TYPE_LIST_SIZE; i++) {
			RecDevTypeList[i] = (dev_type_t)sio_rx_buf[index++];
		}
		profile_id_t RecProfileIdList[PROFILE_ID_LIST_SIZE];
		for (uint8_t i = 0; i < PROFILE_ID_LIST_SIZE; i++) {
			RecProfileIdList[i] = (profile_id_t)sio_rx_buf[index++];
		}

		nlme_pair_confirm_cb((nwk_enum_t)sio_rx_buf[2], sio_rx_buf[3],
				((uint16_t)sio_rx_buf[4] |
				((uint16_t)sio_rx_buf[5] << 8)),   /* Rec Vendor
			                                            * Id// */
				RecVendorString, /* uint8_t RecVendorString[7],
			                          **/
				sio_rx_buf[6 + 7], /* RecAppCapabilities */
				RecUserString,
				RecDevTypeList,
				RecProfileIdList);
	}
	break;

	case NLME_RX_ENABLE_CONFIRM:
	{
		nlme_rx_enable_confirm_cb((nwk_enum_t)sio_rx_buf[2]);
	}
	break;

	case NLME_SET_CONFIRM:
	{
		nlme_set_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				(nib_attribute_t)sio_rx_buf[3],
				sio_rx_buf[4]);
	}
	break;

	case NLME_START_CONFIRM:
	{
		nlme_start_confirm_cb((nwk_enum_t)sio_rx_buf[2]);
	}
	break;

	case NLME_UNPAIR_CONFIRM:
	{
		nlme_unpair_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3]);
	}
	break;

	case NLME_UPDATE_KEY_CONFIRM:
	{
		nlme_update_key_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3]);
	}
	break;

	case NWK_CH_AGILITY_CONFIRM:
	{
		nwk_ch_agility_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				(bool)sio_rx_buf[3], sio_rx_buf[4]);
	}
	break;

	case PBP_ORG_PAIR_CONFIRM:
	{
		pbp_org_pair_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3]);
	}
	break;

	case PBP_REC_PAIR_CONFIRM:
	{
		pbp_rec_pair_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3]);
	}
	break;

	case ZRC_CMD_CONFIRM:
	{
		zrc_cmd_confirm_cb((nwk_enum_t)sio_rx_buf[2], sio_rx_buf[3],
				(cec_code_t)sio_rx_buf[4]);
	}
	break;

	case ZRC_CMD_DISCOVERY_CONFIRM:
	{
		zrc_cmd_disc_confirm_cb((nwk_enum_t)sio_rx_buf[2],
				sio_rx_buf[3], &sio_rx_buf[4]);
	}
	break;

	case NLDE_DATA_INDICATION:
	{
		if (nwk_ind_callback.nlde_data_indication_cb == NULL) {
			return;
		}

		nwk_ind_callback.nlde_data_indication_cb(
				sio_rx_buf[2], (profile_id_t)sio_rx_buf[3],
				((uint16_t)sio_rx_buf[4] |
				((uint16_t)sio_rx_buf[5] << 8)),   /* Vendor
			                                           * Id// */
				sio_rx_buf[8], /* nsdu length */
				&sio_rx_buf[9],
				sio_rx_buf[6], /* rx link quality */
				sio_rx_buf[7] /* rx flags */
				);
	}
	break;

	case NLME_COMM_STATUS_INDICATION:
	{
		if (nwk_ind_callback.nlme_comm_status_indication_cb == NULL) {
			return;
		}

		uint64_t SrcIEEEAddr;
		MEMCPY_ENDIAN(&SrcIEEEAddr, &sio_rx_buf[7], 8);
		nwk_ind_callback.nlme_comm_status_indication_cb(
				(nwk_enum_t)sio_rx_buf[2], sio_rx_buf[3],
				((uint16_t)sio_rx_buf[4] |
				((uint16_t)sio_rx_buf[5] << 8)),       /*
			                                                *DstPANId//
			                                                **/
				sio_rx_buf[6],
				SrcIEEEAddr);
	}
	break;

	case NLME_DISCOVERY_INDICATION:
	{
		if (nwk_ind_callback.nlme_discovery_indication_cb == NULL) {
			return;
		}

		uint64_t DstIEEEAddr;
		MEMCPY_ENDIAN(&DstIEEEAddr, &sio_rx_buf[3], 8);
		nwk_ind_callback.nlme_discovery_indication_cb(
				(nwk_enum_t)sio_rx_buf[2], DstIEEEAddr, /*
			                                                 *DstIEEEaddr
			                                                 **/
				sio_rx_buf[11],
				((uint16_t)sio_rx_buf[12] |
				((uint16_t)sio_rx_buf[13] << 8)),
				(uint8_t *)&sio_rx_buf[14], sio_rx_buf[21],
				(uint8_t *)&sio_rx_buf[22],
				(dev_type_t *)&sio_rx_buf[37],
				(profile_id_t *)&sio_rx_buf[40],
				(dev_type_t)sio_rx_buf[47],
				sio_rx_buf[48]);
	}
	break;

	case NLME_PAIR_INDICATION:
	{
		uint8_t OrgVendorString[7];
		for (uint8_t i = 0; i < 7; i++) {
			OrgVendorString[i] = (uint8_t)sio_rx_buf[16 + i];
		}
		uint8_t OrgUserString[15];
		for (uint8_t i = 0; i < 7; i++) {
			OrgUserString[i] = (uint8_t)sio_rx_buf[24 + i];
		}
		dev_type_t OrgDevTypeList[3];
		for (uint8_t i = 0; i < 3; i++) {
			OrgDevTypeList[i] = (dev_type_t)sio_rx_buf[39 + i];
		}
		profile_id_t OrgProfileIdList[7];
		for (uint8_t i = 0; i < 3; i++) {
			OrgProfileIdList[i] = (profile_id_t)sio_rx_buf[42 + i];
		}
		uint64_t SrcIEEEAddr;
		MEMCPY_ENDIAN(&SrcIEEEAddr, &sio_rx_buf[5], 8);

		if (nwk_ind_callback.nlme_pair_indication_cb == NULL) {
			return;
		}

		nwk_ind_callback.nlme_pair_indication_cb(
				(nwk_enum_t)sio_rx_buf[2],
				((uint16_t)sio_rx_buf[3] |
				((uint16_t)sio_rx_buf[4] << 8)),
				SrcIEEEAddr,
				sio_rx_buf[13],
				((uint16_t)sio_rx_buf[14] |
				((uint16_t)sio_rx_buf[15] << 8)),
				OrgVendorString, sio_rx_buf[23], OrgUserString,
				OrgDevTypeList, OrgProfileIdList,
				sio_rx_buf[49],
				sio_rx_buf[50]);
	}
	break;

	case NLME_UNPAIR_INDICATION:
	{
		if (nwk_ind_callback.nlme_unpair_indication_cb == NULL) {
			return;
		}

		nwk_ind_callback.nlme_unpair_indication_cb(
				sio_rx_buf[2]); /* pairing ref */
	}
	break;

	case NWK_CH_AGILITY_INDICATION:
	{
		if (nwk_ind_callback.nwk_ch_agility_indication_cb == NULL) {
			return;
		}

		nwk_ind_callback.nwk_ch_agility_indication_cb(
				sio_rx_buf[2]); /* logical channel */
	}
	break;

	case ZRC_CMD_INDICATION:
	{
		if (zrc_ind_cb.zrc_cmd_indication_cb == NULL) {
			return;
		}

		zrc_ind_cb.zrc_cmd_indication_cb(
				sio_rx_buf[2], /* pairing ref */
				sio_rx_buf[5], /* nsdulength */
				&sio_rx_buf[6],
				sio_rx_buf[3], /* rxlink quality */
				sio_rx_buf[4] /* rxflags */
				);
	}
	break;

	case ZRC_CMD_DISCOVERY_INDICATION:
	{
		if (zrc_ind_cb.zrc_cmd_disc_indication_cb == NULL) {
			return;
		}

		zrc_ind_cb.zrc_cmd_disc_indication_cb(

				sio_rx_buf[2] /* pairing ref */

				);
	}
	break;

	case VENDOR_DATA_INDICATION:
	{
		zrc_ind_cb.vendor_data_ind_cb(

				sio_rx_buf[2], /* pairing ref */
				((uint16_t)sio_rx_buf[4] |
				((uint16_t)sio_rx_buf[5] << 8)),   /* vendor id
			                                            **/
				sio_rx_buf[8], /* nsdu length */
				&sio_rx_buf[9],
				sio_rx_buf[6], /* rx link quality */
				sio_rx_buf[7] /* rx flags */
				);
	}
	break;
	}
}
Beispiel #7
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);
	}
}
Beispiel #8
0
retval_t mlme_get(uint8_t attribute, pib_value_t *attribute_value)
#endif  /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006)  */
{
	/*
	 * Variables indicates whether the transceiver has been woken up for
	 * setting a TAL PIB attribute.
	 */

	retval_t status = MAC_SUCCESS;

	switch (attribute) {
#if (MAC_ASSOCIATION_REQUEST_CONFIRM == 1)
	case macAssociatedPANCoord:
		attribute_value->pib_value_8bit
			= mac_pib.mac_AssociatedPANCoord;
		break;
#endif /* (MAC_ASSOCIATION_REQUEST_CONFIRM == 1) */

	case macMaxBE:
		attribute_value->pib_value_8bit = tal_pib.MaxBE;
		break;

#if ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT))
	case macMaxFrameTotalWaitTime:
		memcpy(attribute_value,
				&mac_pib.mac_MaxFrameTotalWaitTime,
				sizeof(uint16_t));

		break;
#endif  /* ((MAC_INDIRECT_DATA_BASIC == 1) || defined(BEACON_SUPPORT)) */

	case macMaxFrameRetries:
		attribute_value->pib_value_8bit = tal_pib.MaxFrameRetries;
		break;

	case macResponseWaitTime:
		memcpy(attribute_value,
				&mac_pib.mac_ResponseWaitTime,
				sizeof(uint16_t));

		break;

	case macSecurityEnabled:
		attribute_value->pib_value_8bit = mac_pib.mac_SecurityEnabled;
		break;

	case phyCurrentPage:
		attribute_value->pib_value_8bit = tal_pib.CurrentPage;
		break;

	case phyMaxFrameDuration:
		memcpy(attribute_value, &tal_pib.MaxFrameDuration,
				sizeof(uint16_t));
		break;

	case phySHRDuration:
		attribute_value->pib_value_8bit = tal_pib.SHRDuration;
		break;

	case phySymbolsPerOctet:
		attribute_value->pib_value_8bit = tal_pib.SymbolsPerOctet;
		break;

	case macAutoRequest:
		attribute_value->pib_value_8bit = mac_pib.mac_AutoRequest;
		break;

#ifdef BEACON_SUPPORT
	case macBattLifeExt:
		attribute_value->pib_value_8bit = tal_pib.BattLifeExt;
		break;

	case macBattLifeExtPeriods:
		attribute_value->pib_value_8bit
			= mac_pib.mac_BattLifeExtPeriods;
		break;

	case macBeaconTxTime:
		memcpy(attribute_value,
				&tal_pib.BeaconTxTime,
				sizeof(uint32_t));
		break;

	case macBeaconOrder:
		attribute_value->pib_value_8bit = tal_pib.BeaconOrder;
		break;

	case macSuperframeOrder:
		attribute_value->pib_value_8bit = tal_pib.SuperFrameOrder;
		break;
#endif  /* BEACON_SUPPORT */

#if (MAC_ASSOCIATION_INDICATION_RESPONSE == 1)
	case macAssociationPermit:
		attribute_value->pib_value_8bit = mac_pib.mac_AssociationPermit;
		break;
#endif /* (MAC_ASSOCIATION_INDICATION_RESPONSE == 1) */

#if (MAC_START_REQUEST_CONFIRM == 1)
	case macBeaconPayload:
		memcpy(attribute_value,
				mac_beacon_payload,
				mac_pib.mac_BeaconPayloadLength);
		break;

	case macBeaconPayloadLength:
		attribute_value->pib_value_8bit
			= mac_pib.mac_BeaconPayloadLength;
		break;

	case macBSN:
		attribute_value->pib_value_8bit = mac_pib.mac_BSN;
		break;
#endif  /* (MAC_START_REQUEST_CONFIRM == 1) */

#if (MAC_INDIRECT_DATA_FFD == 1)
	case macTransactionPersistenceTime:
		memcpy(attribute_value,
				&mac_pib.mac_TransactionPersistenceTime,
				sizeof(uint16_t));
		break;
#endif /* (MAC_INDIRECT_DATA_FFD == 1) */

#ifdef PROMISCUOUS_MODE
	case macPromiscuousMode:
		attribute_value->pib_value_8bit = tal_pib.PromiscuousMode;
		break;
#endif  /* PROMISCUOUS_MODE */

	case macCoordExtendedAddress:
		memcpy(attribute_value,
				&mac_pib.mac_CoordExtendedAddress,
				sizeof(uint64_t));
		break;

	case macCoordShortAddress:
		memcpy(attribute_value,
				&mac_pib.mac_CoordShortAddress,
				sizeof(uint16_t));
		break;

	case macDSN:
		attribute_value->pib_value_8bit = mac_pib.mac_DSN;
		break;

	case macMaxCSMABackoffs:
		attribute_value->pib_value_8bit = tal_pib.MaxCSMABackoffs;
		break;

	case macMinBE:
		attribute_value->pib_value_8bit = tal_pib.MinBE;
		break;

	case macPANId:
		memcpy(attribute_value,
				&tal_pib.PANId,
				sizeof(uint16_t));
		break;

	case macRxOnWhenIdle:
		attribute_value->pib_value_8bit = mac_pib.mac_RxOnWhenIdle;
		break;

	case macShortAddress:
		memcpy(attribute_value,
				&tal_pib.ShortAddress,
				sizeof(uint16_t));
		break;

	case macIeeeAddress:
		memcpy(attribute_value,
				&tal_pib.IeeeAddress,
				sizeof(uint64_t));
		break;

	case phyCurrentChannel:
		attribute_value->pib_value_8bit = tal_pib.CurrentChannel;
		break;

	case phyChannelsSupported:
		memcpy(attribute_value,
				&tal_pib.SupportedChannels,
				sizeof(uint32_t));
		break;

	case phyTransmitPower:
		attribute_value->pib_value_8bit = tal_pib.TransmitPower;
		break;

	case phyCCAMode:
		attribute_value->pib_value_8bit = tal_pib.CCAMode;
		break;

	default:
		status = MAC_UNSUPPORTED_ATTRIBUTE;
		break;

#if ((defined MAC_SECURITY_ZIP)  || (defined MAC_SECURITY_2006))
	case macKeyTable:
		if (attribute_index >= mac_sec_pib.KeyTableEntries) {
			status = MAC_INVALID_INDEX;
		} else {
			memcpy(attribute_value,
					&mac_sec_pib.KeyTable[attribute_index],
					sizeof(mac_key_table_t));
		}

		break;

	case macKeyTableEntries:
		attribute_value->pib_value_8bit = mac_sec_pib.KeyTableEntries;
		break;

	case macDeviceTable:
		if (attribute_index >= mac_sec_pib.DeviceTableEntries) {
			status = MAC_INVALID_INDEX;
		} else {
			/*
			 * Since the members of the mac_dev_table_t structure do
			 * contain padding bytes,
			 * each member needs to be filled in separately.
			 */
			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 */
			ADDR_COPY_DST_SRC_16(*(uint16_t *)attribute_temp_ptr,
					mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[
						0].PANId);
			attribute_temp_ptr += sizeof(uint16_t);

			/* Short Address */
			ADDR_COPY_DST_SRC_16(*(uint16_t *)attribute_temp_ptr,
					mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[
						0].ShortAddress);
			attribute_temp_ptr += sizeof(uint16_t);

			/* Extended Address */
			ADDR_COPY_DST_SRC_64(*(uint64_t *)attribute_temp_ptr,
					mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[
						0].ExtAddress);
			attribute_temp_ptr += sizeof(uint64_t);

			/* Extended Address */
			memcpy(attribute_temp_ptr,
					&mac_sec_pib.DeviceTable[attribute_index].DeviceDescriptor[
						0].FrameCounter,
					sizeof(uint32_t));
			attribute_temp_ptr += sizeof(uint32_t);

			/* Exempt */
			*attribute_temp_ptr
				= mac_sec_pib.DeviceTable[attribute_index
					].DeviceDescriptor[0].Exempt;
		}

		break;

	case macDeviceTableEntries:
		MEMCPY_ENDIAN(&attribute_value->pib_value_16bit,
				&mac_sec_pib.DeviceTableEntries, 2);
		break;

	case macSecurityLevelTable:
		if (attribute_index >= mac_sec_pib.SecurityLevelTableEntries) {
			status = MAC_INVALID_INDEX;
		} else {
			memcpy(attribute_value,
					&mac_sec_pib.SecurityLevelTable[
						attribute_index],
					sizeof(mac_sec_lvl_table_t));
		}

		break;

	case macSecurityLevelTableEntries:
		attribute_value->pib_value_8bit
			= mac_sec_pib.SecurityLevelTableEntries;
		break;

	case macFrameCounter:
		memcpy(attribute_value,
				&mac_sec_pib.FrameCounter,
				sizeof(uint32_t));
		break;

	case macDefaultKeySource:
		/* Key Source length is 8 octets. */
		memcpy(attribute_value, mac_sec_pib.DefaultKeySource, 8);
		break;
#endif /* (MAC_SECURITY_ZIP || MAC_SECURITY_2006) */

#ifdef TEST_HARNESS

	/*
	 * The following PIB attributes are privately used for special
	 * test scenarios and are not part of the product code path
	 */
	case macPrivateIllegalFrameType:
		attribute_value->pib_value_8bit
			= mac_pib.privateIllegalFrameType;
		break;

	case macPrivateMACState:
		attribute_value->pib_value_8bit = mac_state;
		break;

	case macPrivateNoDataAfterAssocReq:
		attribute_value->pib_value_8bit
			= mac_pib.privateNoDataAfterAssocReq;
		break;

	case macPrivateVirtualPANs:
		attribute_value->pib_value_8bit = mac_pib.privateVirtualPANs;
		break;

	case macPrivateMACSyncState:
		attribute_value->pib_value_8bit = mac_sync_state;
		break;
#endif /* TEST_HARNESS */
	}
	return status;
}