From: Munkyu Im Date: Wed, 27 Aug 2014 07:28:51 +0000 (+0900) Subject: nfc: Add getting status X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~228^2^2~23 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=538ba38e818ac081920c074ff5f694ecd30b7735;p=sdk%2Femulator%2Fqemu.git nfc: Add getting status Client can get nfc status from nfc device. Change-Id: I1a10cfccebe6031aa6b70da3ad93dd834803029a Signed-off-by: Munkyu Im --- diff --git a/tizen/src/ecs/ecs_msg.c b/tizen/src/ecs/ecs_msg.c index 2e84435825..d7a8b34f3f 100644 --- a/tizen/src/ecs/ecs_msg.c +++ b/tizen/src/ecs/ecs_msg.c @@ -615,8 +615,7 @@ bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg) msgproc_device_ans(ccli, cmd, true, vmname); } else if (!strcmp(cmd, "nfc")) { if (group == MSG_GROUP_STATUS) { - //TODO: - INFO("get nfc data: do nothing\n"); + get_nfc_data(); } else { if (data != NULL) { send_to_nfc(ccli->client_id, ccli->client_type, data, msg->data.len); diff --git a/tizen/src/hw/virtio/maru_virtio_nfc.c b/tizen/src/hw/virtio/maru_virtio_nfc.c index ce632e63d3..df589f0614 100644 --- a/tizen/src/hw/virtio/maru_virtio_nfc.c +++ b/tizen/src/hw/virtio/maru_virtio_nfc.c @@ -63,8 +63,46 @@ typedef struct NFCBuf { 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) { @@ -96,7 +134,7 @@ bool send_to_nfc(unsigned char id, unsigned char type, const char* data, const u _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); diff --git a/tizen/src/hw/virtio/maru_virtio_nfc.h b/tizen/src/hw/virtio/maru_virtio_nfc.h index 17c539aba8..5a991b6be8 100644 --- a/tizen/src/hw/virtio/maru_virtio_nfc.h +++ b/tizen/src/hw/virtio/maru_virtio_nfc.h @@ -1,72 +1,73 @@ -/* - * Virtio NFC Device - * - * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved - * - * Contact: - * Munkyu Im - * YeongKyoon Lee - * - * 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 - - -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); - -#ifdef __cplusplus -} -#endif - - -#endif /* MARU_VIRTIO_NFC_H_ */ +/* + * Virtio NFC Device + * + * Copyright (c) 2013 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * Munkyu Im + * YeongKyoon Lee + * + * 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_ */