common/net_nfc_util_handover.c
static net_nfc_error_e __net_nfc_get_inner_message(ndef_message_s *message, ndef_message_s *inner_msg)
{
	net_nfc_error_e error;
	ndef_record_s *inner_record = NULL;

	if (message == NULL || inner_msg == NULL)
	{
		return NET_NFC_NULL_PARAMETER;
	}

	inner_record = message->records;
	if (inner_record == NULL)
	{
		// This message is not connection handover message
		return NET_NFC_INVALID_FORMAT;
	}

	if (strncmp((char*)(inner_record->type_s.buffer), CH_REQ_RECORD_TYPE, (size_t)(inner_record->type_s.length)) != 0
			&& strncmp((char*)(inner_record->type_s.buffer), CH_SEL_RECORD_TYPE, (size_t)(inner_record->type_s.length)) != 0)
	{
		// This message is not connection handover message
		return NET_NFC_INVALID_FORMAT;
	}

	if (inner_record->payload_s.length > 1)
	{
		/* There is Alternative Carrier Record or Collision Res. Rec. */
		(inner_record->payload_s.buffer)++; /* version */
		(inner_record->payload_s.length)--;
		error = net_nfc_util_convert_rawdata_to_ndef_message(&(inner_record->payload_s), inner_msg);
		(inner_record->payload_s.buffer)--;
		(inner_record->payload_s.length)++;
	}
	else
	{
		error = NET_NFC_NO_DATA_FOUND;
	}

	return error;
}
/*	inner_msg should be freed after using 	*/
inner_msg should be freed after using
inner_msg should be freed after using
static net_nfc_error_e __net_nfc_get_inner_message(ndef_message_s *message, ndef_message_s *inner_msg)
{
	net_nfc_error_e error;
	ndef_record_s *inner_record = NULL;
	if (message == NULL || inner_msg == NULL)
	{
		return NET_NFC_NULL_PARAMETER;
	}
	inner_record = message->records;
	if (inner_record == NULL)
	{
		return NET_NFC_INVALID_FORMAT;
	}
	if (strncmp((char*)(inner_record->type_s.buffer), CH_REQ_RECORD_TYPE, (size_t)(inner_record->type_s.length)) != 0
			&& strncmp((char*)(inner_record->type_s.buffer), CH_SEL_RECORD_TYPE, (size_t)(inner_record->type_s.length)) != 0)
	{
		return NET_NFC_INVALID_FORMAT;
	}
	if (inner_record->payload_s.length > 1)
	{
		(inner_record->payload_s.buffer)++; 
		(inner_record->payload_s.length)--;
		error = net_nfc_util_convert_rawdata_to_ndef_message(&(inner_record->payload_s), inner_msg);
		(inner_record->payload_s.buffer)--;
		(inner_record->payload_s.length)++;
	}
	else
	{
		error = NET_NFC_NO_DATA_FOUND;
	}
	return error;
}
static net_nfc_error_e __net_nfc_get_inner_message ( ndef_message_s * message , ndef_message_s * inner_msg ) { net_nfc_error_e error ; ndef_record_s * inner_record = NULL ; if ( message == NULL || inner_msg == NULL ) { return NET_NFC_NULL_PARAMETER ; } inner_record = message -> records ; if ( inner_record == NULL ) { return NET_NFC_INVALID_FORMAT ; } if ( strncmp ( ( char * ) ( inner_record -> type_s . buffer ) , CH_REQ_RECORD_TYPE , ( size_t ) ( inner_record -> type_s . length ) ) != 0 && strncmp ( ( char * ) ( inner_record -> type_s . buffer ) , CH_SEL_RECORD_TYPE , ( size_t ) ( inner_record -> type_s . length ) ) != 0 ) { return NET_NFC_INVALID_FORMAT ; } if ( inner_record -> payload_s . length > 1 ) { ( inner_record -> payload_s . buffer ) ++ ; ( inner_record -> payload_s . length ) -- ; error = net_nfc_util_convert_rawdata_to_ndef_message ( & ( inner_record -> payload_s ) , inner_msg ) ; ( inner_record -> payload_s . buffer ) -- ; ( inner_record -> payload_s . length ) ++ ; } else { error = NET_NFC_NO_DATA_FOUND ; } return error ; }
inner_msg should be freed after using
inner_msg should be freed after using
// This message is not connection handover message // This message is not connection handover message /* There is Alternative Carrier Record or Collision Res. Rec. */ /* version */