The ofono plugin was using context path as network group identifier
which caused service path to end something like this:
/profile/default/cellular_244053111242822_huawei2_primarycontext1
But the problem here is that with certain modems (like my Huawei E1552)
the path will change every time the modem in replugged. This meant
that a new connman service was created everytime and I had to
enter APN everytime, instead of using the stored service which already
had APN correctly set.
Fix this by using only the last part from path, for example in this
case primarycontext1:
/profile/default/cellular_244053111242822_primarycontext1
Now with huawei modems the service id stays always the same as it should.
static char *get_ident(const char *path)
{
- char *ident, *pos;
+ char *pos;
if (*path != '/')
return NULL;
- ident = g_strdup(path + 1);
-
- pos = ident;
-
- while ((pos = strchr(pos, '/')) != NULL)
- *pos = '_';
+ pos = strrchr(path, '/');
+ if (pos == NULL)
+ return NULL;
- return ident;
+ return g_strdup(pos + 1);
}
static void create_service(struct connman_network *network)