Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-04 Thread Marcel Holtmann
Hi Sjur,

> > what about potential USB based CAIF devices?
> Good question, but in a Bridge Setup for a phone this will not really
> be devices that come and go.
> I belive it will still be a fixed HW setup where the Modem Init Daemon
> will have static knowledge of the
> USB modems. But I'll discuss this with my coleagues tomorrow.
> In case of true USB dongles the modem should look pretty much
> identical to MBM USB dongles.

I personally would prefer that USB devices just expose CAIF directly.
The whole handling of multiple hardcoded TTY and network interface is
only sub-optimal.

I know it is kinda nice to use standard USB class drivers, but the
flexibility that CAIF actually gives you goes away.

>From my point of view, it should be similar to Phonet/ISI over USB. At
least on Linux we have a CAIF subsystem ;)

> >I would just ask to send the property changed signal for the serial
> >number before sending the signal for on/ready.
> It will require a re-design of the state machine in the Modem Init Daemon,
> but I'll check into this tomorrow.
> 
> Here is the latest version of the Dbus API:
> 
> STE Modem Init Deamon Manager
> =
> Service   com.stericsson.modeminit
> Interface com.stericsson.modeminit.ModemManager

Just call it com.stericsson.modeminit.Manager. That gives you the chance
to also include other methods/signals later on if needed.

> Object path   /
> 
> Methods   array{object,dict} GetModems()
> 
>   Get array of STE Modem objects and their state and
>   properties (out signature 'a(oa{sv})').
> 
>   The method should only be call once per application.
>   Further changes shall be monitored via StateChange
>   signals.
> 
> STE Modem
> =
> Service   com.stericsson.modeminit
> Interface com.stericsson.modeminit.Modem
> Object path   variable
> 
> Signals   PropertyChanged(string property, variant value)
> 
>   This signal indicates a changed value of the given
>   property.
> 
> Propertiesstring State [readonly]
> 
>   The modems state is dynamic can can have the following
>   values:
>   "booting"   Modem is powered up (flashed version)
>   or Modem is powered up and firmware upload
>   is completed. (flashless version)
>   "upgrading" Firmware upgrade on going
>   or Flashing manager under execution -
>   modem in service mode.
>   "on"Modem has booted and is ready for use.
>   This implies that all AT channels are
>   available, the modem might be in
>   e.g. flight mode.
>   NOTE: Consider change name to "ready"
> 
>   "dumping"  Modem has crashed and dump is ongoing
>   "off"   Modem is powered off.
> 
>   string AtInterface[readonly]
> 
>   CAIF Link Layer interface to be used for
>   AT channels for a modem.

Why is there an "At" in here? I know that mainly only AT command
channels will be used, but the CAIF interface can be also used to
request debug channels and other things. So I would just call it
Interface only to say what's the interface name is to bind to.

>   string Serial[optional,readonly]
> 
>   Serial Number or IMEI for the Modem. The Serial will
>   not be available until the modem can open an AT channel.

Otherwise, this looks a lot simpler and cleaner.

Regards

Marcel


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-03 Thread Sjur Brændeland
Hi Marcel,

> what about potential USB based CAIF devices?
Good question, but in a Bridge Setup for a phone this will not really
be devices that come and go.
I belive it will still be a fixed HW setup where the Modem Init Daemon
will have static knowledge of the
USB modems. But I'll discuss this with my coleagues tomorrow.
In case of true USB dongles the modem should look pretty much
identical to MBM USB dongles.

>I would just ask to send the property changed signal for the serial
>number before sending the signal for on/ready.
It will require a re-design of the state machine in the Modem Init Daemon,
but I'll check into this tomorrow.

Here is the latest version of the Dbus API:

STE Modem Init Deamon Manager
=
Service com.stericsson.modeminit
Interface   com.stericsson.modeminit.ModemManager
Object path /

Methods array{object,dict} GetModems()

Get array of STE Modem objects and their state and
properties (out signature 'a(oa{sv})').

The method should only be call once per application.
Further changes shall be monitored via StateChange
signals.

STE Modem
=
Service com.stericsson.modeminit
Interface   com.stericsson.modeminit.Modem
Object path variable

Signals PropertyChanged(string property, variant value)

This signal indicates a changed value of the given
property.

Properties  string State [readonly]

The modems state is dynamic can can have the following
values:
"booting"   Modem is powered up (flashed version)
or Modem is powered up and firmware upload
is completed. (flashless version)
"upgrading" Firmware upgrade on going
or Flashing manager under execution -
modem in service mode.
"on"Modem has booted and is ready for use.
This implies that all AT channels are
available, the modem might be in
e.g. flight mode.
NOTE: Consider change name to "ready"

"dumping"  Modem has crashed and dump is ongoing
"off"   Modem is powered off.

string AtInterface[readonly]

CAIF Link Layer interface to be used for
AT channels for a modem.

string Serial[optional,readonly]

Serial Number or IMEI for the Modem. The Serial will
not be available until the modem can open an AT channel.


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-03 Thread Marcel Holtmann
Hi Sjur,

> >> Signals   StateChange(string State)
> >>
> >>   The modems state sent from when
> >>   a modem state change occurs. State is the only
> >>   dynamic property in this Interface.
> >
> >I would personally just go straight for PropertyChanged signal here and
> >not bother with StateChanged. It is actually "...Changed" since at that
> >time the state has already changed ;)
> 
> OK, I'll look into this. I thought StateChange was the only dynamic parameter,
> but I might have been wrong here (see below).
> 
> > You also need the following signals:
> >
> >ModemAdded(object, dict)
> >
> >ModemRemoved(object)
> 
> I think I'd rather add this when I see a use case for it. The Modem
> Init Deamon would need to
> know what GPIOs are associated with what modems, and what CAIF
> interfaces to use etc.
> This information is not dynamic, at least not at the moment. So
> ModemAdded and ModemRemoved
> will not happen in the current implementation, all the modems will be
> known when the Manager
> interface becomes available.

what about potential USB based CAIF devices?

> ...
> >>   string CaifAtInterface [readonly]
> >>
> >>   CAIF Link Layer interface to be used for
> >>   AT channels for a modem.
> >
> > I would really just call this "Interface" to make it simpler. Don't
> > think that you are expecting more than just CAIF interface here anyway.
> 
> OK, Fair enough.
> 
> > And in addition if we can have the modem serial number here as "Serial"
> > as well would be good. Even it is is not right away available, you can
> > signal a change via PropertyChanged signal.
> >
> > That way we can construct a proper modem object path inside oFono. I
> > really rather use the serial number and only fallback to the interface
> > name.
> >
> 
> OK, a Serial property is doable, but I think this is only available
> after state "on" (ready)

That is fine. We have the same case in oFono that the SubscriberIdentity
only becomes available a bit later. That is in the end easy to handle.

I would just ask to send the property changed signal for the serial
number before sending the signal for on/ready.

> has been reached. The drawback is that my assumption of State being the only
> dynamic property wrong.
> Crap you were right - I might need to add a PropertyChanged signal.

This way you are a lot more flexible in the future.

Regards

Marcel


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-03 Thread Sjur Brændeland
Hi Marcel,

>> Signals   StateChange(string State)
>>
>>   The modems state sent from when
>>   a modem state change occurs. State is the only
>>   dynamic property in this Interface.
>
>I would personally just go straight for PropertyChanged signal here and
>not bother with StateChanged. It is actually "...Changed" since at that
>time the state has already changed ;)

OK, I'll look into this. I thought StateChange was the only dynamic parameter,
but I might have been wrong here (see below).

> You also need the following signals:
>
>        ModemAdded(object, dict)
>
>        ModemRemoved(object)

I think I'd rather add this when I see a use case for it. The Modem
Init Deamon would need to
know what GPIOs are associated with what modems, and what CAIF
interfaces to use etc.
This information is not dynamic, at least not at the moment. So
ModemAdded and ModemRemoved
will not happen in the current implementation, all the modems will be
known when the Manager
interface becomes available.

...
>>               string CaifAtInterface [readonly]
>>
>>                       CAIF Link Layer interface to be used for
>>                       AT channels for a modem.
>
> I would really just call this "Interface" to make it simpler. Don't
> think that you are expecting more than just CAIF interface here anyway.

OK, Fair enough.

> And in addition if we can have the modem serial number here as "Serial"
> as well would be good. Even it is is not right away available, you can
> signal a change via PropertyChanged signal.
>
> That way we can construct a proper modem object path inside oFono. I
> really rather use the serial number and only fallback to the interface
> name.
>

OK, a Serial property is doable, but I think this is only available
after state "on" (ready)
has been reached. The drawback is that my assumption of State being the only
dynamic property wrong.
Crap you were right - I might need to add a PropertyChanged signal.

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


Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-03 Thread Marcel Holtmann
Hi Sjur,

> > is this the full API or only part of it. If it is just a part of it,
> > please send the full API for the daemon. Just looking at this piece, I
> > am not really thinking that this is a good API. It is actually pretty
> > much broken :(
> 
> Ok, here's an updated version of the Modem Init Daemon DBus API.
> I hope this is aligned with what we discussed on the IRC.
> 
> STE Modem Init Deamon Manager
> 
> 
> Service   com.stericsson.modeminit
> Interface com.stericsson.modeminit.Manager
> Object path   /
> 
> Methods   array{object,dict} GetModems()
> 
>   Get array of STE Modem objects and their state and
>   properties (out signature 'a(oa{sv})').
> 
>   The method should only be call once per application.
>   Further changes shall be monitored via StateChange
>   signals.

You also need the following signals:

ModemAdded(object, dict)

ModemRemoved(object)

> STE Modem
> 
> Service   com.stericsson.modeminit
> Interface com.stericsson.modeminit.Modem
> Object path   variable
> 
> Signals   StateChange(string State)
> 
>   The modems state sent from when
>   a modem state change occurs. State is the only
>   dynamic property in this Interface.

I would personally just go straight for PropertyChanged signal here and
not bother with StateChanged. It is actually "...Changed" since at that
time the state has already changed ;)

> Propertiesstring State [readonly]
> 
>   The modems state is dynamic can can have the following
>   values:
>   "booting"   Modem is powered up (flashed version)
>   or Modem is powered up and firmware upload
>   is completed. (flashless version)
>   "upgrading" Firmware upgrade on going
>   or Flashing manager under execution -
>   modem in service mode.
>   "on" Modem has booted and is ready for use.
>   This implies that all AT channels are
>   available, the modem might be in
>   e.g. flight mode.
>   "dumping"  Modem has crashed and dump is ongoing
>   "off"   Modem is powered off.

I personally would call it "ready" instead of "on" since the modem is
actually on, it is just not ready yet.

>   string CaifAtInterface [readonly]
> 
>   CAIF Link Layer interface to be used for
>   AT channels for a modem.

I would really just call this "Interface" to make it simpler. Don't
think that you are expecting more than just CAIF interface here anyway.

And in addition if we can have the modem serial number here as "Serial"
as well would be good. Even it is is not right away available, you can
signal a change via PropertyChanged signal.

That way we can construct a proper modem object path inside oFono. I
really rather use the serial number and only fallback to the interface
name.

Regards

Marcel


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2011-01-03 Thread Sjur Brændeland
Hi Marcel.

> is this the full API or only part of it. If it is just a part of it,
> please send the full API for the daemon. Just looking at this piece, I
> am not really thinking that this is a good API. It is actually pretty
> much broken :(

Ok, here's an updated version of the Modem Init Daemon DBus API.
I hope this is aligned with what we discussed on the IRC.

STE Modem Init Deamon Manager


Service com.stericsson.modeminit
Interface   com.stericsson.modeminit.Manager
Object path /

Methods array{object,dict} GetModems()

Get array of STE Modem objects and their state and
properties (out signature 'a(oa{sv})').

The method should only be call once per application.
Further changes shall be monitored via StateChange
signals.

STE Modem

Service com.stericsson.modeminit
Interface   com.stericsson.modeminit.Modem
Object path variable

Signals StateChange(string State)

The modems state sent from when
a modem state change occurs. State is the only
dynamic property in this Interface.

Properties  string State [readonly]

The modems state is dynamic can can have the following
values:
"booting"   Modem is powered up (flashed version)
or Modem is powered up and firmware upload
is completed. (flashless version)
"upgrading" Firmware upgrade on going
or Flashing manager under execution -
modem in service mode.
"on" Modem has booted and is ready for use.
This implies that all AT channels are
available, the modem might be in
e.g. flight mode.
"dumping"  Modem has crashed and dump is ongoing
"off"   Modem is powered off.

string CaifAtInterface [readonly]

CAIF Link Layer interface to be used for
AT channels for a modem.

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


Re: [PATCHv2] plugin: Add ste modem initd integration

2010-12-22 Thread Marcel Holtmann
Hi Sjur,

> >> > This is a bad D-Bus API btw. Using a D-Bus method to trigger signal
> >> > sending. You will wake up any listener for that signal. What is wrong
> >> > with just having a GetState?
> >>
> >> My problem is that I need to get the path, or modem serial-number if
> >> you like, to the
> >> modem(s). As I don't know the start order I have to query the state at 
> >> startup.
> >> So this will happens only once. The simples way for me to get the path is
> >> to send "ResendState" to path "/". This will then send the state info
> >> for all modem
> >> paths.
> >>
> >> I don't think I have the path them available at connect...
> >> If you have any other ideas of how to query the modem instances I'm all 
> >> ears?
> >
> > I think you need to resend the D-Bus API of your init daemon. I need to
> > have a second look.
> 
> This is an extract of the Modem Init Daemon D-Bus API.
> I have removed the GetState API as we don't know the object
> path of the modem when oFOno has just booted. Instead we
> have added the ResendState API. This will be called initially
> when oFono starts to query the modem instances and their
> state. After startup state changes are handed as signals
> with StateChange. (There are some exceptions to this but
> they should be only corner cases).
> 
> 
> Modem Init Deamon
> 
> 
> Service com.stericsson.modeminit
> Interface   com.stericsson.modeminit.Modem
> Object path /{modem-serial} or /
> 
> Methods
>   void  ResendState()
> 
>   Resends state information for all modems.
> This method must use with '/' as object path.
> 
>   string GetCaifIfName()
> 
>   Returns the CAIF Link Layer interface used for
> AT channels for a specific modem. This method
> must use the same object path as used in StateChange.
> 
> 
> Signals  StateChange(string status)
> 
>The modems state sent from Modem Init Daemon when
>a modem state change occurs. The object path must
>  be the identifier of the modem (typically
>the serial-id or IMEI of the HW).
> 
>"booting"   Modem is powered up (flashed version)
>or Modem is powered up and firmware upload
>is completed. (flashless version)
>"upgrading" Firmware upgrade on going
>or Flashing manager under execution -
>modem in service mode.
>"on" Modem has booted and is ready for use.
>This implies that all AT channels are
>available, the modem might be in
>e.g. flight mode.
>"dumping"  Modem has crashed and dump is ongoing
>"off"   Modem is powered off.

is this the full API or only part of it. If it is just a part of it,
please send the full API for the daemon. Just looking at this piece, I
am not really thinking that this is a good API. It is actually pretty
much broken :(

Regards

Marcel


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2010-12-21 Thread Sjur Brændeland
Hi Marcel.

>> > This is a bad D-Bus API btw. Using a D-Bus method to trigger signal
>> > sending. You will wake up any listener for that signal. What is wrong
>> > with just having a GetState?
>>
>> My problem is that I need to get the path, or modem serial-number if
>> you like, to the
>> modem(s). As I don't know the start order I have to query the state at 
>> startup.
>> So this will happens only once. The simples way for me to get the path is
>> to send "ResendState" to path "/". This will then send the state info
>> for all modem
>> paths.
>>
>> I don't think I have the path them available at connect...
>> If you have any other ideas of how to query the modem instances I'm all ears?
>
> I think you need to resend the D-Bus API of your init daemon. I need to
> have a second look.

This is an extract of the Modem Init Daemon D-Bus API.
I have removed the GetState API as we don't know the object
path of the modem when oFOno has just booted. Instead we
have added the ResendState API. This will be called initially
when oFono starts to query the modem instances and their
state. After startup state changes are handed as signals
with StateChange. (There are some exceptions to this but
they should be only corner cases).


Modem Init Deamon


Service com.stericsson.modeminit
Interface   com.stericsson.modeminit.Modem
Object path /{modem-serial} or /

Methods
void  ResendState()

  Resends state information for all modems.
  This method must use with '/' as object path.

string GetCaifIfName()

  Returns the CAIF Link Layer interface used for
  AT channels for a specific modem. This method
  must use the same object path as used in StateChange.


Signals  StateChange(string status)

   The modems state sent from Modem Init Daemon when
   a modem state change occurs. The object path must
   be the identifier of the modem (typically
   the serial-id or IMEI of the HW).

   "booting"   Modem is powered up (flashed version)
   or Modem is powered up and firmware upload
   is completed. (flashless version)
   "upgrading" Firmware upgrade on going
   or Flashing manager under execution -
   modem in service mode.
   "on" Modem has booted and is ready for use.
   This implies that all AT channels are
   available, the modem might be in
   e.g. flight mode.
   "dumping"  Modem has crashed and dump is ongoing
   "off"   Modem is powered off.


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2010-12-21 Thread Marcel Holtmann
Hi Sjur,

> >> +
> >> +/* ResetState requests resending of StateChange. */
> >> +#define MID_RESEND_STATE "ResendState"
> >
> > This is a bad D-Bus API btw. Using a D-Bus method to trigger signal
> > sending. You will wake up any listener for that signal. What is wrong
> > with just having a GetState?
> 
> My problem is that I need to get the path, or modem serial-number if
> you like, to the
> modem(s). As I don't know the start order I have to query the state at 
> startup.
> So this will happens only once. The simples way for me to get the path is
> to send "ResendState" to path "/". This will then send the state info
> for all modem
> paths.
> 
> I don't think I have the path them available at connect...
> If you have any other ideas of how to query the modem instances I'm all ears?

I think you need to resend the D-Bus API of your init daemon. I need to
have a second look.

Regards

Marcel


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2010-12-21 Thread Sjur Brændeland
Hi Marcel.

>> +
>> +/* ResetState requests resending of StateChange. */
>> +#define MID_RESEND_STATE     "ResendState"
>
> This is a bad D-Bus API btw. Using a D-Bus method to trigger signal
> sending. You will wake up any listener for that signal. What is wrong
> with just having a GetState?

My problem is that I need to get the path, or modem serial-number if
you like, to the
modem(s). As I don't know the start order I have to query the state at startup.
So this will happens only once. The simples way for me to get the path is
to send "ResendState" to path "/". This will then send the state info
for all modem
paths.

I don't think I have the path them available at connect...
If you have any other ideas of how to query the modem instances I'm all ears?


The other is feedback makes sens to me ;-)
Thanks for review and feedback.


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


Re: [PATCHv2] plugin: Add ste modem initd integration

2010-12-21 Thread Marcel Holtmann
Hi Sjur,

> This patch introduces auto discovery of ST-Ericsson modems.
> ST-Ericsson modems (M5XX, M57XX, M7XX, M74XX) are managed by a
> Modem Init Daemon responsible for start, power cycles,
> flashing etc. This STE plugin monitors the modem state exposed
> from the Modem Init Damon's Dbus API. When the modem is in state
> "on" the STE modem is created and registered. Multiple modem
> instances, and reset handling is supported.

I don't really like on how STE, ST and TI do abbreviations these days.

It is MID for modem init daemon, it is UIM for user init manager, KIM
for kernel init manager and TI calls a shared transport ST. This will
end up in a massive confusion at some point ;)

> ---
> Changes:
> - Support for multiple STE modems.
> - Better naming of STE modem instances, using received dbus path.
> - CAIF Link layer to use for AT channels specified pr modem instance.
> - Added support for reset.
> 
>  Makefile.am  |5 +
>  configure.ac |6 +
>  plugins/stemid.c |  310 
> ++
>  3 files changed, 321 insertions(+), 0 deletions(-)
>  create mode 100644 plugins/stemid.c

Can we just call this something like stemgr for STE Manager or STE Init
Manager. The MID part is just confusing.

> diff --git a/Makefile.am b/Makefile.am
> index 12b3c33..98096ae 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -82,6 +82,11 @@ gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
>  
>  udev_files = plugins/ofono.rules
>  
> +if STE_MODEM_INITD
> +builtin_modules += stemid
> +builtin_sources += plugins/stemid.c
> +endif
> +
>  if UDEV
>  builtin_modules += udev
>  builtin_sources += plugins/udev.c
> diff --git a/configure.ac b/configure.ac
> index 5c18f68..f733fc4 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -177,6 +177,12 @@ AC_ARG_ENABLE(datafiles, 
> AC_HELP_STRING([--disable-datafiles],
>  
>  AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
>  
> +AC_ARG_ENABLE(ste_modem_initd, AC_HELP_STRING([--disable-ste-modem-initd],
> + [disable auto discovery of STE modem using modem init 
> daemon]),
> + [enable_ste_modem_initd=${enableval}])
> +
> +AM_CONDITIONAL(STE_MODEM_INITD, test "${enable_ste_modem_initd}" != "no")
> +

Don't bother with this and just always compile this in. For now that is
fine and in case we start with more fine grained control here, I will do
that on modem technology based and not on plugins.

Right now we do atmodem and isimodem. If we feel like it is needed, we
would do stemodem, but right now, I don't see it.

>  if (test "${prefix}" = "NONE"); then
>   dnl no prefix and no localstatedir, so default to /var
>   if (test "$localstatedir" = '${prefix}/var'); then
> diff --git a/plugins/stemid.c b/plugins/stemid.c
> new file mode 100644
> index 000..9f5da22
> --- /dev/null
> +++ b/plugins/stemid.c
> @@ -0,0 +1,310 @@
> +/*
> + *
> + *  oFono - Open Source Telephony
> + *
> + *  Copyright (C) 2010 ST-Ericsson AB.
> + *
> + *  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
> + *
> + */
> +
> +#ifdef HAVE_CONFIG_H
> +#include 
> +#endif
> +
> +#include 
> +#include 
> +#include 
> +
> +#include 
> +
> +#define OFONO_API_SUBJECT_TO_CHANGE
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +/*
> + * ST-Ericsson's Modem Init Daemon is used for controling the modem power
> + * cycles and provides a dbus API for modem state and properties.
> + */
> +#define MID_SERVICE  "com.stericsson.modeminit"
> +#define MID_INTERFACEMID_SERVICE ".Modem"
> +
> +/* The signal StateChange sends the modem state.*/
> +#define STATUS_CHANGED   "StateChange"
> +
> +#define MID_ACTION_ON"on"/* Modem is on */
> +#define MID_ACTION_RESET "dumping"   /* Modem is resetting */
> +#define MID_ACTION_UNKNOWN   "unknown"   /* Don't care */
> +
> +/* ResetState requests resending of StateChange. */
> +#define MID_RESEND_STATE "ResendState"

This is a bad D-Bus API btw. Using a D-Bus method to trigger signal
sending. You will wake up any listener for that signal. What is wrong
with just having a GetState?

> +/* GetCaifIfName requests the CAIF Interface Name. */
> +#define MID_GET_CAIFIF   "GetCaifIfName"
> +
> +#define TIMEOUT  5000
>

[PATCHv2] plugin: Add ste modem initd integration

2010-12-15 Thread Sjur Brændeland
From: Sjur Brændeland 

This patch introduces auto discovery of ST-Ericsson modems.
ST-Ericsson modems (M5XX, M57XX, M7XX, M74XX) are managed by a
Modem Init Daemon responsible for start, power cycles,
flashing etc. This STE plugin monitors the modem state exposed
from the Modem Init Damon's Dbus API. When the modem is in state
"on" the STE modem is created and registered. Multiple modem
instances, and reset handling is supported.
---
Changes:
- Support for multiple STE modems.
- Better naming of STE modem instances, using received dbus path.
- CAIF Link layer to use for AT channels specified pr modem instance.
- Added support for reset.

 Makefile.am  |5 +
 configure.ac |6 +
 plugins/stemid.c |  310 ++
 3 files changed, 321 insertions(+), 0 deletions(-)
 create mode 100644 plugins/stemid.c

diff --git a/Makefile.am b/Makefile.am
index 12b3c33..98096ae 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -82,6 +82,11 @@ gatchat_sources = gatchat/gatchat.h gatchat/gatchat.c \
 
 udev_files = plugins/ofono.rules
 
+if STE_MODEM_INITD
+builtin_modules += stemid
+builtin_sources += plugins/stemid.c
+endif
+
 if UDEV
 builtin_modules += udev
 builtin_sources += plugins/udev.c
diff --git a/configure.ac b/configure.ac
index 5c18f68..f733fc4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -177,6 +177,12 @@ AC_ARG_ENABLE(datafiles, 
AC_HELP_STRING([--disable-datafiles],
 
 AM_CONDITIONAL(DATAFILES, test "${enable_datafiles}" != "no")
 
+AC_ARG_ENABLE(ste_modem_initd, AC_HELP_STRING([--disable-ste-modem-initd],
+   [disable auto discovery of STE modem using modem init 
daemon]),
+   [enable_ste_modem_initd=${enableval}])
+
+AM_CONDITIONAL(STE_MODEM_INITD, test "${enable_ste_modem_initd}" != "no")
+
 if (test "${prefix}" = "NONE"); then
dnl no prefix and no localstatedir, so default to /var
if (test "$localstatedir" = '${prefix}/var'); then
diff --git a/plugins/stemid.c b/plugins/stemid.c
new file mode 100644
index 000..9f5da22
--- /dev/null
+++ b/plugins/stemid.c
@@ -0,0 +1,310 @@
+/*
+ *
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 ST-Ericsson AB.
+ *
+ *  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
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include 
+#endif
+
+#include 
+#include 
+#include 
+
+#include 
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * ST-Ericsson's Modem Init Daemon is used for controling the modem power
+ * cycles and provides a dbus API for modem state and properties.
+ */
+#define MID_SERVICE"com.stericsson.modeminit"
+#define MID_INTERFACE  MID_SERVICE ".Modem"
+
+/* The signal StateChange sends the modem state.*/
+#define STATUS_CHANGED "StateChange"
+
+#define MID_ACTION_ON  "on"/* Modem is on */
+#define MID_ACTION_RESET   "dumping"   /* Modem is resetting */
+#define MID_ACTION_UNKNOWN "unknown"   /* Don't care */
+
+/* ResetState requests resending of StateChange. */
+#define MID_RESEND_STATE   "ResendState"
+
+/* GetCaifIfName requests the CAIF Interface Name. */
+#define MID_GET_CAIFIF "GetCaifIfName"
+
+#define TIMEOUT5000
+#define STE_DRIVER_NAME"ste"
+#define STE_INTERFACE_PROPERTY "Interface"
+
+enum ste_state {
+   STE_PENDING,/* Waiting for caifif and "on" notification */
+   STE_PENDING_IF, /* Waiting for caifif, already got "on" */
+   STE_REGISTERED, /* Modem is registered */
+   STE_RESETTING   /* Modem is resetting */
+};
+
+struct ste_modem {
+   char *path;
+   struct ofono_modem *modem;
+   enum ste_state state;
+   gboolean got_caifif;
+   gboolean pending_call;
+};
+
+static GHashTable *modem_list;
+static guint mid_api_watch;
+static guint mid_state_watch;
+static DBusConnection *connection;
+
+static void get_caifif_reply(DBusPendingCall *call, void *user_data)
+{
+   DBusMessage *reply;
+   char *ifname;
+   struct ste_modem *stemodem = user_data;
+
+   stemodem->pending_call = FALSE;
+   stemodem->got_caifif = TRUE;
+   reply = dbus_pending_call_steal_reply(call);
+
+   if (dbus_message_is_error(reply, DBUS_ERROR_SERVICE_UNKNOWN)) {
+   ofono_error("STE Modem Init Daemon: unavailable");
+