modify checking nfc length and add getting nfc status
authorjihye kim <jihye1128.kim@samsung.com>
Sat, 17 Nov 2012 13:18:42 +0000 (22:18 +0900)
committerjihye kim <jihye1128.kim@samsung.com>
Sat, 17 Nov 2012 13:18:42 +0000 (22:18 +0900)
include/emuld.h
include/emuld_common.h
packaging/emuld.spec
src/emuld.c
src/get_status.c

index 702bc34..e33d5be 100644 (file)
@@ -5,7 +5,6 @@
  *
  * 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");
index 7d3abb9..285333b 100644 (file)
@@ -1,3 +1,29 @@
+/*
+ * 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>
@@ -24,6 +50,8 @@
 
 #define LOCATION_STATUS 120
 
+#define NFC_STATUS 121
+
 struct LXT_MESSAGE// lxt_message
 {
        unsigned short length;
@@ -50,3 +78,6 @@ char* get_magnetic_value(void* );
 
 // Location
 char* get_location_status(void* );
+
+// NFC
+char* get_nfc_status(void* );
index 4dade3a..c51c9ba 100644 (file)
@@ -1,6 +1,6 @@
 #git:/slp/pkgs/e/emulator-daemon
 Name: emuld
-Version: 0.2.21
+Version: 0.2.22
 Release: 1
 Summary: emuld is used for communication emulator between and ide.
 License: Apache
index e271143..bc8fdf8 100644 (file)
@@ -5,7 +5,6 @@
  *
  * 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");
@@ -765,44 +764,40 @@ void client_recv(int event_fd)
                                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)
                {
@@ -1067,6 +1062,12 @@ void setting_device()
                        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;
index 1a02eca..0867af7 100644 (file)
@@ -1,3 +1,29 @@
+/*
+ * 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"
 
@@ -347,3 +373,24 @@ char* get_location_status(void* p)
 
        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;
+}