4 * Copyright (c) 2000 - 2014 Samsung Electronics Co., Ltd. All rights reserved
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 #include "MsgCppTypes.h"
22 #include "MsgGconfWrapper.h"
23 #include "MsgHelper.h"
27 /*==================================================================================================
29 ==================================================================================================*/
30 int sensorHandler = -1;
32 msg_sensor_cb cbFunction = NULL;
34 /*==================================================================================================
35 FUNCTION IMPLEMENTATION
36 ==================================================================================================*/
38 void MsgSensorCB(unsigned int event_type, sensor_event_data_t *event_data , void *data)
42 my_event_data = (int *)(event_data->event_data);
44 if (event_type == MOTION_ENGINE_EVENT_TOP_TO_BOTTOM)
45 if(*my_event_data == MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION) {
46 MSG_DEBUG("top to bottom event detected.");
47 if(MsgSettingGetInt(VCONFKEY_SETAPPL_MOTION_ACTIVATION))
48 if(MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER))
54 msg_error_t MsgSensorConnect()
56 sensorHandler = sf_connect(MOTION_SENSOR);
57 if (sensorHandler < 0) {
58 MSG_DEBUG("sensor attach fail.");
59 return MSG_ERR_UNKNOWN;
66 void MsgSensorDisconnect()
68 if(cbFunction != NULL)
71 if (sensorHandler < 0)
76 sf_stop(sensorHandler);
80 MSG_FATAL("sf_stop error[%d]", exception);
82 sf_disconnect(sensorHandler);
86 msg_error_t MsgRegSensorCB(msg_sensor_cb cb)
88 int resultCondition = -1;
90 if (sensorHandler < 0) {
91 MSG_DEBUG("Not connected to sensor FW.");
92 return MSG_ERR_UNKNOWN;
99 MSG_DEBUG("cb is NULL.");
100 return MSG_ERR_UNKNOWN;
103 resultCondition = sf_register_event(sensorHandler, MOTION_ENGINE_EVENT_TOP_TO_BOTTOM , NULL , MsgSensorCB,NULL);
104 if (resultCondition < 0) {
105 MSG_DEBUG("SLP_sensor_register_cb fail to gather data.");
106 return MSG_ERR_UNKNOWN;
109 MSG_DEBUG("Start SF.");
110 resultCondition = sf_start(sensorHandler, 0);
111 if (resultCondition < 0) {
112 MSG_DEBUG("SLP_sensor_start fail.");
113 return MSG_ERR_UNKNOWN;