plugin: Add plugin for Linktop LW27x data cards
PATCH 1/3 plugin: Add plugin for Linktop LW27x data cards
--- Makefile.am | 3 + plugins/linktop.c | 357 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 360 insertions(+), 0 deletions(-) create mode 100644 plugins/linktop.c
Makefile.am +3 -0
@@ -314,6 +314,9 @@ builtin_sources += plugins/nokia.c builtin_modules += nokiacdma builtin_sources += plugins/nokiacdma.c +builtin_modules += linktop +builtin_sources += plugins/linktop.c + if BLUETOOTH builtin_modules += bluetooth builtin_sources += plugins/bluetooth.c plugins/bluetooth.h
plugins/linktop.c new file +357 -0
357 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 2/3 udev: Handle Linktop data card
--- plugins/udev.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
plugins/udev.c +32 -0
@@ -552,6 +552,36 @@ static void add_nokiacdma(struct ofono_modem *modem,ofono_modem_register (modem); } +static void add_linktop (struct ofono_modem *modem, +struct udev_device *udev_device) +{ +const char *devnode, *intfnum; +struct udev_device *parent; +int registered; + +DBG ("modem %p" , modem); + + registered =ofono_modem_get_integer (modem,"Registered" ); +if (registered !=0 ) +return ; + + parent =udev_device_get_parent (udev_device); + intfnum =udev_device_get_sysattr_value (parent,"bInterfaceNumber" ); + +DBG ("intfnum %s" , intfnum); + +if (g_strcmp0 (intfnum,"01" ) ==0 ) { + devnode =udev_device_get_devnode (udev_device); +ofono_modem_set_string (modem,"Modem" , devnode); + }else if (g_strcmp0 (intfnum,"03" ) ==0 ) { + devnode =udev_device_get_devnode (udev_device); +ofono_modem_set_string (modem,"Control" , devnode); + +ofono_modem_set_integer (modem,"Registered" ,1 ); +ofono_modem_register (modem); + } +} +static void add_modem (struct udev_device *udev_device) {struct ofono_modem *modem;
@@ -646,6 +676,8 @@ done:add_tc65 (modem, udev_device); else if (g_strcmp0(driver, "nokiacdma") == 0) add_nokiacdma(modem, udev_device); + else if (g_strcmp0(driver, "linktop") == 0) + add_linktop(modem, udev_device); }static gboolean devpath_remove (gpointer key,gpointer value,gpointer user_data)
Signature · 1 line
1.7.1
PATCH 3/3 udev: Add Teracom (Linktop/LW27x) device detection
In reply to Amit Mendapara--- plugins/ofono.rules | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
plugins/ofono.rules +3 -0
@@ -451,4 +451,7 @@ ATTRS{idVendor}=="0421", ATTRS{idProduct}=="0623", ENV{OFONO_DRIVER}="nokia" ATTRS{idVendor}=="0421", ATTRS{idProduct}=="023e", ENV{OFONO_DRIVER}="nokiacdma" ATTRS{idVendor}=="0421", ATTRS{idProduct}=="00b6", ENV{OFONO_DRIVER}="nokiacdma" ++# Teracom (Linktop/LW27x) 3G Data Card ++ATTRS{idVendor}=="230d", ATTRS{idProduct}=="0001", ENV{OFONO_DRIVER}="linktop" + LABEL="ofono_end"
Signature · 1 line
1.7.1
Hi Amit,
Quoted 1 line · Amit Mendapara
Signed-off-by Amit Mendapara <[email protected]>
Please note that we do not use the Signed-off-by. Configure your git settings not to send this.
Quoted 5 lines
--- Makefile.am | 3 + plugins/linktop.c | 357 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 360 insertions(+), 0 deletions(-) create mode 100644 plugins/linktop.c
So I applied this patch, however there's one thing I'd like you to fix:
Quoted 22 lines
plugins/linktop.c new file +22
-0+static int linktop_enable (struct ofono_modem *modem) +{ +struct linktop_data *data =ofono_modem_get_data (modem); + +DBG ("%p" , modem); + + data->modem =open_device (modem,"Modem" ,"Modem: " ); +if (data->modem ==NULL ) +return -EINVAL ; + +g_at_chat_set_disconnect_function (data->modem, + linktop_disconnect, modem); + + data->control =open_device (modem,"Control" ,"Control: " ); +if (data->control ==NULL ) { +g_at_chat_unref (data->modem); + data->modem =NULL ; +return -EIO ; + } + +g_at_chat_send (data->control,"ATE0 +CMEE=1" , none_prefix, +NULL ,NULL ,NULL );
plugins/linktop.c line 205
Quoted 10 lines
plugins/linktop.c new file +10
-0+ +g_at_chat_send (data->modem,"AT" , none_prefix, +NULL ,NULL ,NULL ); + +g_at_chat_send (data->modem,"AT &F" , none_prefix, +NULL ,NULL ,NULL ); + +g_at_chat_send (data->control,"AT+CFUN=1" , none_prefix, + cfun_enable, modem,NULL ); +
oFono expects the modem driver to power up the modem in an 'offline' state. So using CFUN=1 is fine, but it might need to be followed by a CFUN=4 afterward. Look at a few other drivers to see the creative ways we have tried to address this.
Review
Quoted 2 lines
(quoted diff) +2
-0+ return -EINPROGRESS; +}
Regards,
-Denis
Re: [PATCH 2/3] udev: Handle Linktop data card
In reply to Amit MendaparaHi Amit,
Quoted 5 lines · Amit Mendapara
Signed-off-by Amit Mendapara <[email protected]>--- plugins/udev.c | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-)
Patch has been applied, thanks.
Some comments on further improvements:
Quoted 18 lines
plugins/udev.c +18
-0+static void add_linktop (struct ofono_modem *modem, +struct udev_device *udev_device) +{ +const char *devnode, *intfnum; +struct udev_device *parent; +int registered; + +DBG ("modem %p" , modem); + + registered =ofono_modem_get_integer (modem,"Registered" ); +if (registered !=0 ) +return ; + + parent =udev_device_get_parent (udev_device); + intfnum =udev_device_get_sysattr_value (parent,"bInterfaceNumber" ); + +DBG ("intfnum %s" , intfnum); +
plugins/udev.c static void add_nokiacdma(struct ofono_modem *modem, · line 582
Quoted 10 lines
plugins/udev.c +10
-0+if (g_strcmp0 (intfnum,"01" ) ==0 ) { + devnode =udev_device_get_devnode (udev_device); +ofono_modem_set_string (modem,"Modem" , devnode); + }else if (g_strcmp0 (intfnum,"03" ) ==0 ) { + devnode =udev_device_get_devnode (udev_device); +ofono_modem_set_string (modem,"Control" , devnode); + +ofono_modem_set_integer (modem,"Registered" ,1 ); +ofono_modem_register (modem); + }
Instead of hardcoding this info, you might want to use an approach similar to how the Huawei udev rules are structured. However, this really depends on how many variations of this Linktop card there are. Since there's only 1 right now, this is fine.
Regards,
-Denis
Re: [PATCH 3/3] udev: Add Teracom (Linktop/LW27x) device detection
In reply to Amit MendaparaHi Amit,
Quoted 5 lines · Amit Mendapara
Signed-off-by Amit Mendapara <[email protected]>--- plugins/ofono.rules | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
Patch has been applied, thanks.
Regards,
-Denis