static GAtChat *open_device(struct ofono_modem *modem, const char *key, char *debug) { const char *device; GAtSyntax *syntax; GIOChannel *channel; GAtChat *chat; device = ofono_modem_get_string(modem, key); if (device == NULL) return NULL; DBG("%s %s", key, device); channel = g_at_tty_open(device, NULL); if (channel == NULL) return NULL; syntax = g_at_syntax_new_gsmv1(); chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (chat == NULL) return NULL; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, telit_debug, debug); return chat; }
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; }
static int cinterion_enable(struct ofono_modem *modem) { GAtChat *chat; GIOChannel *channel; GAtSyntax *syntax; GHashTable *options; const char *device; DBG("%p", modem); options = g_hash_table_new(g_str_hash, g_str_equal); if (options == NULL) return -ENOMEM; device = ofono_modem_get_string(modem, "Device"); if (device == NULL) return -EINVAL; g_hash_table_insert(options, "Baud", "115200"); g_hash_table_insert(options, "StopBits", "1"); g_hash_table_insert(options, "DataBits", "8"); g_hash_table_insert(options, "Parity", "none"); g_hash_table_insert(options, "XonXoff", "off"); g_hash_table_insert(options, "RtsCts", "on"); g_hash_table_insert(options, "Local", "on"); g_hash_table_insert(options, "Read", "on"); channel = g_at_tty_open(device, options); g_hash_table_destroy(options); if (channel == NULL) return -EIO; /* * (Cinterion plugin is based on tc65 plugin. Comment left in but may * not be applicable in the general case) * * TC65 works almost as the 27.007 says. But for example after * AT+CRSM the modem replies with the data in the queried EF and * writes three pairs of <CR><LF> after the data and before OK. */ syntax = g_at_syntax_new_gsm_permissive(); chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (chat == NULL) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, cinterion_debug, ""); ofono_modem_set_data(modem, chat); return 0; }
static int ifx_enable(struct ofono_modem *modem) { struct ifx_data *data = ofono_modem_get_data(modem); const char *device, *ldisc; GAtSyntax *syntax; GAtChat *chat; DBG("%p", modem); device = ofono_modem_get_string(modem, "Device"); if (device == NULL) return -EINVAL; DBG("%s", device); ldisc = ofono_modem_get_string(modem, "LineDiscipline"); if (ldisc != NULL) { data->mux_ldisc = atoi(ldisc); ofono_info("Using multiplexer line discipline %d", data->mux_ldisc); } data->device = g_at_tty_open(device, NULL); if (data->device == NULL) return -EIO; syntax = g_at_syntax_new_gsmv1(); chat = g_at_chat_new(data->device, syntax); g_at_syntax_unref(syntax); if (chat == NULL) { g_io_channel_unref(data->device); return -EIO; } if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, ifx_debug, "Master: "); g_at_chat_send(chat, "ATE0 +CMEE=1", NULL, NULL, NULL, NULL); /* Enable multiplexer */ data->frame_size = 1509; g_at_chat_send(chat, "AT+CMUX=0,0,,1509,10,3,30,,", NULL, mux_setup_cb, modem, NULL); data->mux_init_timeout = g_timeout_add_seconds(5, mux_timeout_cb, modem); data->dlcs[AUX_DLC] = chat; return -EINPROGRESS; }
static int open_serial(void) { GAtSyntax *syntax; GIOChannel *channel; channel = g_at_tty_open(option_control, NULL); if (channel == NULL) return -EIO; syntax = g_at_syntax_new_gsm_permissive(); control = g_at_chat_new(channel, syntax); g_io_channel_unref(channel); g_at_syntax_unref(syntax); if (control == NULL) return -EIO; if (option_modem == NULL) { g_at_chat_ref(control); modem = control; g_at_chat_set_debug(control, gsmdial_debug, ""); } else { g_at_chat_set_debug(control, gsmdial_debug, "Control"); channel = g_at_tty_open(option_modem, NULL); if (channel == NULL) return -EIO; syntax = g_at_syntax_new_gsm_permissive(); modem = g_at_chat_new(channel, syntax); g_io_channel_unref(channel); g_at_syntax_unref(syntax); if (modem == NULL) return -EIO; g_at_chat_set_debug(modem, gsmdial_debug, "Modem"); } return 0; }
static gboolean dlc_ready_check(gpointer user_data) { struct ofono_modem *modem = user_data; struct ifx_data *data = ofono_modem_get_data(modem); struct stat st; int i; DBG(""); data->dlc_poll_count++; if (stat(dlc_nodes[AUX_DLC], &st) < 0) { /* only possible error is ENOENT */ if (data->dlc_poll_count > 6) goto error; return TRUE; } for (i = 0; i < NUM_DLC; i++) { GIOChannel *channel = g_at_tty_open(dlc_nodes[i], NULL); data->dlcs[i] = create_chat(channel, modem, dlc_prefixes[i]); if (data->dlcs[i] == NULL) { ofono_error("Failed to open %s", dlc_nodes[i]); goto error; } } data->dlc_poll_source = 0; /* iterate through mainloop */ data->dlc_init_source = g_timeout_add_seconds(0, dlc_setup, modem); return FALSE; error: data->dlc_poll_source = 0; shutdown_device(data); ofono_modem_set_powered(modem, FALSE); return FALSE; }
static GAtChat *open_device(struct ofono_modem *modem, const char *key, char *debug) { const char *device; GAtSyntax *syntax; GIOChannel *channel; GAtChat *chat; GHashTable *options; device = ofono_modem_get_string(modem, key); if (device == NULL) return NULL; DBG("%s %s", key, device); options = g_hash_table_new(g_str_hash, g_str_equal); if (options == NULL) return NULL; g_hash_table_insert(options, "Baud", "115200"); channel = g_at_tty_open(device, options); g_hash_table_destroy(options); if (channel == NULL) return NULL; syntax = g_at_syntax_new_gsmv1(); chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (chat == NULL) return NULL; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, telit_debug, debug); return chat; }
static int atgen_enable(struct ofono_modem *modem) { GAtChat *chat; GIOChannel *channel; GAtSyntax *syntax; const char *device; const char *value; GHashTable *options; int i; DBG("%p", modem); device = ofono_modem_get_string(modem, "Device"); if (!device) return -EINVAL; options = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); if (!options) return -ENOMEM; for (i = 0; tty_opts[i]; i++) { value = ofono_modem_get_string(modem, tty_opts[i]); if (value == NULL) continue; g_hash_table_insert(options, g_strdup(tty_opts[i]), g_strdup(value)); } channel = g_at_tty_open(device, options); g_hash_table_destroy(options); if (!channel) { return -EIO; } value = ofono_modem_get_string(modem, "GsmSyntax"); if (value) { if (g_str_equal(value, "V1")) syntax = g_at_syntax_new_gsmv1(); else if (g_str_equal(value, "Permissive")) syntax = g_at_syntax_new_gsm_permissive(); else return -EINVAL; } else { syntax = g_at_syntax_new_gsmv1(); } chat = g_at_chat_new(channel, syntax); g_at_syntax_unref(syntax); g_io_channel_unref(channel); if (!chat) return -ENOMEM; if (getenv("OFONO_AT_DEBUG")) g_at_chat_set_debug(chat, atgen_debug, NULL); ofono_modem_set_data(modem, chat); return 0; }