Hi Daniel,

On 24/11/2011 09:24, Daniel Wagner wrote:
Hi Guillaume,

On 23.11.2011 17:55, Daniel Wagner wrote:
Hi Guillaume&  Denis,

On 23.11.2011 17:17, Guillaume Zajac wrote:
Hi Denis

On 23/11/2011 04:58, Denis Kenzior wrote:
Hi Guillaume,

Here you should do:
if (modem->device == NULL&&   has_interface(modem->interfaces,
OFONO_API_SIM) == FALSE)
          create_device(modem);

As devinfo and sim interface are created at the same time into oFono, if
you receive modem Serial and no SIM interface exists. You can use the
serial as unique identifier of your device.

This is how I would manage it for CDMA modems case but maybe it is not
the case for dunmodem :)

This is not quite true; they are created at the same time in the driver,
however the drivers can call the corresponding atom registration
functions at different times.  So there are no guarantees that that if
you have a SerialNumber and no SimManager it won't come up sometime soon.

The only guarantee you have is that SubscriberIdentity is emitted (if
relevant) before ConnectionManager interface is made available.  Which
means that if ConnectionManager is available an no SimManager is
available, then it never will be...

Yes we have to test if ConnectionManager interface is existent.
So it means if we receive modem Serial from oFono, we have a
ConnectionManager interface but no SimManager interface, then we can
create_device() with Serial.
So when we receive Serial into ofono plugin from ConnMan we should do
like this:

if (modem->device == NULL&&  has_interface(modem->interfaces,
OFONO_API_CM) == TRUE&&
                 has_interface(modem->interfaces, OFONO_API_SIM) == FALSE)
         create_device(modem);
Will change the patch accordingly.
Looking at the code again, I don't think I have to change anything:

modem_changed() {

[...]
        if (has_interface(modem->interfaces, OFONO_API_CM) == TRUE) {
                if (modem->device == NULL)
                        create_device(modem);
        } else {
                if (modem->device != NULL)
                        destroy_device(modem);
        }
[...]
}

oFono guarantees that the gprs interface will always be emitted after
the sim we just have too wait for the grps interface to appear. And that
is the point in time where we create the device.

I think your condition is even wrong in the case where we have a proper
order, e.g. modem added ->  power up ->  sim ->  gprs.
In this case we wouldn't even create the modem. The only trigger for
creating the modem should be the gprs interface appears.

And in case where the gprs interface goes away we remove the device
again. Also very simple to understand.

Though there is possibility that we end up in create_device() when we
don't have a Serial or an IMSI string. In this case we don't have an
unique identifier. Bad luck, we can't create a service (note ConnMan
doesn't crash, it handles this gracefully).

I would say we should treat this as bug somewhere in oFono and we should
not add some weird hackaround in the ofono plugin. Just report it as an
error and that's it.

In case of gsmmodem you are right, there will never be any problem because IMSI should always show up.

The problem I raised is only in case of cdmamodem and dunmodem.
I have used your patch to implement a cdmamodem solution without sim atom (e.g. using Serial) and the device was created too early. If your dun/cdmamodem is added, the ConnectionManager will be created before you received the modem Serial.

In below statement, you are not sure you have received the Serial when you create the device:

[...]
if (has_interface(modem->interfaces, OFONO_API_CM) == TRUE) {
            if (modem->device == NULL)
                create_device(modem);
}
[...]

Thus you should test if modem->serial != NULL or (not to break gsmmodem) modem->imsi != NULL
Then when you receive serial, you can create the device:

[...]
} else if (g_str_equal(key, "Serial") == TRUE) {
        char *serial;

        dbus_message_iter_get_basic(&value, &serial);

        g_free(modem->serial);
        modem->serial = g_strdup(serial);

        DBG("%s Serial %s", modem->path, modem->serial);

        if (has_interface(modem->interfaces, OFONO_API_CM)
                == TRUE) {
            if (modem->device == NULL &&
                    has_interface(modem->interfaces,
                    OFONO_API_SIM) == FALSE)
                create_device(modem);
        }
}
[...]

This is what I experimented in implementing cdmamodem solution when there is no SIM interface. Maybe you receive early enough the Serial for dunmodem and you don't have this issue, in this case I will put such implementation into cdmamodem solution.

Kind regards,
Guillaume
_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to