Re: [PATCH] Fix Let data device be optional for mbm driver

2010-04-16 Thread Marcel Holtmann
Hi Zhenhua,

 Dell 5530 modem has no data device port. So data device should be
 optional in mbm drvier.

can you please include the content of /proc/bus/usb/devices for this
device and the sysfs descriptions for each TTY port.

Regards

Marcel


___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


RF control, atoms and Powered property

2010-04-16 Thread Pekka Pessi
Hello all,

I continue the Powered saga with Nokia N900 phone as an example use
case. N900 is a Linux phone running Maemo 5, it has a Nokia modem with
ISI interface.

When N900 is powered on, it boots the Linux. First thing in user space
are the system services, things like system dbus, hal, ohm. Also, the
daemons controlling the modem, sscd and csd are started immediately
after the system dbus gets started. (csd provides roughly the same
functionality as ofono does, sscd powers on the modem and controls its
RF state.)

Next step is to start the X server and launch the X session. The first
UI component started after the boot is system-ui. If phone is in
offline or flight mode, system-ui asks whether user wants to get
online. If so, it changes the system mode to normal. Next thing is
pin-query UI. The PIN query checks if there is SIM card which requires
a PIN or PUK code. After giving the PIN/PUK code to the modem, it also
checks if additional codes like device unlocking code is needed and
prompts for them.

Next thing is localization wizard, known as startup-wizard. If it
detects that a new SIM card is inserted into the device it will prompt
the user about the user interface language and the regional settings
with defaults based on the information read from the SIM card.

The normal X session is then started with home screen. The session
includes the Telepathy framework used to handle calls and messaging. A
Telepathy component called Mission Control loads the UI and logging
components and the protocol-specific connection managers. Only after
they are ready to handle an incoming call, the modem is given
permission to register to the cellular network.

N900 modem has three runlevels or states used to control modem,
POWER_OFF, RF_INACTIVE and NORMAL. Power off means real power off, it
is only used when whole device is powered off. The rf inactive is also
pretty self-explanatory. The normal state activates the 3G/UMTS radios
and the software controlling it. The first thing the radio resource
control (RRC) does is registering the modem to the network. If the SIM
is ready, it registers using IMSI. If not, it registers using IMEI. In
latter case, the network only provides limited services. Only
service available in this limited service mode is emergency call.

There are two conditions when N900 modem enters the normal mode (turn
on the modem radios and register to the network):
1) SIM is ready (there is a SIM card inserted in the device, a PIN
code is entered), device is not in flight mode and call UI is ready to
accept an incoming call
2) an emergency call is made

On N900, emergency calls can be initiated by three UI components:
normal call UI, PIN query UI, and screen lock UI. You can make an
emergency call if you enter a valid emergency number like 112 or 911
as pin code or lock code. This is not a N900 feature, but a type
approval requirement for cellular phones. These UI components need to
access the list of valid emergency numbers and a way to initiate an
emergency call regardless of the RF state of the modem. It makes no
sense to enable cellular radio just in order to check if a screen lock
code entered by user is an emergency call number. When the UI
component requests an emergency call, the csd call component makes
things required to place the call: enables RF (and registers to
network), detaches GPRS and then lets the modem dial the emergency
call.

So, based on N900 experience, the current Powered property does not
serve any purpose in RF control. The only interesting use case for RF
control is in post-sim state. If the modem is on, but there is no SIM
card or it requires a PIN code, modem should not enable RF. However,
the atoms required to initiate emergency call should be there.

The emergency call can and probably should override the normal power
control. In other words, if RF is disabled for any reason, it gets
enabled for emergency calls but only during the call. Many other
settings beside RF on/off gets overridden during the call. If
registration is disabled, it gets enabled. If manual registration is
configured, and that network rejects the registration attempt, modem
registers to an another network.

-- 
Pekka.Pessi mail at nokia.com
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 1/2] phonesim: Add a simple USSD UI.

2010-04-16 Thread Denis Kenzior
Hi Andrew,

 This is not the best UI in the world...
 ---
  src/control.cpp |   40 +++-
  src/control.h   |6 ++--
  src/controlbase.ui  |   70
  +++ src/hardwaremanipulator.cpp 
| 
   19 ++-
  src/hardwaremanipulator.h   |9 --
  src/phonesim.cpp|2 +-
  6 files changed, 135 insertions(+), 11 deletions(-)
 

This patch has been applied, thanks.

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 2/2] phonesim: Refactor SimApplication api, add a UI.

2010-04-16 Thread Denis Kenzior
Hi Andrew,

 Try to move all the AT parsing / generating out of applications, just send
 ready envelopes, terminal responses, commands between the application
 and the SimRules class.
 ---
  src/control.cpp |   35 +++
  src/control.h   |1 +
  src/controlbase.ui  |   71 ++
  src/hardwaremanipulator.cpp |   42 +
  src/hardwaremanipulator.h   |7 ++
  src/phonesim.cpp|  138
  +++ src/phonesim.h  | 
6 ++
  src/simapplication.cpp  |  137
  ++ src/simapplication.h|  
  27 +
  9 files changed, 349 insertions(+), 115 deletions(-)

This patch has now been applied, thanks.

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


Re: [PATCH 4/8] Add skeleton of src/emulator.c

2010-04-16 Thread Denis Kenzior
Hi Zhenhua,

 ---
  Makefile.am|7 +-
  include/dbus.h |1 +
  include/emulator.h |   75 +++
  src/emulator.c |  203
   src/ofono.h
| 
4 +
  5 files changed, 287 insertions(+), 3 deletions(-)
  create mode 100644 include/emulator.h
  create mode 100644 src/emulator.c
 

I suggest we handle this one a bit differently.  Let us create an Emulator atom 
that has no driver (similar to how MessageWaiting atom works).  Then have each 
interested atom declare an atom watch on the Emulator atom.  When one is 
created, let the atom get notified and register any AT command handlers it 
wishes.  If the atom itself goes away, it needs to de-register at commands 
from all relevant emulators.

Potentially there might be several emulators at once in the system (e.g. one 
for DUN, one for HFP, one for SPP, etc)

Regards,
-Denis
___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono


[PATCH 1/2] hdlc: allow for scanning and escaping

2010-04-16 Thread Kristen Carlson Accardi
PPP needs to inspect the packet protocol to see if a character
should be escaped.  Additionally, it needs to be able to compare
against recv and xmit accm.
---
 gatchat/gathdlc.c |   60 
 gatchat/gathdlc.h |   12 ++
 2 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index 19df9c6..c5c02cf 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -47,6 +47,12 @@ struct _GAtHDLC {
gpointer receive_data;
GAtDebugFunc debugf;
gpointer debug_data;
+   GAtHDLCScanFunc scan_func;
+   gpointer scan_data;
+   GAtHDLCSendEscapeFunc send_escape_func;
+   gpointer send_escape_data;
+   GAtHDLCRecvEscapeFunc recv_escape_func;
+   gpointer recv_escape_data;
 };
 
 static void new_bytes(GAtHDLC *hdlc)
@@ -71,6 +77,13 @@ static void new_bytes(GAtHDLC *hdlc)
continue;
}
 
+   if (hdlc-recv_escape_func 
+   hdlc-recv_escape_func(hdlc-recv_escape_data,
+   buf[pos])) {
+   pos++;
+   continue;
+   }
+
if (buf[pos] == 0x7d) {
if (pos + 2  len)
break;
@@ -249,6 +262,35 @@ void g_at_hdlc_set_receive(GAtHDLC *hdlc, GAtReceiveFunc 
func,
hdlc-receive_data = user_data;
 }
 
+void g_at_hdlc_set_scan(GAtHDLC *hdlc, GAtHDLCScanFunc func, gpointer 
user_data)
+{
+   if (!hdlc)
+   return;
+
+   hdlc-scan_func = func;
+   hdlc-scan_data = user_data;
+}
+
+void g_at_hdlc_set_send_escape(GAtHDLC *hdlc, GAtHDLCSendEscapeFunc func,
+   gpointer user_data)
+{
+   if (!hdlc)
+   return;
+
+   hdlc-send_escape_func = func;
+   hdlc-send_escape_data = user_data;
+}
+
+void g_at_hdlc_set_recv_escape(GAtHDLC *hdlc, GAtHDLCRecvEscapeFunc func,
+   gpointer user_data)
+{
+   if (!hdlc)
+   return;
+
+   hdlc-recv_escape_func = func;
+   hdlc-recv_escape_data = user_data;
+}
+
 static gboolean can_write_data(GIOChannel *channel, GIOCondition cond,
gpointer user_data)
 {
@@ -302,11 +344,15 @@ static void wakeup_write(GAtHDLC *hdlc)
can_write_data, hdlc, write_watch_destroy);
 }
 
-static inline void hdlc_put(GAtHDLC *hdlc, guint8 *buf, gsize *pos, guint8 c)
+static inline void hdlc_put(GAtHDLC *hdlc, guint8 *buf, gsize *pos, guint8 c,
+   gboolean scan_result)
 {
gsize i = *pos;
 
-   if (c == 0x7e || c == 0x7d) {
+   if ((hdlc-send_escape_func 
+   hdlc-send_escape_func(hdlc-send_escape_data,
+   c, scan_result))
+   || c == 0x7e || c == 0x7d) {
buf[i++] = 0x7d;
buf[i++] = c ^ 0x20;
} else
@@ -321,6 +367,10 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char 
*data, gsize size)
unsigned int space, i = 0;
guint16 fcs = 0x;
gsize pos;
+   gboolean scan_result = FALSE;
+
+   if (hdlc-scan_func)
+   scan_result = hdlc-scan_func(hdlc-scan_data, data);
 
do {
space = ring_buffer_avail_no_wrap(hdlc-write_buffer);
@@ -332,12 +382,12 @@ gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned 
char *data, gsize size)
 
while (size--) {
fcs = crc_ccitt_byte(fcs, data[i]);
-   hdlc_put(hdlc, buf, pos, data[i++]);
+   hdlc_put(hdlc, buf, pos, data[i++], scan_result);
}
 
fcs ^= 0x;
-   hdlc_put(hdlc, buf, pos, fcs  0xff);
-   hdlc_put(hdlc, buf, pos, fcs  8);
+   hdlc_put(hdlc, buf, pos, fcs  0xff, scan_result);
+   hdlc_put(hdlc, buf, pos, fcs  8, scan_result);
 
buf[pos++] = 0x7e;
 
diff --git a/gatchat/gathdlc.h b/gatchat/gathdlc.h
index a295f08..f1adeb7 100644
--- a/gatchat/gathdlc.h
+++ b/gatchat/gathdlc.h
@@ -32,6 +32,12 @@ struct _GAtHDLC;
 
 typedef struct _GAtHDLC GAtHDLC;
 
+typedef gboolean (*GAtHDLCSendEscapeFunc)(gpointer user_data, guint8 c,
+   gboolean scan_result);
+typedef gboolean (*GAtHDLCRecvEscapeFunc)(gpointer user_data, guint8 c);
+
+typedef gboolean (*GAtHDLCScanFunc)(gpointer user_data,
+   const unsigned char *data);
 GAtHDLC *g_at_hdlc_new(GIOChannel *channel);
 
 GAtHDLC *g_at_hdlc_ref(GAtHDLC *hdlc);
@@ -43,6 +49,12 @@ void g_at_hdlc_set_receive(GAtHDLC *hdlc, GAtReceiveFunc 
func,
gpointer user_data);
 gboolean 

[PATCH 2/2] hdlc: handle wrapped buffers

2010-04-16 Thread Kristen Carlson Accardi
---
 gatchat/gathdlc.c |   75 
 1 files changed, 40 insertions(+), 35 deletions(-)

diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index c5c02cf..13e15a1 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -59,11 +59,12 @@ static void new_bytes(GAtHDLC *hdlc)
 {
unsigned int len = ring_buffer_len(hdlc-read_buffer);
unsigned char *buf = ring_buffer_read_ptr(hdlc-read_buffer, 0);
+   unsigned int wrap = ring_buffer_len_no_wrap(hdlc-read_buffer);
unsigned char val;
unsigned int pos = 0;
 
while (pos  len) {
-   if (buf[pos] == 0x7e) {
+   if (*buf == 0x7e) {
if (hdlc-receive_func  hdlc-decode_offset  2 
hdlc-decode_fcs == 0xf0b8) {
hdlc-receive_func(hdlc-decode_buffer,
@@ -74,29 +75,44 @@ static void new_bytes(GAtHDLC *hdlc)
hdlc-decode_fcs = 0x;
hdlc-decode_offset = 0;
pos++;
+   buf++;
+   if (pos == wrap)
+   buf = ring_buffer_read_ptr(hdlc-read_buffer,
+   pos);
continue;
}
 
if (hdlc-recv_escape_func 
hdlc-recv_escape_func(hdlc-recv_escape_data,
-   buf[pos])) {
+   *buf)) {
pos++;
+   buf++;
+   if (pos == wrap)
+   buf = ring_buffer_read_ptr(hdlc-read_buffer,
+   pos);
continue;
}
 
-   if (buf[pos] == 0x7d) {
+   if (*buf == 0x7d) {
if (pos + 2  len)
break;
pos++;
-   val = buf[pos] ^ 0x20;
+   buf++;
+   if (pos == wrap)
+   buf = ring_buffer_read_ptr(hdlc-read_buffer,
+   pos);
+   val = *buf ^ 0x20;
} else
-   val = buf[pos];
+   val = *buf;
 
hdlc-decode_buffer[hdlc-decode_offset] = val;
hdlc-decode_fcs = crc_ccitt_byte(hdlc-decode_fcs, val);
 
hdlc-decode_offset++;
pos++;
+   buf++;
+   if (pos == wrap)
+   buf = ring_buffer_read_ptr(hdlc-read_buffer, pos);
}
 
ring_buffer_drain(hdlc-read_buffer, pos);
@@ -344,55 +360,44 @@ static void wakeup_write(GAtHDLC *hdlc)
can_write_data, hdlc, write_watch_destroy);
 }
 
-static inline void hdlc_put(GAtHDLC *hdlc, guint8 *buf, gsize *pos, guint8 c,
-   gboolean scan_result)
+static inline void hdlc_buffer_put_char(struct ring_buffer *buffer,
+   const char val)
 {
-   gsize i = *pos;
+   ring_buffer_write(buffer, val, 1);
+}
 
+static inline void hdlc_put(GAtHDLC *hdlc, guint8 c, gboolean scan_result)
+{
if ((hdlc-send_escape_func 
hdlc-send_escape_func(hdlc-send_escape_data,
c, scan_result))
|| c == 0x7e || c == 0x7d) {
-   buf[i++] = 0x7d;
-   buf[i++] = c ^ 0x20;
+   hdlc_buffer_put_char(hdlc-write_buffer, 0x7d);
+   hdlc_buffer_put_char(hdlc-write_buffer, c ^ 0x20);
} else
-   buf[i++] = c;
-
-   *pos = i;
+   hdlc_buffer_put_char(hdlc-write_buffer, c);
 }
 
 gboolean g_at_hdlc_send(GAtHDLC *hdlc, const unsigned char *data, gsize size)
 {
-   unsigned char *buf;
-   unsigned int space, i = 0;
guint16 fcs = 0x;
-   gsize pos;
gboolean scan_result = FALSE;
+   unsigned int i = 0;
 
if (hdlc-scan_func)
scan_result = hdlc-scan_func(hdlc-scan_data, data);
 
-   do {
-   space = ring_buffer_avail_no_wrap(hdlc-write_buffer);
-   if (space == 0)
-   break;
+   hdlc_buffer_put_char(hdlc-write_buffer, 0x7e);
 
-   buf = ring_buffer_write_ptr(hdlc-write_buffer);
-   pos = 0;
-
-   while (size--) {
-   fcs = crc_ccitt_byte(fcs, data[i]);
-   hdlc_put(hdlc, buf, pos, data[i++], scan_result);
-   }
-
-   fcs ^= 0x;
-   hdlc_put(hdlc, buf, pos, fcs  0xff, scan_result);
-   hdlc_put(hdlc, buf, pos, fcs  8, scan_result);
-
- 

[PATCH 0/2] hdlc fixes

2010-04-16 Thread Kristen Carlson Accardi
Kristen Carlson Accardi (2):
  hdlc: allow for scanning and escaping
  hdlc: handle wrapped buffers

 gatchat/gathdlc.c |  121 ++--
 gatchat/gathdlc.h |   12 +
 2 files changed, 100 insertions(+), 33 deletions(-)

___
ofono mailing list
ofono@ofono.org
http://lists.ofono.org/listinfo/ofono