Implement STATUS polling in atmodem driver, enable it for phonesim & atgen.
PATCH 5/5 Implement STATUS polling in atmodem driver, enable it for phonesim & atgen.
--- Makefile.am | 2 + drivers/atmodem/sim-poll.c | 283 ++++++++++++++++++++++++++++++++++++++++++++ drivers/atmodem/sim-poll.h | 22 ++++ plugins/atgen.c | 7 +- plugins/phonesim.c | 6 +- 5 files changed, 316 insertions(+), 4 deletions(-) create mode 100644 drivers/atmodem/sim-poll.c create mode 100644 drivers/atmodem/sim-poll.h
Makefile.am +2 -0
@@ -123,6 +123,8 @@ builtin_sources += $(gatchat_sources) \ drivers/atmodem/call-meter.c \ drivers/atmodem/network-registration.c \ drivers/atmodem/sim.c \ + drivers/atmodem/sim-poll.c \ + drivers/atmodem/sim-poll.h \ drivers/atmodem/ussd.c \ drivers/atmodem/voicecall.c \ drivers/atmodem/call-barring.c \
drivers/atmodem/sim-poll.c new file +283 -0
283 lines not on this page · raw message
drivers/atmodem/sim-poll.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* +* oFono - Open Source Telephony +* +* Copyright (C) 2008-2010 Intel Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +* +*/ + +void ofono_atmodem_poll_enable (struct ofono_modem *modem,void *data);
plugins/atgen.c +4 -3
@@ -48,6 +48,8 @@#include <ofono/ussd.h> #include <ofono/voicecall.h> +#include <drivers/atmodem/sim-poll.h> +static const char *tty_opts[] = {"Baud" ,"Read" ,
@@ -156,15 +158,14 @@ static int atgen_disable(struct ofono_modem *modem)static void atgen_pre_sim (struct ofono_modem *modem) {GAtChat *chat =ofono_modem_get_data (modem); -struct ofono_sim *sim;DBG ("%p" , modem);ofono_devinfo_create (modem,0 ,"atmodem" , chat); - sim =ofono_sim_create (modem,0 ,"atmodem" , chat); +ofono_sim_create (modem,0 ,"atmodem" , chat);ofono_voicecall_create (modem,0 ,"atmodem" , chat); -ofono_sim_inserted (sim); +ofono_atmodem_poll_enable (modem, chat); }static void atgen_post_sim (struct ofono_modem *modem)
plugins/phonesim.c +5 -1
@@ -58,6 +58,7 @@#include <ofono/gprs-context.h> #include <drivers/atmodem/vendor.h> +#include <drivers/atmodem/sim-poll.h> struct phonesim_data {GAtMux *mux;
@@ -289,7 +290,10 @@ static void phonesim_pre_sim(struct ofono_modem *modem)else ofono_voicecall_create (modem,0 ,"atmodem" , data->chat); -ofono_sim_inserted (sim); +if (data->calypso) +ofono_sim_inserted (sim); +else +ofono_atmodem_poll_enable (modem, data->chat); }static void phonesim_post_sim (struct ofono_modem *modem)
Signature · 1 line
1.6.1
Hi Andrzej,
drivers/atmodem/sim-poll.c line 87
Quoted 9 lines
drivers/atmodem/sim-poll.c new file +9
-0+ +if (!g_at_result_iter_next_hexstring (&iter, &response, &len)) +return ; + +if (rlen != len *2 || len <2 || (response[len -2 ] !=0x90 && + response[len -2 ] !=0x91 ) || + (response[len -2 ] ==0x90 && response[len -1 ] !=0 )) +return ; +
let me re-write this into something readable ;)
if (len < 2 || rlen != len * 2) return; if (response[len - 2] != 0x90 || response[len - 2] != 0x91) return; if (response[len - 2] == 0x90 && response[len - 1] != 0) return;
And please add comments on top of the if statements to explain what they are checking for.
Regards
Marcel