+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LOCATION_STATUS 120
+#define NFC_STATUS 121
+
struct LXT_MESSAGE// lxt_message
{
unsigned short length;
// Location
char* get_location_status(void* );
+
+// NFC
+char* get_nfc_status(void* );
*
* Contact:
* Sungmin Ha <sungmin82.ha@samsung.com>
- * DongKyun Yun <dk77.yun@samsung.com>
* YeongKyoon Lee <yeongkyoon.lee@samsung.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
r_databuf = NULL;
return;
}
- /*
- LOG("nfc packet length r_databuf: %s", r_databuf);
- memset(tmpbuf, '\0', sizeof(tmpbuf));
- parse_len = parse_val(r_databuf, 0x0a, tmpbuf);
-
- int length = atoi(tmpbuf);
- */
+ memcpy((void*)packet, (void*)r_databuf, HEADER_SIZE);
+ LOG("nfc packet_length: %d", packet->length);
- //byte to int
- int length = ((r_databuf[0] & 0xff) << 24 | (r_databuf[1] & 0xff) << 16
- | (r_databuf[2] & 0xff) << 8 | (r_databuf[3] & 0xff)) ;
- LOG("nfc packet converted length: %d", length);
- free(r_databuf);
+ free(r_databuf);
r_databuf = NULL;
-
- recvd_size = recv_data(event_fd, &r_databuf, length);
- /*
- char* strbuf = NULL;
- strbuf = (char*)malloc(length + 1);
- memset(strbuf, '\0', length + 1);
- memcpy(strbuf, r_databuf, length);
- */
+ recvd_size = recv_data(event_fd, &r_databuf, packet->length);
LOG("nfc data recv buffer: %s", r_databuf);
- FILE* fd;
- fd = fopen("/opt/nfc/sdkMsg", "w");
- if(!fd)
- {
- LOG("nfc file open fail!");
- free(packet);
- packet = NULL;
- return;
+ if (packet->group == STATUS) {
+ g_get_status_sockfd = event_fd;
+ ActionID = packet->action;
+ memset(GetBuffer, '\0', sizeof(GetBuffer));
+ strcpy(GetBuffer, r_databuf);
+ LOG("GetBuffer is %s", GetBuffer);
+
+ if(pthread_create(&tid[2], NULL, setting_device, NULL) != 0) {
+ LOG("pthread create fail!");
+ }
+ } else {
+ FILE* fd;
+ fd = fopen("/opt/nfc/sdkMsg", "w");
+ if(!fd)
+ {
+ LOG("nfc file open fail!");
+ free(packet);
+ packet = NULL;
+ return;
+ }
+ fprintf(fd, "%s", r_databuf);
+ fclose(fd);
+ //free(strbuf);
+ //strbuf = NULL;
}
- fprintf(fd, "%s", r_databuf);
- fclose(fd);
- //free(strbuf);
- //strbuf = NULL;
}
else if(strncmp(tmpbuf, "system", 6) == 0)
{
LOG("failed getting location status");
}
break;
+ case NFC_STATUS:
+ msg = get_nfc_status((void*)packet);
+ if (msg ==0) {
+ LOG("failed getting nfc status");
+ }
+ break;
default:
//TODO
break;
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * Sungmin Ha <sungmin82.ha@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
//#include <vconf.h>
#include "emuld_common.h"
return message;
}
+
+char* get_nfc_status(void* p)
+{
+ FILE* fd = fopen("/opt/nfc/sdkMsg", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ message = (char*)malloc(5000);
+ fscanf(fd, "%s\n", message);
+ fclose(fd);
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = NFC_STATUS;
+
+ return message;
+}