static int enable_data_stream(struct ofono_location_reporting *lr) { struct ofono_modem *modem; const char *gps_dev; GHashTable *options; GIOChannel *channel; int fd; modem = ofono_location_reporting_get_modem(lr); gps_dev = ofono_modem_get_string(modem, "GPS"); options = g_hash_table_new(g_str_hash, g_str_equal); if (options == NULL) return -1; g_hash_table_insert(options, "Baud", "115200"); channel = g_at_tty_open(gps_dev, options); g_hash_table_destroy(options); if (channel == NULL) return -1; fd = g_io_channel_unix_get_fd(channel); g_io_channel_set_close_on_unref(channel, FALSE); g_io_channel_unref(channel); return fd; }
static int enable_data_stream(struct ofono_location_reporting *lr) { struct ofono_modem *modem; const char *gps_dev; GIOChannel *channel; GIOStatus status; gsize written; int fd; modem = ofono_location_reporting_get_modem(lr); gps_dev = ofono_modem_get_string(modem, "GPSDevice"); channel = g_at_tty_open(gps_dev, NULL); if (channel == NULL) return -1; fd = g_io_channel_unix_get_fd(channel); status = g_io_channel_write_chars(channel, "AT*E2GPSNPD\r\n", -1, &written, NULL); g_io_channel_set_close_on_unref(channel, FALSE); g_io_channel_unref(channel); if (status != G_IO_STATUS_NORMAL || written != 13) { close(fd); return -1; } return fd; }