예제 #1
0
void print_ndef_message(nfc_ndef_message_h message){
	char *tnf_tbl[] = {
			"NFC_RECORD_TNF_EMPTY",
			"NFC_RECORD_TNF_WELL_KNOWN",
			"NFC_RECORD_TNF_MIME_MEDIA",
			"NFC_RECORD_TNF_URI",
			"NFC_RECORD_TNF_EXTERNAL_RTD",
			"NFC_RECORD_TNF_UNKNOWN",
			"NFC_RECORD_TNF_UNCHAGNED"
		};
	nfc_record_tnf_e tnf;
	unsigned char *type;
	int type_size;
	unsigned char *payload;
	int payload_size;
	nfc_ndef_record_h record;
	int ret;

	ret = nfc_ndef_message_get_record(message, 0 , &record);
	if( ret != 0 ){
		printf("can't found NDEF Record\n");
		return;
	}


	nfc_ndef_record_get_tnf(record, &tnf);
	nfc_ndef_record_get_type(record, &type, &type_size);
	nfc_ndef_record_get_payload(record, &payload, &payload_size);

	printf("tnf \t: %s\n", tnf_tbl[tnf]);
	printf("type \t: %s\n", byteToString(type, type_size));
	printf("payload : %s\n", byteToString(payload, payload_size)	);

	if( tnf == NFC_RECORD_TNF_WELL_KNOWN && type[0] == 'U' ){
		char *uri;
		nfc_ndef_record_get_uri(record, &uri);
		printf("uri \t: %s\n", uri);
		free(uri);
	}

	if( tnf == NFC_RECORD_TNF_WELL_KNOWN && type[0] == 'T' ){
		char *text;
		nfc_ndef_record_get_text(record, &text);
		printf("text \t: %s\n", text);
		free(text);
		nfc_ndef_record_get_langcode(record , &text);
		printf("langcode : %s\n", text);
		free(text);
	}

}
std::vector<Material> ModelBinaryLoader::readMaterial(int p_NumberOfMaterial, std::istream* p_Input)
{
	Material temp;
	std::vector<Material> tempVector;
	for(int i = 0; i < p_NumberOfMaterial; i++)
	{
		byteToString(p_Input, temp.m_MaterialID);
		byteToString(p_Input, temp.m_DiffuseMap);
		byteToString(p_Input, temp.m_NormalMap);
		byteToString(p_Input, temp.m_SpecularMap);
		tempVector.push_back(temp);
	}
	return tempVector;
}
ModelBinaryLoader::Header ModelBinaryLoader::readHeader(std::istream* p_Input)
{
	Header tempHeader;
	tempHeader.m_Animated = true;
	tempHeader.m_Transparent = true;
	tempHeader.m_CollideAble = true;
	int tempBool;
	byteToString(p_Input, tempHeader.m_ModelName);
	byteToInt(p_Input, tempHeader.m_NumMaterial);
	byteToInt(p_Input, tempHeader.m_NumVertex);
	byteToInt(p_Input, tempHeader.m_NumMaterialBuffer);
	byteToInt(p_Input, tempBool);
	if(tempBool == 0)
	{
		tempHeader.m_Animated= false;
	}
	byteToInt(p_Input, tempBool);
	if(tempBool == 0)
	{
		tempHeader.m_Transparent = false;
	}
	byteToInt(p_Input, tempBool);
	if(tempBool == 0)
	{
		tempHeader.m_CollideAble = false;
	}
	return tempHeader;
}
std::vector<MaterialBuffer> ModelBinaryLoader::readMaterialBuffer(int p_NumberOfMaterialBuffers, std::istream* p_Input)
{
	MaterialBuffer temp;
	std::vector<MaterialBuffer> tempBuffer;
	for(int i = 0; i < p_NumberOfMaterialBuffers; i++)
	{
		byteToString(p_Input, temp.material);
		byteToInt(p_Input, temp.start);
		byteToInt(p_Input, temp.length);
		tempBuffer.push_back(temp);
	}
	return tempBuffer;
}
예제 #5
0
void ndef_record_create_test(nfc_error_e error, void *user_data){
	int ret=0;
	char *tnf_tbl[] = {
			"NFC_RECORD_TNF_EMPTY",
			"NFC_RECORD_TNF_WELL_KNOWN",
			"NFC_RECORD_TNF_MIME_MEDIA",
			"NFC_RECORD_TNF_URI",
			"NFC_RECORD_TNF_EXTERNAL_RTD",
			"NFC_RECORD_TNF_UNKNOWN",
			"NFC_RECORD_TNF_UNCHAGNED"
		};
	nfc_ndef_record_h record1;
	nfc_record_tnf_e tnf;
	unsigned char *type;
	int type_size;
	unsigned char *id;
	int id_size;
	unsigned char *payload;
	int payload_size;

	char *strp = NULL;
	char *strp2 = NULL;


	printf("---------------------------------------------------\n");
	printf(" NEF Record Create Test\n");

	ret = nfc_ndef_record_create(&record1, NFC_RECORD_TNF_WELL_KNOWN, NFC_RECORD_SMART_POSTER_TYPE, sizeof(NFC_RECORD_SMART_POSTER_TYPE), (unsigned char*)"id", strlen("id"), (unsigned char*)"testpayload", strlen("testpayload"));
	print_result("nfc_ndef_record_create" , ret);

	nfc_ndef_record_get_tnf(record1, &tnf);
	nfc_ndef_record_get_type(record1, &type, &type_size);
	nfc_ndef_record_get_id(record1, &id, &id_size);
	nfc_ndef_record_get_payload(record1, &payload, &payload_size);

	printf("tnf \t: %s\n", tnf_tbl[tnf]);
	printf("type \t: %s\n", byteToString(type, type_size));
	printf("id \t: %s\n" , byteToString(id, id_size) );
	printf("payload : %s\n", byteToString(payload, payload_size)	);

	nfc_ndef_record_destroy(record1);

	printf("\n");

	strp = NULL;
	ret = nfc_ndef_record_create_mime(&record1, "text/plain", (unsigned char*)"the text record", sizeof("the text record"));
	print_result("nfc_ndef_record_create_mime" , ret);

	nfc_ndef_record_get_tnf(record1, &tnf);
	nfc_ndef_record_get_mime_type(record1 , &strp);
	nfc_ndef_record_get_type(record1, &type, &type_size);
	nfc_ndef_record_get_payload(record1, &payload, &payload_size);

	printf("tnf \t: %s\n", tnf_tbl[tnf]);
	printf("mimetype: %s\n", strp);
	printf("type \t: %s\n", byteToString(type, type_size));
	printf("payload : %s\n", byteToString(payload, payload_size)	);


	nfc_ndef_record_destroy(record1);
	free(strp);

	printf("\n");

	ret = nfc_ndef_record_create_text(&record1, "the text record", "us-en", NFC_ENCODE_UTF_8);
	print_result("nfc_ndef_record_create_text" , ret);

	nfc_ndef_record_get_tnf(record1, &tnf);
	nfc_ndef_record_get_type(record1, &type, &type_size);
	nfc_ndef_record_get_payload(record1, &payload, &payload_size);
	nfc_ndef_record_get_text(record1, &strp);
	nfc_ndef_record_get_langcode(record1, &strp2);

	printf("tnf \t: %s\n", tnf_tbl[tnf]);
	printf("type \t: %s\n", byteToString(type, type_size));
	printf("payload : %s\n", byteToString(payload, payload_size)	);
	printf("text \t: %s\n", strp);
	printf("langcode: %s\n", strp2);
	nfc_ndef_record_destroy(record1);
	free(strp);
	free(strp2);

	printf("\n");

	ret = nfc_ndef_record_create_uri(&record1,"http://samsung.com");
	print_result("nfc_ndef_record_create_uri" , ret);


	nfc_ndef_record_get_tnf(record1, &tnf);
	nfc_ndef_record_get_type(record1, &type, &type_size);
	nfc_ndef_record_get_payload(record1, &payload, &payload_size);
	nfc_ndef_record_get_uri(record1, &strp);

	printf("tnf \t: %s\n", tnf_tbl[tnf]);
	printf("type \t: %s\n", byteToString(type, type_size));
	printf("payload : %s\n", byteToString(payload, payload_size)	);
	printf("uri \t: %s\n", strp);

	nfc_ndef_record_destroy(record1);
	free(strp);

	printf("\n");


	ret = nfc_ndef_record_create_uri(&record1,"http://samsung.com");
	print_result("nfc_ndef_record_create_uri" , ret);

	ret = nfc_ndef_record_get_mime_type(record1, &strp);
	print_result("nfc_ndef_record_get_mime_type" , ret);
	ret = nfc_ndef_record_get_text(record1,&strp);
	print_result("nfc_ndef_record_get_text" , ret);
	ret = nfc_ndef_record_get_langcode(record1,&strp);
	print_result("nfc_ndef_record_get_langcode" , ret);
	ret = nfc_ndef_record_get_uri(record1,&strp);
	print_result("nfc_ndef_record_get_uri" , ret);
	free(strp);

	nfc_ndef_record_destroy(record1);

	printf("---------------------------------------------------\n");
	printf("\n");
	is_terminate = 1;
	return ;

}