Huawei GPRS support
v5 cover Huawei GPRS support
v5 of my Huawei GPRS support. Hopefully ready now :)
Please take a look and comment.
---
Kalle Valo (3):
huawei: add gprs context
Move report_signal_strength to atutil
huawei: detect possible secondary device
drivers/atmodem/atutil.h | 12 +++ drivers/atmodem/network-registration.c | 26 +++---- plugins/huawei.c | 128 ++++++++++++++++++++++++++++---- plugins/udev.c | 61 +++++++++++++-- 4 files changed, 188 insertions(+), 39 deletions(-)
Hi Kalle,
Quoted 4 lines
v5 of my Huawei GPRS support. Hopefully ready now :)
Please take a look and comment.
All three have now been applied.
Thanks,
-Denis
PATCH v5 1/3 huawei: detect possible secondary device
In reply to Kalle Valo---
plugins/huawei.c | 67 +++++++++++++++++++++++++++++++++++++++++++----------- plugins/udev.c | 61 +++++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 106 insertions(+), 22 deletions(-)
plugins/huawei.c +53 -14
@@ -46,6 +46,7 @@struct huawei_data {GAtChat *chat; +GAtChat *event; };static int huawei_probe (struct ofono_modem *modem)
@@ -72,12 +73,14 @@ static void huawei_remove(struct ofono_modem *modem)ofono_modem_set_data (modem,NULL );g_at_chat_unref (data->chat); +g_at_chat_unref (data->event);g_free (data); }static void huawei_debug (const char *str,void *user_data) { -ofono_info ("%s" , str); +const char *prefix = user_data; +ofono_info ("%s%s" , prefix, str); }static void cfun_enable (gboolean ok,GAtResult *result,gpointer user_data)
@@ -90,35 +93,64 @@ static void cfun_enable(gboolean ok, GAtResult *result, gpointer user_data)ofono_modem_set_powered (modem, TRUE); } -static int huawei_enable (struct ofono_modem *modem) +static GAtChat *create_port (const char *device) { -struct huawei_data *data =ofono_modem_get_data (modem);GAtSyntax *syntax;GIOChannel *channel; -const char *device; - -DBG ("%p" , modem); - - device =ofono_modem_get_string (modem,"Device" ); -if (!device) -return -EINVAL ; +GAtChat *chat; channel =g_at_tty_open (device,NULL );if (!channel) -return -EIO ; +return NULL ; syntax =g_at_syntax_new_gsm_permissive (); - data->chat =g_at_chat_new (channel, syntax); + chat =g_at_chat_new (channel, syntax);g_at_syntax_unref (syntax);g_io_channel_unref (channel); -if (!data->chat) +if (!chat) +return NULL ; + +return chat; +} + +static int huawei_enable (struct ofono_modem *modem) +{ +struct huawei_data *data =ofono_modem_get_data (modem); +const char *modem_device, *event_device; + +DBG ("%p" , modem); + + modem_device =ofono_modem_get_string (modem,"Device" ); + event_device =ofono_modem_get_string (modem,"SecondaryDevice" ); + +if (modem_device ==NULL || event_device ==NULL ) +return -EINVAL ; + + data->chat =create_port (modem_device); + +if (data->chat ==NULL )return -EIO ;g_at_chat_add_terminator (data->chat,"COMMAND NOT SUPPORT" ,-1 , FALSE);if (getenv ("OFONO_AT_DEBUG" )) -g_at_chat_set_debug (data->chat, huawei_debug,NULL ); +g_at_chat_set_debug (data->chat, huawei_debug,"" ); + + data->event =create_port (event_device); + +if (data->event ==NULL ) { +g_at_chat_unref (data->chat); + data->chat =NULL ; +return -EIO ; + } + +g_at_chat_add_terminator (data->event,"COMMAND NOT SUPPORT" ,-1 , + FALSE); + +if (getenv ("OFONO_AT_DEBUG" )) +g_at_chat_set_debug (data->event, huawei_debug, +"EventChannel: " );g_at_chat_send (data->chat,"ATE0" ,NULL ,NULL ,NULL ,NULL );
@@ -148,6 +180,13 @@ static int huawei_disable(struct ofono_modem *modem)DBG ("%p" , modem); +if (data->event) { +g_at_chat_cancel_all (data->event); +g_at_chat_unregister_all (data->event); +g_at_chat_unref (data->event); + data->event =NULL ; + } +if (!data->chat)return 0 ;
plugins/udev.c +53 -8
77 lines not on this page · raw message
PATCH v5 2/3 Move report_signal_strength to atutil
In reply to Kalle ValoThe function is needed in two different places, better to move it to atutil.h.
---
drivers/atmodem/atutil.h | 12 ++++++++++++ drivers/atmodem/network-registration.c | 22 ++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-)
drivers/atmodem/atutil.h +12 -0
@@ -55,6 +55,18 @@ static inline struct cb_data *cb_data_new(void *cb, void *data)return ret; } +static inline int at_util_convert_signal_strength (int strength) +{ +int result; + +if (strength ==99 ) + result =-1 ; +else + result = (strength *100 ) /31 ; + +return result; +} +#define DECLARE_FAILURE (e) \ struct ofono_error e; \ e.type = OFONO_ERROR_TYPE_FAILURE; \
drivers/atmodem/network-registration.c +6 -16
@@ -463,19 +463,6 @@ error:CALLBACK_WITH_FAILURE (cb, data); } -static inline void report_signal_strength (struct ofono_netreg *netreg, -int strength) -{ -DBG ("csq_notify: %d" , strength); - -if (strength ==99 ) - strength =-1 ; -else - strength = (strength *100 ) /31 ; - -ofono_netreg_strength_notify (netreg, strength); -} -static void csq_notify (GAtResult *result,gpointer user_data) {struct ofono_netreg *netreg = user_data;
@@ -490,7 +477,8 @@ static void csq_notify(GAtResult *result, gpointer user_data)if (!g_at_result_iter_next_number (&iter, &strength))return ; -report_signal_strength (netreg, strength); +ofono_netreg_strength_notify (netreg, +at_util_convert_signal_strength (strength)); }static void calypso_csq_notify (GAtResult *result,gpointer user_data)
@@ -507,7 +495,8 @@ static void calypso_csq_notify(GAtResult *result, gpointer user_data)if (!g_at_result_iter_next_number (&iter, &strength))return ; -report_signal_strength (netreg, strength); +ofono_netreg_strength_notify (netreg, +at_util_convert_signal_strength (strength)); }static void option_osigq_notify (GAtResult *result,gpointer user_data)
@@ -524,7 +513,8 @@ static void option_osigq_notify(GAtResult *result, gpointer user_data)if (!g_at_result_iter_next_number (&iter, &strength))return ; -report_signal_strength (netreg, strength); +ofono_netreg_strength_notify (netreg, +at_util_convert_signal_strength (strength)); }static void option_owcti_notify (GAtResult *result,gpointer user_data)
PATCH v5 3/3 huawei: add gprs context
In reply to Kalle ValoTested with Huawei E1552 HSDPA USB stick using a finnish Saunalahti prepaid SIM.
---
drivers/atmodem/network-registration.c | 4 ++ plugins/huawei.c | 61 +++++++++++++++++++++++++++++++- 2 files changed, 64 insertions(+), 1 deletions(-)
drivers/atmodem/network-registration.c +4 -0
@@ -906,6 +906,10 @@ static void at_creg_set_cb(gboolean ok, GAtResult *result, gpointer user_data) cind_support_cb, netreg, NULL);break ; +case OFONO_VENDOR_HUAWEI : +/* huawei doesn't support CIND */ +ofono_netreg_register (netreg); +break ;default :g_at_chat_send (nd->chat,"AT+CIND=?" , cind_prefix, cind_support_cb, netreg,NULL );
plugins/huawei.c +60 -1
81 lines not on this page · raw message