2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "MsgCppTypes.h"
19 #include "MsgGconfWrapper.h"
20 #include "MsgHelper.h"
24 /*==================================================================================================
26 ==================================================================================================*/
27 int sensorHandler = -1;
29 msg_sensor_cb cbFunction = NULL;
31 /*==================================================================================================
32 FUNCTION IMPLEMENTATION
33 ==================================================================================================*/
35 void MsgSensorCB(unsigned int event_type, sensor_event_data_t *event_data , void *data)
39 my_event_data = (int *)(event_data->event_data);
41 if (event_type == MOTION_ENGINE_EVENT_TOP_TO_BOTTOM)
42 if(*my_event_data == MOTION_ENGIEN_TOP_TO_BOTTOM_DETECTION) {
43 MSG_DEBUG("top to bottom event detected.");
44 if(MsgSettingGetInt(VCONFKEY_SETAPPL_MOTION_ACTIVATION))
45 if(MsgSettingGetInt(VCONFKEY_SETAPPL_USE_TURN_OVER))
51 msg_error_t MsgSensorConnect()
53 sensorHandler = sf_connect(MOTION_SENSOR);
54 if (sensorHandler < 0) {
55 MSG_DEBUG("sensor attach fail.");
56 return MSG_ERR_UNKNOWN;
63 void MsgSensorDisconnect()
65 if(cbFunction != NULL)
68 if (sensorHandler < 0)
73 sf_stop(sensorHandler);
77 MSG_FATAL("sf_stop error[%d]", exception);
79 sf_disconnect(sensorHandler);
83 msg_error_t MsgRegSensorCB(msg_sensor_cb cb)
85 int resultCondition = -1;
87 if (sensorHandler < 0) {
88 MSG_DEBUG("Not connected to sensor FW.");
89 return MSG_ERR_UNKNOWN;
96 MSG_DEBUG("cb is NULL.");
97 return MSG_ERR_UNKNOWN;
100 resultCondition = sf_register_event(sensorHandler, MOTION_ENGINE_EVENT_TOP_TO_BOTTOM , NULL , MsgSensorCB,NULL);
101 if (resultCondition < 0) {
102 MSG_DEBUG("SLP_sensor_register_cb fail to gather data.");
103 return MSG_ERR_UNKNOWN;
106 MSG_DEBUG("Start SF.");
107 resultCondition = sf_start(sensorHandler, 0);
108 if (resultCondition < 0) {
109 MSG_DEBUG("SLP_sensor_start fail.");
110 return MSG_ERR_UNKNOWN;