QTAILQ_ENTRY(NFCBuf) next;
} NFCBuf;
+
+static char nfc_data [NFC_MAX_BUF_SIZE] = {'0',};
static pthread_mutex_t recv_buf_mutex = PTHREAD_MUTEX_INITIALIZER;
+static void send_nfc_data_to_ecs(const char* data)
+{
+ type_length length = 0;
+ type_group group = 15;
+ type_action action = 0;
+ int buf_len = strlen(data);
+ int message_len = buf_len + 14;
+
+ char* ecs_message = (char*) malloc(message_len + 1);
+ if (!ecs_message)
+ return;
+
+ memset(ecs_message, 0, message_len + 1);
+
+ length = (unsigned short) buf_len;
+ action = 0;
+
+ memcpy(ecs_message, MESSAGE_TYPE_NFC, 3);
+ memcpy(ecs_message + 10, &length, sizeof(unsigned short));
+ memcpy(ecs_message + 12, &group, sizeof(unsigned char));
+ memcpy(ecs_message + 13, &action, sizeof(unsigned char));
+ memcpy(ecs_message + 14, data, buf_len);
+
+ TRACE("ntf_to_injector- len: %d, group: %d, action: %d, data: %s\n", length, group, action, data);
+
+ send_device_ntf(ecs_message, message_len);
+
+ if (ecs_message)
+ free(ecs_message);
+}
+
+void get_nfc_data(void)
+{
+ send_nfc_data_to_ecs(nfc_data);
+}
+
bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len)
{
if(vio_nfc == NULL) {
_msg->info.client_type = type;
pthread_mutex_lock(&recv_buf_mutex);
-
+ strcpy(nfc_data, data);
QTAILQ_INSERT_TAIL(&nfc_recv_msg_queue, _msg, next);
pthread_mutex_unlock(&recv_buf_mutex);
-/*\r
- * Virtio NFC Device\r
- *\r
- * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Contact:\r
- * Munkyu Im <munkyu.im@samsung.com>\r
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
- *\r
- * Contributors:\r
- * - S-Core Co., Ltd\r
- *\r
- */\r
-\r
-#ifndef MARU_VIRTIO_NFC_H_\r
-#define MARU_VIRTIO_NFC_H_\r
-\r
-#ifdef __cplusplus\r
-extern "C" {\r
-#endif\r
-\r
-#include "hw/virtio/virtio.h"\r
-\r
-enum request_cmd_nfc {\r
- request_nfc_get = 0,\r
- request_nfc_set,\r
- request_nfc_answer\r
-};\r
-\r
-\r
-/* device protocol */\r
-\r
-#define __MAX_BUF_SIZE 1024\r
-\r
-\r
-typedef struct VirtIONFC{\r
- VirtIODevice vdev;\r
- VirtQueue *rvq;\r
- VirtQueue *svq;\r
- DeviceState *qdev;\r
-\r
- QEMUBH *bh;\r
-} VirtIONFC;\r
-\r
-\r
-#define TYPE_VIRTIO_NFC "virtio-nfc-device"\r
-#define VIRTIO_NFC(obj) \\r
- OBJECT_CHECK(VirtIONFC, (obj), TYPE_VIRTIO_NFC)\r
-\r
-\r
-bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len);\r
-\r
-#ifdef __cplusplus\r
-}\r
-#endif\r
-\r
-\r
-#endif /* MARU_VIRTIO_NFC_H_ */\r
+/*
+ * Virtio NFC Device
+ *
+ * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact:
+ * Munkyu Im <munkyu.im@samsung.com>
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Contributors:
+ * - S-Core Co., Ltd
+ *
+ */
+
+#ifndef MARU_VIRTIO_NFC_H_
+#define MARU_VIRTIO_NFC_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "hw/virtio/virtio.h"
+
+enum request_cmd_nfc {
+ request_nfc_get = 0,
+ request_nfc_set,
+ request_nfc_answer
+};
+
+
+/* device protocol */
+
+#define __MAX_BUF_SIZE 1024
+#define MESSAGE_TYPE_NFC "nfc"
+
+typedef struct VirtIONFC{
+ VirtIODevice vdev;
+ VirtQueue *rvq;
+ VirtQueue *svq;
+ DeviceState *qdev;
+
+ QEMUBH *bh;
+} VirtIONFC;
+
+
+#define TYPE_VIRTIO_NFC "virtio-nfc-device"
+#define VIRTIO_NFC(obj) \
+ OBJECT_CHECK(VirtIONFC, (obj), TYPE_VIRTIO_NFC)
+
+
+bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const uint32_t len);
+void get_nfc_data(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* MARU_VIRTIO_NFC_H_ */