__geoStateMap[fenceId] = state;
}
-static const char* get_state_string(geofence_state_e state)
-{
- switch (state) {
- case GEOFENCE_STATE_IN:
- return PLACE_GEOFENCE_IN;
- case GEOFENCE_STATE_OUT:
- return PLACE_GEOFENCE_OUT;
- case GEOFENCE_STATE_UNCERTAIN:
- return PLACE_GEOFENCE_UNCERTAIN;
- default:
- return PLACE_GEOFENCE_UNCERTAIN;
- }
-}
-
void ctx::GeofenceMonitorHandle::__emitStateChange()
{
- geofence_state_e current_state = GEOFENCE_STATE_UNCERTAIN;
+ geofence_state_e currentState = GEOFENCE_STATE_UNCERTAIN;
int outCount = 0;
for (auto it = __geoStateMap.begin(); it != __geoStateMap.end(); ++it) {
if (it->second == GEOFENCE_STATE_IN) {
- current_state = GEOFENCE_STATE_IN;
+ currentState = GEOFENCE_STATE_IN;
break;
} else if (it->second == GEOFENCE_STATE_OUT) {
- ++ outCount;
+ ++outCount;
}
}
- if (current_state != GEOFENCE_STATE_IN && outCount > 0) {
- current_state = GEOFENCE_STATE_OUT;
+ if (currentState != GEOFENCE_STATE_IN && outCount > 0) {
+ currentState = GEOFENCE_STATE_OUT;
}
- if (current_state == __prevState) {
+ if (currentState == __prevState) {
return;
}
- __prevState = current_state;
+ __prevState = currentState;
Json option;
option.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId);
Json data;
data.set(NULL, PLACE_GEOFENCE_PLACE_ID, __placeId);
- data.set(NULL, PLACE_GEOFENCE_EVENT, get_state_string(current_state));
+ data.set(NULL, PLACE_GEOFENCE_EVENT, __getStateString(currentState));
context_manager::publish(PLACE_SUBJ_GEOFENCE, option, ERR_NONE, data);
}
+const char* ctx::GeofenceMonitorHandle::__getStateString(geofence_state_e state)
+{
+ switch (state) {
+ case GEOFENCE_STATE_IN:
+ return PLACE_GEOFENCE_IN;
+ case GEOFENCE_STATE_OUT:
+ return PLACE_GEOFENCE_OUT;
+ case GEOFENCE_STATE_UNCERTAIN:
+ return PLACE_GEOFENCE_UNCERTAIN;
+ default:
+ return PLACE_GEOFENCE_UNCERTAIN;
+ }
+}
+
bool ctx::GeofenceMonitorHandle::__fenceListCb(int geofenceId, geofence_h fence, int fenceIndex, int fenceCount, void* userData)
{
_D("FenceID: %d, Index: %d, Count: %d", geofenceId, fenceIndex, fenceCount);
void __updateFence(int fenceId, geofence_manage_e manage);
void __updateState(int fenceId, geofence_state_e state);
+ static const char* __getStateString(geofence_state_e state);
+
static bool __fenceListCb(int geofenceId, geofence_h fence, int fenceIndex, int fenceCount, void* userData);
static void __fenceEventCb(int placeId, int geofenceId, geofence_manager_error_e error, geofence_manage_e manage, void* userData);
static void __fenceStateCb(int geofenceId, geofence_state_e state, void* userData);