-HyunGoo Kang <hyungoo1.kang@samsung.com>
YeongKyoon Lee <yeongkyoon.lee@samsung.com>
-DongKyun Yun <dk77.yun@samsung.com>
-DoHyung Hong <don.hong@samsung.com>
+DaiYoung Kim <daiyoung777.kim@samsung.com>
SeokYeon Hwang <syeon.hwang@samsung.com>
-Hyunjun Son <hj79.son@samsung.com>
SangJin Kim <sangjin3.kim@samsung.com>
KiTae Kim <kt920.kim@samsung.com>
JinHyung Jo <jinhyung.jo@samsung.com>
MunKyu Im <munkyu.im@samsung.com>
JiHye Kim <jihye1128.kim@samsung.com>
GiWoong Kim <giwoong.kim@samsung.com>
+SooYoung Ha <yoosah.ha@samsnung.com>
+HyunGoo Kang <hyungoo1.kang@samsung.com>
+
add_definitions(-Wall -O3 -omit-frame-pointer)
#add_definitions(-Wall -g -D_DEBUG)
add_definitions(-Iinclude)
-ADD_EXECUTABLE(${PROJECT_NAME} src/emuld.c)
+ADD_EXECUTABLE(${PROJECT_NAME} src/emuld.c src/get_status.c)
target_link_libraries(${PROJECT_NAME} ${rpkgs_LDFLAGS} ${GLES_LDFLAGS})
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread" )
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} "-lpthread -lvconf" )
install(TARGETS ${PROJECT_NAME} DESTINATION /usr/bin)
--- /dev/null
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
-Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+Copyright (c) 2000 - 2013 Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE.APLv2 file for Apache License Version 2, terms and conditions.
-emuld (0.2.4) unstable; urgency=low
+emuld (0.2.20) unstable; urgency=low
- * modified post install script for fix install error
+ * add checking routine 'recv' function's return value
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.20
- -- Sungmin Ha <sungmin82.ha@samsung.com> Mon, 20 Feb 2012 15:16:52 +0900
+ -- Jihye kim <jihye1128.kim@samsung.com> Mon, 04 Nov 2012 20:00:18 +0900
-emuld (0.2.3) unstable; urgency=low
+emuld (0.2.18) unstable; urgency=low
- * modified for build only i386
+ * fixed hang up when sending packet vmodem to eventinjector
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.18
- -- Sungmin Ha <sungmin82.ha@samsung.com> Sat, 18 Feb 2012 13:06:52 +0900
+ -- Sungmin ha <sungmin82.ha@samsung.com> Wed, 12 Sep 2012 20:00:18 +0900
-emuld (0.2.2) unstable; urgency=low
+emuld (0.2.17) unstable; urgency=low
+
+ * modified for scm build
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.17
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Thu, 09 Aug 2012 21:00:18 +0900
+
+emuld (0.2.15) unstable; urgency=low
+
+ * Permission of sdcard partition changed from 755 to 777.
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.15
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Wed, 11 Jul 2012 19:38:44 +0900
+
+emuld (0.2.14) unstable; urgency=low
+
+ * modified for checking resource busy when umount sdcard
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.14
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Thu, 05 Jul 2012 21:03:00 +0900
+
+emuld (0.2.12) unstable; urgency=low
+
+ * modified for checking return value of fopen
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.12
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Fri, 22 Jun 2012 18:23:00 +0900
+
+emuld (0.2.10) unstable; urgency=low
+
+ * deleted process kill when umount
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.10
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Thu, 15 Jun 2012 16:16:00 +0900
+
+emuld (0.2.9) unstable; urgency=low
+
+ * modified vconf key path for sdcard supporting
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.9
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Thu, 14 Jun 2012 16:04:00 +0900
+
+emuld (0.2.8) unstable; urgency=low
+
+ * added sdcard mount/umount handling
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.8
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Tue, 29 May 2012 18:47:00 +0900
+
+emuld (0.2.7) unstable; urgency=low
+
+ * added exception handling
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.7
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Mon, 14 May 2012 18:10:00 +0900
+
+emuld (0.2.6) unstable; urgency=low
+
+ * modified how to get host ip
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.6
+
+ -- Sungmin ha <sungmin82.ha@samsung.com> Fri, 11 May 2012 18:05:00 +0900
+
+emuld (0.2.5) unstable; urgency=low
+
+ * add setting location replay and modify nfc.
+ * need sinchronization with event injector
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.5
+
+ -- Jihye kim <jihye1128.kim@samsung.com> Thu, 10 May 2012 11:30:00 +0900
+
+emuld (0.2.4) unstable; urgency=low
+
+ * back to the 0.2.2
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.4
+
+ -- Jihye kim <jihye1128.kim@samsung.com> Thu, 4 May 2012 11:50:00 +0900
+
+emuld (0.2.3) unstable; urgency=low
- * modified for distinction close fd by event injector
+ * Add making 'sdkMsg' file during post install.
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.3
- -- Sungmin Ha <sungmin82.ha@samsung.com> Wed, 15 Feb 2012 15:35:52 +0900
+ -- Jihye kim <jihye1128.kim@samsung.com> Wen, 02 May 2012 14:00:00 +0900
emuld (0.2.2) unstable; urgency=low
- * modified for distinction close fd by event injector
+ * Update changelog version.
+ * Git: slp/pkgs/e/emulator-daemon
+ * Tag: emuld_0.2.2
- -- Sungmin Ha <sungmin82.ha@samsung.com> Wed, 15 Feb 2012 15:35:52 +0900
+ -- Kitae kim <kt920.kim@samsung.com> Thu, 27 Mar 2012 20:00:00 +0900
emuld (0.2.1) unstable; urgency=low
Source: emuld
Section: misc
Priority: extra
-Maintainer: Sungmin Ha <sungmin82.ha@samsung.com>
-Standards-Version: 0.2.4
+Maintainer:Sungmin Ha <sungmin82.ha@samsung.com>,Jihye Kim <jihye1128.kim@samsung.com>,Yeongkyoon Lee <yeongkyoon.lee@samsung.com>
+Standards-Version: 0.2.20
Package: emuld
Section: misc
-This is $PACKAGE_NAME, written and maintained by $NAME <$EMAIL>
-on Fri, 18 Nov 2011 17:08:22 +0900.
-The original source can always be found at:
- slp/sdk/public/common/emulator/default-files-emulator/src/emulator-daemon
-
-Copyright Holder: $NAME
-
-License:
- samsung
-
-/*
- * Copyright (c) 2008 Samsung Electronics, Inc.
- * All rights reserved.
- *
- * This software is a confidential and proprietary information
- * of Samsung Electronics, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Samsung Electronics.
- */
#!/bin/sh
chmod 777 /usr/bin/emuld
-
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
+ * SooYoung Ha <yoosah.ha@samsnung.com>
* 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");
#include <stdarg.h>
#include <sys/time.h>
#include <pthread.h>
+#include <dirent.h>
+#include <sys/stat.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/mount.h>
/* definition */
#define MAX_CLIENT 10000
#define VMODEM_PORT 3578
#define GPSD_PORT 3579
#define SENSORD_PORT 3580
-#define EMUL_IP "10.0.2.16"
+#define SRV_IP "10.0.2.2"
#define ID_SIZE 10
#define HEADER_SIZE 4
#define EMD_DEBUG
void client_recv(int event_fd);
void server_process(void);
void end_server(int sig);
+int is_mounted(void);
static int log_print = -1;
FILE* log_fd;
+// location
+void setting_location(char* databuf);
+
#define LOG(fmt, arg...) \
do { \
log_print_out("[%s:%d] "fmt"\n", __FUNCTION__, __LINE__, ##arg); \
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * 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>
+#include <assert.h>
+#include <errno.h>
+
+// define group id
+// return value to the injector
+#define STATUS 15
+
+// define action id
+#define BATTERY_LEVEL 100
+#define BATTERY_CHARGER 101
+#define USB_STATUS 102
+#define EARJACK_STATUS 103
+#define RSSI_LEVEL 104
+
+#define ACCEL_VALUE 110
+#define GYRO_VALUE 111
+#define MAG_VALUE 112
+#define LIGHT_VALUE 113
+#define PROXI_VALUE 114
+#define MOTION_VALUE 115
+
+#define LOCATION_STATUS 120
+
+#define NFC_STATUS 121
+
+struct LXT_MESSAGE// lxt_message
+{
+ unsigned short length;
+ unsigned char group;
+ unsigned char action;
+ void *data;
+};
+
+typedef struct LXT_MESSAGE LXT_MESSAGE;
+
+// Device
+char* get_battery_level(void* );
+char* get_battery_charger(void* );
+char* get_usb_status(void* );
+char* get_earjack_status(void* );
+char* get_rssi_level(void* );
+
+// Sensor
+char* get_proximity_status(void* );
+char* get_light_level(void* );
+char* get_acceleration_value(void* );
+char* get_gyroscope_value(void* );
+char* get_magnetic_value(void* );
+
+// Location
+char* get_location_status(void* );
+
+// NFC
+char* get_nfc_status(void* );
--- /dev/null
+<manifest>
+ <request>
+ <domain name="_"/>
+ </request>
+</manifest>
--- /dev/null
+#git:/slp/pkgs/e/emulator-daemon
+Name: emuld
+Version: 0.2.27
+Release: 1
+Summary: emuld is used for communication emulator between and ide.
+License: Apache
+Source0: %{name}-%{version}.tar.gz
+Source1001: packaging/emuld.manifest
+BuildRequires: cmake
+BuildRequires: pkgconfig(vconf)
+
+%description
+
+%prep
+%setup -q
+
+%build
+export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+
+LDFLAGS="$LDFLAGS" cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
+
+make
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+%clean
+make clean
+rm -rf CMakeCache.txt
+rm -rf CMakeFiles
+rm -rf cmake_install.cmake
+rm -rf Makefile
+rm -rf install_manifes.txt
+
+%post
+chmod 777 /usr/bin/emuld
+mkdir -p /opt/nfc
+touch /opt/nfc/sdkMsg
+
+%postun
+
+%files
+%defattr(-,root,root,-)
+%{_prefix}/bin/emuld
+
+%changelog
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
*
- * Contact:
+ * Contact:
+ * SooYoung Ha <yoosah.ha@samsnung.com>
* 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");
License: GNU General Public License
------------------------------------------------------------------*/
-
+#include "emuld_common.h"
#include "emuld.h"
/* global definition */
int g_vm_sockfd; /* vmodem fd */
int g_sdbd_sockfd = -1; /* sdbd fd */
static int g_vm_connect_status; /* connection status between emuld and vmodem */
+int g_sdcard_sockfd = -1;
+int g_get_status_sockfd = -1; /* return status of devive to the injector */
pthread_t tid[MAX_CLIENT + 1];
struct epoll_event g_events[MAX_EVENTS];
+void TAPIMessageInit(LXT_MESSAGE *packet)
+{
+ packet->length = 0;
+ packet->group = 0;
+ packet->action = 0;
+ packet->data = 0;
+}
+
+char SDpath[256];
+
+unsigned char ActionID = 0;
+char GetBuffer[256];
+void setting_device();
/*--------------------------------------------------------------*/
/* FUNCTION PART
---------------------------------------------------------------*/
g_vm_connect_status = 1;
pthread_exit((void *) 0);
+}
+
+int is_mounted()
+{
+ int ret = -1, i = 0;
+ struct stat buf;
+ char file_name[128];
+ memset(file_name, '\0', sizeof(file_name));
+
+ for(i = 0; i < 10; i++)
+ {
+ sprintf(file_name, "/dev/emul_mmcblk%d", i);
+ ret = access( file_name, F_OK );
+ if( ret == 0 )
+ {
+ lstat(file_name, &buf);
+ if(S_ISBLK(buf.st_mode))
+ return 1;
+ else
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+void* mount_sdcard(void* data)
+{
+ int ret = -1, i = 0, vconf_value = -1;
+ struct stat buf;
+ char file_name[128], command[256];
+ memset(file_name, '\0', sizeof(file_name));
+ memset(command, '\0', sizeof(command));
+
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+
+ LOG("start sdcard mount thread");
+
+ pthread_detach(pthread_self());
+
+ while(ret < 0)
+ {
+ for(i = 0; i < 10; i++)
+ {
+ sprintf(file_name, "/dev/emul_mmcblk%d", i);
+ ret = access( file_name, F_OK );
+ if( ret == 0 )
+ {
+ lstat(file_name, &buf);
+ if(!S_ISBLK(buf.st_mode))
+ {
+ sprintf(command, "rm -rf %s", file_name);
+ system(command);
+ }
+ else
+ break;
+ }
+ }
+
+ if( i != 10 )
+ {
+ LOG( "%s is exist", file_name);
+ ret = mount(file_name, "/mnt/mmc", "ext3", 0, "");
+ LOG("mount ret = %d, errno = %d", ret, errno);
+
+ LOG("sdcard fd: %d", g_sdcard_sockfd);
+ if(g_sdcard_sockfd != -1)
+ {
+ packet->length = strlen(SDpath); // length
+ packet->group = 11; // sdcard
+ if(ret == 0)
+ packet->action = 1; // mounted
+ else
+ packet->action = 5; // failed
+
+ send(g_sdcard_sockfd, (void*)packet, sizeof(char) * HEADER_SIZE, 0);
+ LOG("SDpath is %s", SDpath);
+ send(g_sdcard_sockfd, SDpath, packet->length, 0);
+
+ if(ret == 0)
+ {
+ //system("if [ ! -d /opt/storage/sdcard/Camera ]; then mkdir -p /opt/storage/sdcard/Camera; fi");
+ system("chmod -R 777 /opt/storage/sdcard");
+ system("vconftool set -t int memory/sysman/mmc 1 -i -f");
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ LOG( "%s is not exist", file_name);
+ sleep(1);
+ }
+ }
+
+ pthread_exit((void *) 0);
+}
+
+int umount_sdcard(void)
+{
+ int ret = -1, i = 0;
+ char file_name[128];
+ memset(file_name, '\0', sizeof(file_name));
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+ if(packet == NULL){
+ return ret;
+ }
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+
+ LOG("start sdcard umount");
+
+ pthread_cancel(tid[1]);
+
+ for(i = 0; i < 10; i++)
+ {
+ sprintf(file_name, "/dev/emul_mmcblk%d", i);
+ ret = access( file_name, F_OK);
+ if ( ret == 0 )
+ {
+ LOG( "%s is exist", file_name);
+ ret = umount("/mnt/mmc");
+ LOG("umount ret = %d, errno = %d", ret, errno);
+
+ LOG("sdcard fd: %d", g_sdcard_sockfd);
+ if(g_sdcard_sockfd != -1)
+ {
+ packet->length = strlen(SDpath); // length
+ packet->group = 11; // sdcard
+
+ if(ret != 0 && errno == 16) // EBUSY
+ packet->action = 4; // failed
+ else
+ packet->action = 0; // do detach
+
+ send(g_sdcard_sockfd, (void*)packet, sizeof(char) * HEADER_SIZE, 0);
+ LOG("SDpath is %s", SDpath);
+ send(g_sdcard_sockfd, SDpath, packet->length, 0);
+
+ if(ret == 0)
+ {
+ memset(SDpath, '\0', sizeof(SDpath));
+ sprintf(SDpath, "umounted");
+ system("vconftool set -t int memory/sysman/mmc 0 -i -f");
+ } else if (packet->action == 0){ // not busy, then force detach
+ memset(SDpath, '\0', sizeof(SDpath));
+ sprintf(SDpath, "umounted");
+ ret = 0;
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ LOG( "%s is not exist", file_name);
+ }
+ }
+
+ if(packet){
+ free(packet);
+ packet = NULL;
+ }
+ return ret;
}
void epoll_init(void)
{
if(g_client[i].cli_sockfd == -1) break;
}
- if( i >= MAX_CLIENT ) close(cli_fd);
+ if( i >= MAX_CLIENT ){
+ close(cli_fd);
+ return;
+ }
LOG("g_client[%d].cli_port: %d", i, cli_port);
{
if(g_client[i].cli_sockfd == cli_fd)
{
- g_client[i].cli_sockfd = -1;
+ g_client[i].cli_sockfd = -1;
break;
}
}
void udp_init(void)
{
LOG("start");
+ char* emul_ip = getenv("HOSTNAME");
+ if(emul_ip == NULL)
+ {
+ LOG("emul_ip is null");
+ assert(0);
+ }
if ((uSensordFd=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1){
fprintf(stderr, "socket error!\n");
memset((char *) &si_sensord_other, 0, sizeof(si_sensord_other));
si_sensord_other.sin_family = AF_INET;
si_sensord_other.sin_port = htons(sensord_port);
- if (inet_aton(EMUL_IP, &si_sensord_other.sin_addr)==0) {
+ if (inet_aton(emul_ip, &si_sensord_other.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
}
memset((char *) &si_gpsd_other, 0, sizeof(si_gpsd_other));
si_gpsd_other.sin_family = AF_INET;
si_gpsd_other.sin_port = htons(gpsd_port);
- if (inet_aton(EMUL_IP, &si_gpsd_other.sin_addr)==0) {
+ if (inet_aton(emul_ip, &si_gpsd_other.sin_addr)==0) {
fprintf(stderr, "inet_aton() failed\n");
}
}
-// for vmodem packets
-typedef struct // lxt_message
-{
- unsigned short length;
- unsigned char group;
- unsigned char action;
- void *data;
-} LXT_MESSAGE;
-
-void TAPIMessageInit(LXT_MESSAGE *packet)
-{
- packet->length = 0;
- packet->group = 0;
- packet->action = 0;
- packet->data = 0;
-}
-
int recv_data(int event_fd, char** r_databuf, int size)
{
int recvd_size = 0;
int getcnt = 0;
char* r_tmpbuf = NULL;
- r_tmpbuf = (char*)malloc(sizeof(char) * size);
- *r_databuf = (char*)malloc(sizeof(char) * size);
- memset(*r_databuf, '\0', sizeof(char) * size);
+ r_tmpbuf = (char*)malloc(sizeof(char) * size + 1);
+ if(r_tmpbuf == NULL){
+ return -1;
+ }
+
+ *r_databuf = (char*)malloc(sizeof(char) * size + 1);
+ if(*r_databuf == NULL){
+ free(r_tmpbuf);
+ return -1;
+ }
+ memset(*r_databuf, '\0', sizeof(char) * size + 1);
while(recvd_size < size)
{
- memset(r_tmpbuf, '\0', sizeof(char) * size);
+ memset(r_tmpbuf, '\0', sizeof(char) * size + 1);
len = recv(event_fd, r_tmpbuf, size - recvd_size, 0);
+ if (len < 0) {
+ break;
+ }
+
memcpy((*r_databuf) + recvd_size, r_tmpbuf, len);
recvd_size += len;
getcnt++;
- if(getcnt > MAX_GETCNT)
+ if(getcnt > MAX_GETCNT) {
break;
+ }
}
free(r_tmpbuf);
r_tmpbuf = NULL;
/* Getting poweroff duration */
buf = getenv("PWROFF_DUR");
- if (buf != NULL && strlen(buf) < 1024)
+ if(buf == NULL)
+ {
+ LOG("PWROFF_DUR is null");
+ assert(0);
+ }
+
+ if (strlen(buf) < 1024)
poweroff_duration = atoi(buf);
if (poweroff_duration < 0 || poweroff_duration > 60)
poweroff_duration = POWEROFF_DURATION;
char tmpbuf[48];
int len, recvd_size, parse_len = 0;
LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+ if (packet == NULL)
+ {
+ return;
+ }
memset(packet, 0, sizeof(LXT_MESSAGE));
- LOG("start");
+ LOG("start (event fd: %d)", event_fd);
/* there need to be more precise code here */
/* for example , packet check(protocol needed) , real recv size check , etc. */
+ if (event_fd == -1) {
+ free(packet);
+ packet = NULL;
+ return;
+ }
// vmodem to event injector
if(event_fd == g_vm_sockfd)
{
recvd_size = recv_data(event_fd, &r_databuf, HEADER_SIZE);
-
- LOG("recv_len: %d, vmodem header recv buffer: %s", recvd_size, r_databuf);
-
+ LOG("receive size: %d", recvd_size);
if(recvd_size <= 0)
{
free(r_databuf);
return;
}
+ LOG("vmodem header recv buffer: %s", r_databuf);
memcpy((void*)packet, (void*)r_databuf, sizeof(char) * HEADER_SIZE);
LOG("first packet of vmodem to event injector %s", r_databuf);
if(g_sdbd_sockfd != -1)
len = send(g_sdbd_sockfd, (void*)packet, sizeof(char) * HEADER_SIZE, 0);
- else
+ else {
+ free(packet);
+ packet = NULL;
return;
+ }
LOG("send_len: %d, next packet length: %d", len, packet->length);
if(g_sdbd_sockfd != -1)
recvd_size = recv_data(event_fd, &r_databuf, packet->length);
else
+ {
+ // for packet clear
+ recvd_size = recv_data(event_fd, &r_databuf, packet->length);
return;
+ }
LOG("recv_len: %d, vmodem data recv buffer: %s", recvd_size, r_databuf);
/* read from socket */
// read identifier
recvd_size = recv_data(event_fd, &r_databuf, ID_SIZE);
-
- LOG("Something may be added in the data end, but it does not matter.");
- LOG("identifier: %s", r_databuf);
-
+ LOG("receive size: %d", recvd_size);
if( recvd_size <= 0 )
{
free(r_databuf);
r_databuf = NULL;
+ free(packet);
+ packet = NULL;
LOG("close event_fd: %d", event_fd);
userpool_delete(event_fd);
close(event_fd); /* epoll set fd also deleted automatically by this call as a spec */
- if(event_fd == g_sdbd_sockfd)
+ if(event_fd == g_sdbd_sockfd)
g_sdbd_sockfd = -1;
+
return;
}
+ LOG("Something may be added in the data end, but it does not matter.");
+ LOG("identifier: %s", r_databuf);
+
memset(tmpbuf, '\0', sizeof(tmpbuf));
parse_len = parse_val(r_databuf, 0x0a, tmpbuf);
if(strncmp(tmpbuf, "telephony", 9) == 0)
{
g_sdbd_sockfd = event_fd;
- if(g_vm_connect_status != 1) // The connection is lost with vmodem
+ if(g_vm_connect_status != 1) { // The connection is lost with vmodem
+ free(packet);
+ packet = NULL;
return;
+ }
recvd_size = recv_data(event_fd, &r_databuf, HEADER_SIZE);
len = send(g_vm_sockfd, r_databuf, HEADER_SIZE, 0);
recvd_size = recv_data(event_fd, &r_databuf, packet->length);
- LOG("Something may be added in the data end, but it does not matter.");
- LOG("telephony data recv buffer: %s", r_databuf);
-
if(recvd_size <= 0)
{
free(r_databuf);
free(packet);
packet = NULL;
return;
- }
- else
+ } else {
+ LOG("Something may be added in the data end, but it does not matter.");
+ LOG("telephony data recv buffer: %s", r_databuf);
+
len = send(g_vm_sockfd, r_databuf, packet->length, 0);
+ }
}
else if(strncmp(tmpbuf, "sensor", 6) == 0)
{
LOG("Something may be added in the data end, but it does not matter.");
LOG("sensor data recv buffer: %s", r_databuf);
- if(sendto(uSensordFd, r_databuf, packet->length, 0, (struct sockaddr*)&si_sensord_other, sslen) == -1)
+ 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 if(sendto(uSensordFd, r_databuf, packet->length, 0, (struct sockaddr*)&si_sensord_other, sslen) == -1) {
LOG("sendto error!");
+ }
}
else if(strncmp(tmpbuf, "location", 8) == 0)
{
LOG("Something may be added in the data end, but it does not matter.");
LOG("location data recv buffer: %s", r_databuf);
- if(sendto(uGpsdFd, r_databuf, packet->length, 0, (struct sockaddr*)&si_gpsd_other, sglen) == -1)
- LOG("sendto error!");
+ 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 {
+ setting_location(r_databuf);
+ }
}
else if(strncmp(tmpbuf, "nfc", 3) == 0)
{
- recvd_size = recv_data(event_fd, &r_databuf, 5);
-
- LOG("nfc packet length r_databuf: %s", r_databuf);
-
- if( recvd_size <= 0 )
+ recvd_size = recv_data(event_fd, &r_databuf, HEADER_SIZE);
+ if( recvd_size <= 0 )
{
free(r_databuf);
r_databuf = NULL;
+ free(packet);
+ packet = NULL;
return;
}
- memset(tmpbuf, '\0', sizeof(tmpbuf));
- parse_len = parse_val(r_databuf, 0x0a, tmpbuf);
+ memcpy((void*)packet, (void*)r_databuf, HEADER_SIZE);
+ LOG("nfc packet_length: %d", packet->length);
- int length = atoi(tmpbuf);
-
- LOG("nfc packet converted length: %d", length);
- free(r_databuf);
+ free(r_databuf);
r_databuf = NULL;
+ recvd_size = recv_data(event_fd, &r_databuf, packet->length);
+ if(r_databuf == NULL){
+ free(packet);
+ packet = NULL;
+ return;
+ }
+ LOG("nfc data recv buffer: %s", r_databuf);
- 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);
-
- LOG("nfc data recv buffer: %s", strbuf);
+ 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);
- FILE* fd;
- fd = fopen("/opt/nfc/sdkMsg", "w");
- if(fd < 0)
- {
- LOG("nfc file open fail!");
- free(packet);
- packet = NULL;
- return;
+ 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(r_databuf);
+ r_databuf = NULL;
+ free(packet);
+ packet = NULL;
+ return;
+ }
+ fprintf(fd, "%s", r_databuf);
+ fclose(fd);
+ //free(strbuf);
+ //strbuf = NULL;
}
- fprintf(fd, "%s", strbuf);
- fclose(fd);
- free(strbuf);
- strbuf = NULL;
}
else if(strncmp(tmpbuf, "system", 6) == 0)
{
powerdown_by_force();
}
+ else if(strncmp(tmpbuf, "sdcard", 6) == 0)
+ {
+ g_sdcard_sockfd = event_fd;
+ recvd_size = recv_data(event_fd, &r_databuf, HEADER_SIZE);
+ memcpy((void*)packet, (void*)r_databuf, HEADER_SIZE);
+
+ LOG("sdcard packet_length: %d", packet->length);
+
+ free(r_databuf);
+ r_databuf = NULL;
+ recvd_size = recv_data(event_fd, &r_databuf, packet->length);
+ if(recvd_size <= 0){
+ LOG("client_recv: recv_data err");
+ if(r_databuf) {
+ free(r_databuf);
+ r_databuf = NULL;
+ }
+ if(packet) {
+ free(packet);
+ packet = NULL;
+ }
+ LOG("close event_fd: %d", event_fd);
+ userpool_delete(event_fd);
+ close(event_fd); /* epoll set fd also deleted automatically by this call as a spec */
+ if(event_fd == g_sdbd_sockfd)
+ g_sdbd_sockfd = -1;
+ return;
+ }
+
+ LOG("Something may be added in the data end, but it does not matter.");
+ LOG("sdcard data recv buffer: %s", r_databuf);
+
+ char token[] = "\n";
+ char tmpdata[recvd_size];
+ memcpy(tmpdata, r_databuf, recvd_size);
+
+ char* ret = NULL;
+ ret = strtok(tmpdata, token);
+ LOG("%s", ret);
+ int mount_param = atoi(ret);
+ int mount_status = 0;
+
+ switch(mount_param)
+ {
+ case 0: // umount
+ mount_status = umount_sdcard();
+ if(mount_status == 0)
+ send_guest_server(r_databuf);
+ break;
+ case 1: // mount
+ memset(SDpath, '\0', sizeof(SDpath));
+ ret = strtok(NULL, token);
+ strcpy(SDpath, ret);
+ LOG("sdcard path is %s", SDpath);
+
+ send_guest_server(r_databuf);
+ if(pthread_create(&tid[1], NULL, mount_sdcard, NULL) != 0)
+ LOG("pthread create fail!");
+ break;
+ case 2: // mount status
+ mount_status = is_mounted();
+
+ LXT_MESSAGE* mntData = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+ if(mntData == NULL){
+ break;
+ }
+ memset(mntData, 0, sizeof(LXT_MESSAGE));
+
+ mntData->length = strlen(SDpath); // length
+ mntData->group = 11; // sdcard
+
+ switch(mount_status)
+ {
+ case 0:
+ mntData->action = 2; // umounted status
+ send(g_sdcard_sockfd, (void*)mntData, sizeof(char) * HEADER_SIZE, 0);
+
+ LOG("SDpath is %s", SDpath);
+ send(g_sdcard_sockfd, SDpath, mntData->length, 0);
+ memset(SDpath, '\0', sizeof(SDpath));
+ sprintf(SDpath, "umounted");
+ break;
+ case 1:
+ mntData->action = 3; // mounted status
+ send(g_sdcard_sockfd, (void*)mntData, sizeof(char) * HEADER_SIZE, 0);
+
+ LOG("SDpath is %s", SDpath);
+ send(g_sdcard_sockfd, SDpath, mntData->length, 0);
+ break;
+ default:
+ break;
+ }
+ free(mntData);
+ break;
+ default:
+ LOG("unknown data %s", ret);
+ break;
+ }
+ }
else
{
LOG("Unknown packet: %s", tmpbuf);
exit(0);
}
+void setting_device()
+{
+ pthread_detach(pthread_self());
+
+ char* msg = 0;
+ LXT_MESSAGE* packet = (LXT_MESSAGE*)malloc(sizeof(LXT_MESSAGE));
+
+ switch(ActionID)
+ {
+ case BATTERY_LEVEL:
+ msg = get_battery_level((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting battery level");
+ }
+ break;
+ case BATTERY_CHARGER:
+ msg = get_battery_charger((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting battery charger state");
+ }
+ break;
+ case USB_STATUS:
+ msg = get_usb_status((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting usb status");
+ }
+ break;
+ case EARJACK_STATUS:
+ msg = get_earjack_status((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting earjack status");
+ }
+ break;
+ case RSSI_LEVEL:
+ msg = get_rssi_level((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting rssi level");
+ }
+ break;
+ case ACCEL_VALUE:
+ msg = get_acceleration_value((void*)packet);
+ if (msg == 0) {
+ LOG("falied getting acceleration value");
+ }
+ break;
+ case GYRO_VALUE:
+ msg = get_gyroscope_value((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting gyroscope value");
+ }
+ break;
+ case MAG_VALUE:
+ msg = get_magnetic_value((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting magnetic value");
+ }
+ break;
+ case LIGHT_VALUE:
+ msg = get_light_level((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting light level");
+ }
+ break;
+ case PROXI_VALUE:
+ msg = get_proximity_status((void*)packet);
+ if (msg == 0) {
+ LOG("failed getting proximity status");
+ }
+ break;
+ case MOTION_VALUE:
+ LOG("not support getting motion value");
+ break;
+ case LOCATION_STATUS:
+ msg = get_location_status((void*)packet);
+ if (msg == 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;
+ }
+
+ if (g_get_status_sockfd != -1) {
+ if (msg != 0) {
+ LOG("send data to injector");
+ } else {
+ LOG("send error message to injector");
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 0;
+ packet->group = STATUS;
+ packet->action = ActionID;
+ }
+ send(g_get_status_sockfd, (void*)packet, sizeof(char) * HEADER_SIZE, 0);
+ if (packet->length != 0) {
+ send(g_get_status_sockfd, msg, packet->length, 0);
+ }
+ }
+
+ if(msg != 0) {
+ free(msg);
+ }
+ free(packet);
+
+ pthread_exit((void *) 0);
+}
+
+// location event
+char command[512];
+char latitude[128];
+char longitude[128];
+void setting_location(char* databuf)
+{
+ char* s = strchr(databuf, ',');
+ memset(command, 0, 256);
+ if (s == NULL) { // SET MODE
+ int mode = atoi(databuf);
+ switch (mode) {
+ case 0: // STOP MODE
+ sprintf(command, "vconftool set -t int db/location/replay/ReplayMode 0 -f");
+ break;
+ case 1: // NMEA MODE (LOG MODE)
+ sprintf(command, "vconftool set -t int db/location/replay/ReplayMode 1 -f");
+ break;
+ case 2: // MANUAL MODE
+ sprintf(command, "vconftool set -t int db/location/replay/ReplayMode 2 -f");
+ break;
+ default:
+ LOG("error(%s) : stop replay mode", databuf);
+ sprintf(command, "vconftool set -t int db/location/replay/ReplayMode 0 -f");
+ break;
+ }
+ LOG("Location Command : %s", command);
+ system(command);
+ } else {
+ *s = '\0';
+ int mode = atoi(databuf);
+ if(mode == 1) { // NMEA MODE (LOG MODE)
+ sprintf(command, "vconftool set -t string db/location/replay/FileName \"%s\"", s+1);
+ LOG("%s", command);
+ system(command);
+ memset(command, 0, 256);
+ sprintf(command, "vconftool set -t int db/location/replay/ReplayMode 1 -f");
+ LOG("%s", command);
+ system(command);
+ } else if(mode == 2) {
+ memset(latitude, 0, 128);
+ memset(longitude, 0, 128);
+ char* t = strchr(s+1, ',');
+ *t = '\0';
+ strcpy(latitude, s+1);
+ strcpy(longitude, t+1);
+ //strcpy(longitude, s+1);
+ //strcpy(latitude, databuf);
+ // Latitude
+ sprintf(command, "vconftool set -t double db/location/replay/ManualLatitude %s -f", latitude);
+ LOG("%s", command);
+ system(command);
+
+ // Longitude
+ sprintf(command, "vconftool set -t double db/location/replay/ManualLongitude %s -f", longitude);
+ LOG("%s", command);
+ system(command);
+ }
+ }
+}
+
+//sdcard event
+void send_guest_server(char* databuf)
+{
+ char buf[32];
+ struct sockaddr_in si_other;
+ int s, slen=sizeof(si_other);
+ FILE* fd;
+ char fbuf[16];
+ int port;
+ fd = fopen("/opt/home/sdb_port.txt", "r");
+ LOG("sdb_port.txt fopen fd is %d", fd);
+ if(!fd)
+ {
+ LOG("fopen /opt/home/sdb_port.txt fail");
+ port = 3581;
+ }
+ else
+ {
+ fgets(fbuf, 16, fd);
+ fclose(fd);
+ port = atoi(fbuf) + 3;
+ }
+
+ if ((s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
+ {
+ LOG("socket error!");
+ return;
+ }
+
+ memset((char *) &si_other, 0, sizeof(si_other));
+ si_other.sin_family = AF_INET;
+ si_other.sin_port = htons(port);
+ if (inet_aton(SRV_IP, &si_other.sin_addr)==0) {
+ fprintf(stderr, "inet_aton() failed\n");
+ }
+
+ memset(buf, '\0', sizeof(buf));
+ sprintf(buf, "4\n%s", databuf);
+ LOG("sendGuestServer msg: %s", buf);
+ if(sendto(s, buf, sizeof(buf), 0, (struct sockaddr*)&si_other, slen) == -1)
+ {
+ LOG("sendto error!");
+ }
+
+ close(s);
+}
+
int main( int argc , char *argv[])
{
if(log_print == 1)
--- /dev/null
+/*
+ * emulator-daemon
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact:
+ * SooYoung Ha <yoosah.ha@samsnung.com>
+ * 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"
+
+
+char* message;
+char* get_usb_status(void* p)
+{
+ FILE* fd = fopen("/sys/devices/platform/jack/usb_online", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int status = 0;
+ fscanf(fd, "%d", &status);
+ fclose(fd);
+
+ // int to byte
+ message = (char*)malloc(5);
+ message[3] = (char) (status & 0xff);
+ message[2] = (char) (status >> 8 & 0xff);
+ message[1] = (char) (status >> 16 & 0xff);
+ message[0] = (char) (status >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = USB_STATUS;
+
+ return message;
+}
+
+char* get_earjack_status(void* p)
+{
+ FILE* fd = fopen("/sys/devices/platform/jack/earjack_online", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int status = 0;
+ fscanf(fd, "%d", &status);
+ fclose(fd);
+
+ // int to byte
+ message = (char*)malloc(5);
+ message[3] = (char) (status & 0xff);
+ message[2] = (char) (status >> 8 & 0xff);
+ message[1] = (char) (status >> 16 & 0xff);
+ message[0] = (char) (status >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = EARJACK_STATUS;
+
+ return message;
+}
+
+char* get_rssi_level(void* p)
+{
+ int level;
+ int ret = vconf_get_int("memory/telephony/rssi", &level);
+ if (ret != 0) {
+ return 0;
+ }
+
+ // int to byte
+ message = (char*)malloc(5);
+ message[3] = (char) (level & 0xff);
+ message[2] = (char) (level >> 8 & 0xff);
+ message[1] = (char) (level >> 16 & 0xff);
+ message[0] = (char) (level >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = RSSI_LEVEL;
+
+ return message;
+}
+
+char* get_battery_level(void* p)
+{
+ FILE* fd = fopen("/sys/class/power_supply/battery/capacity", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int level = 0;
+ fscanf(fd, "%d", &level);
+ fclose(fd);
+
+ // int to byte
+ message = (char*)malloc(5);
+ message[3] = (char) (level & 0xff);
+ message[2] = (char) (level >> 8 & 0xff);
+ message[1] = (char) (level >> 16 & 0xff);
+ message[0] = (char) (level >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = BATTERY_LEVEL;
+
+ return message;
+}
+
+char* get_battery_charger(void* p)
+{
+ FILE* fd = fopen("/sys/class/power_supply/battery/charge_now", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int charge = 0;
+ fscanf(fd, "%d", &charge);
+ fclose(fd);
+ // int to byte
+ message = (char*)malloc(5);
+
+ message[3] = (char) (charge & 0xff);
+ message[2] = (char) (charge >> 8 & 0xff);
+ message[1] = (char) (charge >> 16 & 0xff);
+ message[0] = (char) (charge >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = BATTERY_CHARGER;
+
+ return message;
+}
+
+char* get_proximity_status(void* p)
+{
+ FILE* fd = fopen("/opt/sensor/proxi/vo", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int status = 0;
+ fscanf(fd, "%d", &status);
+ fclose(fd);
+ // int to byte
+ message = (char*)malloc(5);
+
+ message[3] = (char) (status & 0xff);
+ message[2] = (char) (status >> 8 & 0xff);
+ message[1] = (char) (status >> 16 & 0xff);
+ message[0] = (char) (status >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = PROXI_VALUE;
+
+ return message;
+}
+
+char* get_light_level(void* p)
+{
+ FILE* fd = fopen("/opt/sensor/light/adc", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ int level = 0;
+ fscanf(fd, "%d", &level);
+ fclose(fd);
+
+ // int to byte
+ message = (char*)malloc(5);
+ message[3] = (char) (level & 0xff);
+ message[2] = (char) (level >> 8 & 0xff);
+ message[1] = (char) (level >> 16 & 0xff);
+ message[0] = (char) (level >> 24 & 0xff);
+ message[4] = '\0';
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = 4;
+ packet->group = STATUS;
+ packet->action = LIGHT_VALUE;
+
+ return message;
+}
+
+char* get_acceleration_value(void* p)
+{
+ FILE* fd = fopen("/opt/sensor/accel/xyz", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ message = (char*)malloc(128);
+ //fscanf(fd, "%d, %d, %d", message);
+ fgets(message, 128, fd);
+ fclose(fd);
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = ACCEL_VALUE;
+
+ return message;
+}
+
+char* get_gyroscope_value(void* p)
+{
+ int x;
+ int y;
+ int z;
+ FILE* fd = fopen("/opt/sensor/gyro/gyro_x_raw", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ fscanf(fd, "%d", &x);
+ fclose(fd);
+
+ fd = fopen("/opt/sensor/gyro/gyro_y_raw", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ fscanf(fd, "%d", &y);
+ fclose(fd);
+
+ fd = fopen("/opt/sensor/gyro/gyro_z_raw", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+ fscanf(fd, "%d", &z);
+ fclose(fd);
+
+ message = (char*)malloc(128);
+ memset(message, 0, 128);
+ int ret = sprintf(message, "%d, %d, %d", x, y, z);
+ if (ret < 0) {
+ free(message);
+ return 0;
+ }
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = GYRO_VALUE;
+
+ return message;
+}
+
+char* get_magnetic_value(void* p)
+{
+ FILE* fd = fopen("/opt/sensor/geo/tesla", "r");
+ if(!fd)
+ {
+ return 0;
+ }
+
+ message = (char*)malloc(128);
+ fgets(message, 128, fd);
+ fclose(fd);
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = MAG_VALUE;
+ return message;
+}
+
+char* get_location_status(void* p)
+{
+ int mode;
+ int ret = vconf_get_int("db/location/replay/ReplayMode", &mode);
+ if (ret != 0) {
+ return 0;
+ }
+
+ if (mode == 0) { // STOP
+ message = (char*)malloc(5);
+ ret = sprintf(message, "%d", mode);
+ if (ret < 0) {
+ free(message);
+ return 0;
+ }
+ } else if (mode == 1) { // NMEA MODE(LOG MODE)
+ //char* temp = (char*)malloc(128);
+ char* temp = 0;
+ temp = vconf_get_str("db/location/replay/FileName");
+ if (temp == 0) {
+ //free(temp);
+ return 0;
+ }
+
+ message = (char*)malloc(256);
+ ret = sprintf(message, "%d,%s", mode, temp);
+ if (ret < 0) {
+ free(message);
+ return 0;
+ }
+ } else if (mode == 2) { // MANUAL MODE
+ double latitude;
+ double logitude;
+ ret = vconf_get_dbl("db/location/replay/ManualLatitude", &latitude);
+ if (ret != 0) {
+ return 0;
+ }
+ ret = vconf_get_dbl("db/location/replay/ManualLongitude", &logitude);
+ if (ret != 0) {
+ return 0;
+ }
+ message = (char*)malloc(128);
+ ret = sprintf(message, "%d,%f,%f", mode, latitude, logitude);
+ if (ret < 0) {
+ free(message);
+ return 0;
+ }
+ }
+
+ LXT_MESSAGE* packet = p;
+ memset(packet, 0, sizeof(LXT_MESSAGE));
+ packet->length = strlen(message);
+ packet->group = STATUS;
+ packet->action = LOCATION_STATUS;
+
+ 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;
+}