mirror of git://git.sysmocom.de/ofono
WIP: Wavecom SL8082 support
This commit is contained in:
parent
abb72e8999
commit
a168638337
|
@ -47,9 +47,13 @@
|
|||
#include <ofono/sms.h>
|
||||
#include <ofono/ussd.h>
|
||||
#include <ofono/voicecall.h>
|
||||
#include <ofono.h>
|
||||
|
||||
#include <drivers/atmodem/vendor.h>
|
||||
|
||||
static const char *cfun_prefix[] = { "+CFUN:", NULL };
|
||||
static const char *wind_prefix[] = { "+WIND:", NULL };
|
||||
static const char *none_prefix[] = { NULL };
|
||||
|
||||
static int wavecom_probe(struct ofono_modem *modem)
|
||||
{
|
||||
|
@ -67,6 +71,111 @@ static void wavecom_debug(const char *str, void *user_data)
|
|||
ofono_info("%s%s", prefix, str);
|
||||
}
|
||||
|
||||
static void wind_notify(GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
struct ofono_sim *sim = __ofono_atom_find(OFONO_ATOM_TYPE_SIM, modem);
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
GAtResultIter iter;
|
||||
int val;
|
||||
const char *model;
|
||||
enum ofono_vendor vendor = 0;
|
||||
|
||||
DBG("%p", modem);
|
||||
|
||||
model = ofono_modem_get_string(modem, "Model");
|
||||
if (model && strcmp(model, "Q2XXX") == 0)
|
||||
vendor = OFONO_VENDOR_WAVECOM_Q2XXX;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (!g_at_result_iter_next(&iter, "+WIND:"))
|
||||
return;
|
||||
|
||||
if (!g_at_result_iter_next_number(&iter, &val))
|
||||
return;
|
||||
|
||||
switch (val) {
|
||||
case 3: /* ready to process AT commands */
|
||||
ofono_modem_set_powered(modem, TRUE);
|
||||
break;
|
||||
case 1: /* sim inserted */
|
||||
break;
|
||||
case 16: /* SMS and SMS-CB services initialized */
|
||||
ofono_sms_create(modem, vendor, "atmodem", chat);
|
||||
break;
|
||||
case 7: /* service available for emergency call */
|
||||
ofono_voicecall_create(modem, 0, "atmodem", chat);
|
||||
ofono_ussd_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_forwarding_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_settings_create(modem, 0, "atmodem", chat);
|
||||
ofono_netreg_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_meter_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_barring_create(modem, 0, "atmodem", chat);
|
||||
break;
|
||||
case 8: /* network is lost */
|
||||
case 10: /* reload status of SIM phonebook */
|
||||
sim = ofono_sim_create(modem, vendor, "atmodem", chat);
|
||||
ofono_sim_inserted_notify(sim, TRUE);
|
||||
ofono_phonebook_create(modem, 0, "atmodem", chat);
|
||||
break;
|
||||
case 11: /* checksum of SIM phoenbook */
|
||||
case 13: /* rack has been detected closed */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("ok %d", ok);
|
||||
|
||||
if (!ok) {
|
||||
g_at_chat_unref(chat);
|
||||
ofono_modem_set_powered(modem, FALSE);
|
||||
return;
|
||||
}
|
||||
|
||||
ofono_modem_set_powered(modem, TRUE);
|
||||
}
|
||||
|
||||
static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
GAtResultIter iter;
|
||||
int status;
|
||||
|
||||
DBG("ok %d", ok);
|
||||
|
||||
if (!ok)
|
||||
return;
|
||||
|
||||
g_at_result_iter_init(&iter, result);
|
||||
|
||||
if (g_at_result_iter_next(&iter, "+CFUN:") == FALSE)
|
||||
return;
|
||||
|
||||
g_at_result_iter_next_number(&iter, &status);
|
||||
|
||||
if (status != 1) {
|
||||
g_at_chat_send(chat, "AT+CFUN=1", none_prefix,
|
||||
cfun_enable, modem, NULL);
|
||||
return;
|
||||
} else
|
||||
ofono_modem_set_powered(modem, TRUE);
|
||||
}
|
||||
|
||||
static void wind_set(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("");
|
||||
}
|
||||
|
||||
static int wavecom_enable(struct ofono_modem *modem)
|
||||
{
|
||||
GAtChat *chat;
|
||||
|
@ -111,6 +220,9 @@ static int wavecom_enable(struct ofono_modem *modem)
|
|||
if (chat == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
g_at_chat_register(chat, "+WIND", wind_notify,
|
||||
FALSE, modem, NULL);
|
||||
|
||||
g_at_chat_add_terminator(chat, "+CPIN:", 6, TRUE);
|
||||
|
||||
if (getenv("OFONO_AT_DEBUG"))
|
||||
|
@ -118,7 +230,27 @@ static int wavecom_enable(struct ofono_modem *modem)
|
|||
|
||||
ofono_modem_set_data(modem, chat);
|
||||
|
||||
return 0;
|
||||
g_at_chat_send(chat, "AT+WIND=32767", wind_prefix,
|
||||
wind_set, modem, NULL);
|
||||
|
||||
g_at_chat_send(chat, "AT+CFUN?", cfun_prefix,
|
||||
cfun_query, modem, NULL);
|
||||
|
||||
return -EINPROGRESS;
|
||||
}
|
||||
|
||||
static void cfun_disable(gboolean ok, GAtResult *result, gpointer user_data)
|
||||
{
|
||||
struct ofono_modem *modem = user_data;
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
|
||||
DBG("");
|
||||
|
||||
g_at_chat_unref(chat);
|
||||
ofono_modem_set_data(modem, NULL);
|
||||
|
||||
if (ok)
|
||||
ofono_modem_set_powered(modem, FALSE);
|
||||
}
|
||||
|
||||
static int wavecom_disable(struct ofono_modem *modem)
|
||||
|
@ -127,9 +259,11 @@ static int wavecom_disable(struct ofono_modem *modem)
|
|||
|
||||
DBG("%p", modem);
|
||||
|
||||
ofono_modem_set_data(modem, NULL);
|
||||
g_at_chat_cancel_all(chat);
|
||||
g_at_chat_unregister_all(chat);
|
||||
|
||||
g_at_chat_unref(chat);
|
||||
g_at_chat_send(chat, "AT+CFUN=0", cfun_prefix,
|
||||
cfun_disable, modem, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -137,46 +271,19 @@ static int wavecom_disable(struct ofono_modem *modem)
|
|||
static void wavecom_pre_sim(struct ofono_modem *modem)
|
||||
{
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
const char *model;
|
||||
enum ofono_vendor vendor = 0;
|
||||
struct ofono_sim *sim;
|
||||
|
||||
DBG("%p", modem);
|
||||
|
||||
model = ofono_modem_get_string(modem, "Model");
|
||||
if (model && strcmp(model, "Q2XXX") == 0)
|
||||
vendor = OFONO_VENDOR_WAVECOM_Q2XXX;
|
||||
|
||||
ofono_devinfo_create(modem, 0, "atmodem", chat);
|
||||
sim = ofono_sim_create(modem, vendor, "atmodem", chat);
|
||||
ofono_voicecall_create(modem, 0, "atmodem", chat);
|
||||
|
||||
if (vendor == OFONO_VENDOR_WAVECOM_Q2XXX)
|
||||
ofono_sim_inserted_notify(sim, TRUE);
|
||||
}
|
||||
|
||||
static void wavecom_post_sim(struct ofono_modem *modem)
|
||||
{
|
||||
GAtChat *chat = ofono_modem_get_data(modem);
|
||||
struct ofono_message_waiting *mw;
|
||||
const char *model;
|
||||
enum ofono_vendor vendor = 0;
|
||||
|
||||
DBG("%p", modem);
|
||||
|
||||
model = ofono_modem_get_string(modem, "Model");
|
||||
if (model && strcmp(model, "Q2XXX") == 0)
|
||||
vendor = OFONO_VENDOR_WAVECOM_Q2XXX;
|
||||
|
||||
ofono_ussd_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_forwarding_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_settings_create(modem, 0, "atmodem", chat);
|
||||
ofono_netreg_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_meter_create(modem, 0, "atmodem", chat);
|
||||
ofono_call_barring_create(modem, 0, "atmodem", chat);
|
||||
ofono_sms_create(modem, vendor, "atmodem", chat);
|
||||
ofono_phonebook_create(modem, 0, "atmodem", chat);
|
||||
|
||||
mw = ofono_message_waiting_create(modem);
|
||||
if (mw)
|
||||
ofono_message_waiting_register(mw);
|
||||
|
|
|
@ -4,6 +4,7 @@ from gi.repository import GLib
|
|||
|
||||
import dbus
|
||||
import dbus.mainloop.glib
|
||||
import sys
|
||||
|
||||
def property_changed(name, value):
|
||||
print("Modem property %s changed to %s" % (name, value))
|
||||
|
@ -17,7 +18,13 @@ if __name__ == "__main__":
|
|||
'org.ofono.Manager')
|
||||
|
||||
modems = manager.GetModems()
|
||||
modem = dbus.Interface(bus.get_object('org.ofono', modems[0][0]),
|
||||
|
||||
if len(sys.argv) == 2:
|
||||
modem_path = sys.argv[1]
|
||||
else:
|
||||
modem_path = modems[0][0]
|
||||
|
||||
modem = dbus.Interface(bus.get_object('org.ofono', modem_path),
|
||||
'org.ofono.Modem')
|
||||
|
||||
modem.connect_to_signal("PropertyChanged", property_changed)
|
||||
|
|
Loading…
Reference in New Issue