I am trying to use the android hardware abstraction layer to print NMEA messages coming from my phone's gps device(qualcomm I believe), not an external device. All examples of using the Android native code seem to be for using an external gps device. In the case of android qemu, the emulator points to a file descriptor that gets emulated gps information, which is not what I'm looking for either. I used libloc_api to create a GpsInterface instance, but I'm not sure how I use the callback functions in order to get NMEA messages. Here is a piece of code I used to get my gps interface:
#include "hardware/gps.h"
#include "hardware/hardware.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
static const GpsInterface* sGpsInterface = NULL;
int main() {
int err = 0;
size_t gps_size = 0;
hw_module_t* module;
err = hw_get_module(GPS_HARDWARE_MODULE_ID, (hw_module_t const**)&module);
if (err == 0) {
hw_device_t* device;
err = module->methods->open(module, GPS_HARDWARE_MODULE_ID, &device);
struct gps_device_t* gps_device = (struct gps_device_t *)device;
sGpsInterface = gps_device->get_gps_interface(gps_device);
}
if (!sGpsInterface )
printf("No Interface!\n");
mod = module->name;
printf("module name = %s\n", mod);
I have to use native code to get the GPS, so I'm not looking for an SDK answer, unless there is an app that creates a device that I can read the NMEA stream from (ex. /dev/ttyGPS).
Thanks for any help.