It helps to communicate between ecs and nfc event injectors.
Change-Id: I4fc7fb4ac57b52fc793a32291954337700195d6b
Signed-off-by: munkyu.im <munkyu.im@samsung.com>
goto fail;
msgproc_device_req(cli, msg);
}
+ else if (master->type == ECS__MASTER__TYPE__NFC_REQ)
+ {
+ ECS__NfcReq* msg = master->nfc_req;
+ if (!msg)
+ goto fail;
+ msgproc_nfc_req(cli, msg);
+ }
+
ecs__master__free_unpacked(master, NULL);
return true;
fail:
bool send_injector_ntf(const char* data, const int len);
bool send_monitor_ntf(const char* data, const int len);
bool send_device_ntf(const char* data, const int len);
+bool send_nfc_ntf(const char* data, const int len);
bool send_to_all_client(const char* data, const int len);
void send_to_client(int fd, const char* data, const int len) ;
bool msgproc_injector_req(ECS_Client* ccli, ECS__InjectorReq* msg);
bool msgproc_monitor_req(ECS_Client *ccli, ECS__MonitorReq* msg);
bool msgproc_device_req(ECS_Client* ccli, ECS__DeviceReq* msg);
+bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg);
/* request */
int accel_min_max(double value);
#include "hw/maru_virtio_nfc.h"
#include "skin/maruskin_operation.h"
+#define MAX_BUF_SIZE 255
// utility functions
static void* build_master(ECS__Master* master, int* payloadsize)
set_sensor_data(length, data);
}
}
- else if (!strncmp(cmd, MSG_TYPE_NFC, 3)) {
- if (group == MSG_GROUP_STATUS) {
- send_to_nfc(request_nfc_get, data, length);
- }
- else
- {
- send_to_nfc(request_nfc_set, data, length);
- }
+
+ return true;
+}
+
+
+bool msgproc_nfc_req(ECS_Client* ccli, ECS__NfcReq* msg)
+{
+ char cmd[10];
+ char* data = NULL;
+ memset(cmd, 0, 10);
+ strcpy(cmd, msg->category);
+
+ if (msg->has_data && msg->data.len > 0)
+ {
+ data = (char*)msg->data.data;
+ }
+
+ if (!strncmp(cmd, MSG_TYPE_NFC, 3)) {
+ send_to_nfc(request_nfc_set, data, msg->data.len);
}
return true;
}
+
#if 0
bool msgproc_screen_dump_req(ECS_Client *ccli, ECS__ScreenDumpReq* msg)
{
return true;
}
+bool send_nfc_ntf(const char* data, const int len)
+{
+ const int catsize = 10;
+ char cat[catsize + 1];
+ memset(cat, 0, catsize + 1);
+
+ read_val_str(data, cat, catsize);
+
+ const char* ijdata = (data + catsize + 2);
+
+ LOG("<< header cat = %s", cat);
+
+ ECS__Master master = ECS__MASTER__INIT;
+ ECS__NfcNtf ntf = ECS__NFC_NTF__INIT;
+
+ ntf.category = (char*) g_malloc(catsize + 1);
+ strncpy(ntf.category, cat, 10);
+
+ ntf.has_data = 1;
+
+ ntf.data.data = g_malloc(MAX_BUF_SIZE);
+ ntf.data.len = MAX_BUF_SIZE;
+ memcpy(ntf.data.data, ijdata, MAX_BUF_SIZE);
+
+ LOG("data = %s, length = %d", ijdata, len);
+
+ master.type = ECS__MASTER__TYPE__NFC_NTF;
+ master.nfc_ntf = &ntf;
+
+ send_to_ecp(&master);
+
+ if (ntf.data.data && ntf.data.len > 0)
+ {
+ g_free(ntf.data.data);
+ }
+
+ if (ntf.category)
+ g_free(ntf.category);
+
+ return true;
+}
+
MULTI_DEBUG_CHANNEL(qemu, virtio-nfc);
#define NFC_DEVICE_NAME "virtio-nfc"
-
+#define MAX_BUF_SIZE 255
enum {
IOTYPE_INPUT = 0,
#define min(a,b) ((a)<(b)?(a):(b))
#endif
-#define MAX_BUF_SIZE 4096
-
-
VirtIONFC* vio_nfc;
static void send_to_ecs(struct msg_info* msg)
{
type_length length = 0;
- type_group group = 15;
- type_action action = 0;
- int buf_len = strlen(msg->buf);
- int message_len = buf_len + 14;
+ int buf_len = MAX_BUF_SIZE;
+ int message_len = buf_len + 10;
char* ecs_message = (char*) malloc(message_len + 1);
if (!ecs_message)
length = (unsigned short) buf_len;
memcpy(ecs_message, "nfc", 10);
- 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, msg->buf, buf_len);
+ memcpy(ecs_message + 10, msg->buf, buf_len);
- INFO("ntf_to_injector- len: %d, group: %d, action: %d, data: %s\n", length, group, action, msg->buf);
+ INFO("ntf_to_injector- len: %d, data: %s\n", length , msg->buf);
- send_device_ntf(ecs_message, message_len);
+ send_nfc_ntf(ecs_message, message_len);
if (ecs_message)
free(ecs_message);