ASensorEventQueue* sensorEventQueue;
int SensorSamplingRate;
const ASensor* accSensor;
static int get_sensor_events(int fd, int events, void* data) {
ASensorEvent event;
printf("Hello\n");
LOGW("Hi0!");
while (ASensorEventQueue_getEvents(sensorEventQueue, &event, 1) > 0){
if(event.type == ASENSOR_TYPE_ACCELEROMETER) {
LOGW("Hi!");
}
LOGW("Hi2!");
}
return 1;
}
void MySensorValue(){
ASensorEvent event;
int events, ident;
ASensorManager* sensorManager;
void* sensor_data = malloc(1000);
ALooper* looper = ALooper_forThread();
if(looper == NULL)
{
looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
}
sensorManager = ASensorManager_getInstance();
accSensor = ASensorManager_getDefaultSensor(sensorManager,ASENSOR_TYPE_ACCELEROMETER);
sensorEventQueue = ASensorManager_createEventQueue(sensorManager,looper, 3, get_sensor_events, sensor_data);
ASensorEventQueue_enableSensor(sensorEventQueue, accSensor);
//ASensorEventQueue_setEventRate(sensorEventQueue, accSensor, (1000L/200)*1000);
LOGI("sensor() - START ");
}
int main(){
MySensorValue();
int c=0;
while(1){
sleep(1);
LOGI("c=%d",++c);
};
}