Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cellular: Make AT_CellularContext::get_context() virtual #10442

Merged
merged 2 commits into from May 24, 2019

Conversation

Projects
None yet
10 participants
@trowbridgec
Copy link
Contributor

commented Apr 18, 2019

Description

I have observed that some cell modules (namely the Telit ME910C1) pre-fill the contexts with dummy values. When the current get_context() function calls the AT+CGDCONT? command, the module responds with 6 already populated dummy contexts. For example:

AT+CGDCONT?<cr><cr><ln>
+CGDCONT: 1,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 2,"IPV4V6","ims","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 3,"IPV4V6","sos","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,1<cr><ln>
+CGDCONT: 4,"IPV4V6","attm2mglobal","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 5,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 6,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
<cr><ln>
OK<cr><ln>

I would expect the get_context() function to select and overwrite the 1st context, but instead cycles through all of the contexts, rejects them all (none of them match the target APN for my SIM), and tries to create a 7th. This then throws an error since the ME910C1 only supports 6 contexts.

Therefore, I propose making the get_context() function virtual and overwrite-able by the individual cell module driver authors (similar to what is available for other AT_CellularContext functions, like do_connect()), which is what this PR enables.

Pull request type

[ ] Fix
[ ] Refactor
[ ] Target update
[x] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

Release Notes

Makes AT_CellularContext::get_context() virtual - overwrite-able by the individual cell module driver authors (similar to what is available for other AT_CellularContext functions, like do_connect()).

@loverdeg-ep

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

@loverdeg-ep

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

@loverdeg-ep

This comment has been minimized.

Copy link
Contributor

commented Apr 18, 2019

@ciarmcom ciarmcom requested review from ARMmbed/mbed-os-maintainers Apr 18, 2019

@ciarmcom

This comment has been minimized.

Copy link
Member

commented Apr 18, 2019

@trowbridgec, thank you for your changes.
@ARMmbed/mbed-os-wan @ARMmbed/mbed-os-maintainers please review.

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented Apr 23, 2019

@trowbridgec do you have a log with AT debug to see why the first APN is not selected?

I'm guessing your problem might be due to the automatic APN lookup, which you could try to disable in mbed_app.json:

            "ppp-cell-iface.apn-lookup": false,
            "cellular.use-apn-lookup": false,
@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

@AriParkkila

I'm trying out your suggestion on the APN lookup now.

In the mean time, below is an AT log from when I see this issue. It looks like it asks the module what contexts are configured, doesn't match to any of them, decides to create a new one (a 7th one), and then gets rejected because the module only supports 6 contexts. I would expect/hope that it would realize the first context has an empty APN and use with that one.

BTW, the APN we're using is "11583.mcs".

[INFO][CELL]: AT TX (11): AT+CGDCONT?
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (12): AT+CGDCONT?<cr>
[INFO][CELL]: AT RX ( 4): <cr><ln>+C
[INFO][CELL]: AT RX (14): GDCONT: 1,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX (16): 0<cr><ln>+CGDCONT: 2,"
[INFO][CELL]: AT RX (16): IPV4V6","ims","0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0",
[INFO][CELL]: AT RX (16): 0,0,0,0<cr><ln>+CGDCON
[INFO][CELL]: AT RX ( 9): T: 3,"IPV
[INFO][CELL]: AT RX (16): 4V6","sos","0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0",0,0
[INFO][CELL]: AT RX (16): ,0,1<cr><ln>+CGDCONT:
[INFO][CELL]: AT RX (16): 4,"IPV4V6","attm
[INFO][CELL]: AT RX (16): 2mglobal","0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0",0,0,
[INFO][CELL]: AT RX (16): 0,0<cr><ln>+CGDCONT: 5
[INFO][CELL]: AT RX (16): ,"IPV4V6","","0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0",0
[INFO][CELL]: AT RX (16): ,0,0,0<cr><ln>+CGDCONT
[INFO][CELL]: AT RX ( 8): : 6,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX ( 9): 0<cr><ln><cr><ln>OK<cr><ln>
[INFO][CELL]: AT TX (11): AT+CGDCONT=
[INFO][CELL]: AT TX ( 1): 7
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 6): IPV4V6
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 9): 11583.mcs
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (16): AT+CGDCONT=7,"IP
[INFO][CELL]: AT RX (16): V4V6","11583.mcs
[INFO][CELL]: AT RX (11): "<cr><cr><ln>ERROR<cr><ln>
[INFO][CELL]: AT RX (11): <cr><ln>+PACSP0<cr><ln>
[INFO][CELL]: AT RX ( 1): <cr>
[INFO][CELL]: AT RX (10): <ln>+PACSP0<cr><ln>
[INFO][CELL]: AT RX ( 9): <cr><ln>+PACSP0
[INFO][CELL]: AT RX ( 2): <cr><ln>
[INFO][CELL]: AT RX (11): <cr><ln>+PACSP0<cr><ln>
[WARN][CELL]: AT timeout
[DBG ][CELL]: AT error -3012
[DBG ][CELL]: consume_to_tag not found
[DBG ][CELL]: AT stop tag not found
[DBG ][CELL]: AT error -3012
[ERR ][CELL]: Failed to activate network context! (-3004)
Unable to connect to network (-3004). Retrying...
[INFO][CELL]: CellularContext connect
[INFO][CELL]: AT TX (11): AT+CGDCONT?
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (12): AT+CGDCONT?<cr>
[INFO][CELL]: AT RX ( 4): <cr><ln>+C
[INFO][CELL]: AT RX (14): GDCONT: 1,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX (16): 0<cr><ln>+CGDCONT: 2,"
[INFO][CELL]: AT RX (16): IPV4V6","ims","0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0",
[INFO][CELL]: AT RX (16): 0,0,0,0<cr><ln>+CGDCON
[INFO][CELL]: AT RX ( 9): T: 3,"IPV
[INFO][CELL]: AT RX (16): 4V6","sos","0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0",0,0
[INFO][CELL]: AT RX (16): ,0,1<cr><ln>+CGDCONT:
[INFO][CELL]: AT RX (16): 4,"IPV4V6","attm
[INFO][CELL]: AT RX (16): 2mglobal","0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0",0,0,
[INFO][CELL]: AT RX (16): 0,0<cr><ln>+CGDCONT: 5
[INFO][CELL]: AT RX (16): ,"IPV4V6","","0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0",0
[INFO][CELL]: AT RX (16): ,0,0,0<cr><ln>+CGDCONT
[INFO][CELL]: AT RX ( 8): : 6,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX ( 9): 0<cr><ln><cr><ln>OK<cr><ln>
[INFO][CELL]: AT TX (11): AT+CGDCONT=
[INFO][CELL]: AT TX ( 1): 7
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 6): IPV4V6
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 9): 11583.mcs
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (16): AT+CGDCONT=7,"IP
[INFO][CELL]: AT RX (16): V4V6","11583.mcs
[INFO][CELL]: AT RX (11): "<cr><cr><ln>ERROR<cr><ln>
@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

@AriParkkila

After adding the suggested settings to mbed_app.json, I still get the same error:

...
[DBG ][CELL]: +CEREG: RegisteredHomeNetwork, LAC -1, cell -1, RAT unknown
[INFO][CELL]: AT RX ( 3): K<cr><ln>
[DBG ][CELL]: callback: 4098, err: 0, data: 1
[INFO][CELL]: Registering network => Attaching network
[INFO][CELL]: AT TX ( 6): AT+CSQ
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX ( 8): AT+CSQ<cr><cr>
[INFO][CELL]: AT RX ( 8): <ln>+CSQ: 2
[INFO][CELL]: AT RX (11): 1,5<cr><ln><cr><ln>OK<cr><ln>
[INFO][CELL]: RSSI -71 dBm
[INFO][CELL]: Attaching network (timeout 60 s)
[INFO][CELL]: AT TX ( 9): AT+CGATT?
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (11): AT+CGATT?<cr><cr>
[INFO][CELL]: AT RX ( 5): <ln>+CGA
[INFO][CELL]: AT RX (12): TT: 1<cr><ln><cr><ln>OK<cr>
[INFO][CELL]: AT RX ( 1): <ln>
[DBG ][CELL]: callback: 4102, err: 0, data: 1
[INFO][CELL]: AT TX (11): AT+CGDCONT?
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (12): AT+CGDCONT?<cr>
[INFO][CELL]: AT RX ( 4): <cr><ln>+C
[INFO][CELL]: AT RX (14): GDCONT: 1,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX (16): 0<cr><ln>+CGDCONT: 2,"
[INFO][CELL]: AT RX (16): IPV4V6","ims","0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0",
[INFO][CELL]: AT RX (16): 0,0,0,0<cr><ln>+CGDCON
[INFO][CELL]: AT RX ( 9): T: 3,"IPV
[INFO][CELL]: AT RX (16): 4V6","sos","0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0",0,0
[INFO][CELL]: AT RX (16): ,0,1<cr><ln>+CGDCONT:
[INFO][CELL]: AT RX (16): 4,"IPV4V6","attm
[INFO][CELL]: AT RX (16): 2mglobal","0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0",0,0,
[INFO][CELL]: AT RX (16): 0,0<cr><ln>+CGDCONT: 5
[INFO][CELL]: AT RX (16): ,"IPV4V6","","0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0.0.
[INFO][CELL]: AT RX (16): 0.0.0.0.0.0.0",0
[INFO][CELL]: AT RX (16): ,0,0,0<cr><ln>+CGDCONT
[INFO][CELL]: AT RX ( 8): : 6,"IPV
[INFO][CELL]: AT RX (16): 4V6","","0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0.0.0.0.0
[INFO][CELL]: AT RX (16): .0.0.0.0",0,0,0,
[INFO][CELL]: AT RX ( 9): 0<cr><ln><cr><ln>OK<cr><ln>
[INFO][CELL]: AT TX (11): AT+CGDCONT=
[INFO][CELL]: AT TX ( 1): 7
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 6): IPV4V6
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): ,
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 9): 11583.mcs
[INFO][CELL]: AT TX ( 1): "
[INFO][CELL]: AT TX ( 1): <cr>
[INFO][CELL]: AT RX (16): AT+CGDCONT=7,"IP
[INFO][CELL]: AT RX (16): V4V6","11583.mcs
[INFO][CELL]: AT RX (11): "<cr><cr><ln>ERROR<cr><ln>
[WARN][CELL]: AT timeout
[DBG ][CELL]: AT error -3012
[DBG ][CELL]: consume_to_tag not found
[DBG ][CELL]: AT stop tag not found
[DBG ][CELL]: AT error -3012
[ERR ][CELL]: Failed to activate network context! (-3004)
Unable to connect to network (-3004). Retrying...
...

If I tweak the get_context() function to always use context 1 (probably not ideal for all modules, but a good test for my case), the module connects and receives an IP just fine.

Any other ideas?

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented Apr 25, 2019

@trowbridgec you need to clear existing contexts, e.g. add temporarily this code to make cleanup:

bool AT_CellularContext::get_context()
{
  for (int i=0; i<7; i++) {
    _at.cmd_start("AT+CGDCONT=");
    _at.write_int(i);
    _at.cmd_stop();
    _at.resp_start();
    _at.resp_stop();
    _at.clear_error();
  }
@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented Apr 25, 2019

@AriParkkila Adding the tweak to clear out the contexts before choosing one seems to have worked; however, in order to add this change, wouldn't I still need to be able to write my own implementation of the get_context() function?

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2019

@trowbridgec The problem was likely that there were too many existing contexts. After that cleanup tweak was once executed those extra contexts were removed. It should work fine without that cleanup tweak now due to Mbed cellular framework should clear any new contexts that it creates.

@loverdeg-ep

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2019

@AriParkkila

I'm not up to speed with this topic. But I believe we were seeing the issue with a number of ME910 modules.

I wasn't sure if they shipped that way or if the driver had been adding the extra profiles.

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented Apr 29, 2019

@loverdeg-ep could you implement some recovery code at your application, e.g. for APN cleanup:

void clean_context() {
  ATHandler *at = CellularDevice::get_default_instance->get_at_handler();
  for (int i=0; i<7; i++) {
    at->cmd_start("AT+CGDCONT=");
    at->write_int(i);
    at->cmd_stop();
    at->resp_start();
    at->resp_stop();
    at->clear_error();
  }
  CellularDevice::get_default_instance->release_at_handler(at);
}
@40Grit

This comment has been minimized.

Copy link

commented Apr 29, 2019

@AriParkilla it would need to be part of our BSP or factory code.

Being a solution & design services provider we do everything we can not to push any workarounds upto the application level. This would burden the application writer otherwise.

Not necessarily saying this MR needs to make it into the OS. Maybe a better solution will appear as we gain deeper understanding of the module.

@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented Apr 29, 2019

@AriParkkila I think you're right that the issue was just that there were too many contexts already populated, but as @loverdeg-ep pointed out, we are seeing this on some ME910s and not others (it isn't just an isolated incident on one board).

I agree that this might not be the best solution moving forward; how do you feel about a change where the get_context() function only rejects a context if it's APN length is greater than 0?

bool AT_CellularContext::get_context()
{
...

    while (_at.info_resp()) {
        int cid = _at.read_int();
        if (cid > cid_max) {
            cid_max = cid;
        }
        char pdp_type_from_context[10];
        int pdp_type_len = _at.read_string(pdp_type_from_context, sizeof(pdp_type_from_context) - 1);
        if (pdp_type_len > 0) {
            apn_len = _at.read_string(apn, sizeof(apn) - 1);
            if (apn_len >= 0) {
                if (_apn && apn_len > 0 && (strcmp(apn, _apn) != 0)) { // <- add check here for length of apn
                    continue;
                }

                // APN matched -> Check PDP type
                pdp_type_t pdp_type = string_to_pdp_type(pdp_type_from_context);

                // Accept exact matching PDP context type or dual PDP context for IPv4/IPv6 only modems
                if (get_property(pdp_type_t_to_cellular_property(pdp_type)) ||
                        ((pdp_type == IPV4V6_PDP_TYPE && (modem_supports_ipv4 || modem_supports_ipv6)) && !_nonip_req)) {
                    _pdp_type = pdp_type;
                    _cid = cid;
                }
            }
        }
    }

...
}
@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented Apr 30, 2019

@trowbridgec It doesn't sound good to ignore APN if given, and you probably shouldn't define APN at all in that case.

@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented Apr 30, 2019

@AriParkkila apn here is the current APN value for the context we're looking at (get_context() loops through the results of the AT+CGDCONT? command, which to my understanding, returns the states of the module's contexts).

So, my argument is that if a context exists but has an APN of an empty string (apn_length == 0), it is unused, and it is acceptable to use it.

@loverdeg-ep

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

@AriParkkila any further thoughts?

@trowbridgec trowbridgec changed the title Make AT_CellularContext::get_context() virtual Cellular: Make AT_CellularContext::get_context() virtual May 2, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

commented May 3, 2019

@ARMmbed/mbed-os-wan Can we progress here?

@40Grit

This comment has been minimized.

Copy link

commented May 3, 2019

Yes please. Embedded Planet is a partner and is attempting to get an Mbed based Pelion ready product launched.

@maclobdell

@maclobdell

This comment has been minimized.

Copy link
Contributor

commented May 3, 2019

@AriParkkila Can you comment on this PR and/or the proposed alternative workaround? It seems that if this function was virtual and allowed to be overridden, that could allow flexibility for specific cellular module drivers.

Also, please comment about why overwriting an APN with length of 0 could be a problem.

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented May 6, 2019

@maclobdell virtual getcontext() is fine, I just wanted to understand the root cause :)

Do you mean that when APN is "", that is accepted match to any APN in json setup?

@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented May 6, 2019

From my understanding, the purpose of the get_context() function is to provide the function caller with the next, available context. So, I guess my question would be, in your opinion, is it appropriate to modify the get_context() function to consider a context that currently has an empty string for the APN setting (as returned by the AT+CGDCONT? command) 'available' for use? Essentially, can we change the logic to return as valid a context that has no assigned APN?

If yes, then I'd vote we make that change instead.

If no, then I'd vote we make the get_context() function virtual as this change will need to be made to support some modules (e.g. the Telit ME910).

@adbridge

This comment has been minimized.

Copy link
Contributor

commented May 17, 2019

@AriParkkila are you happy with @trowbridgec comments ?

@40Grit

This comment has been minimized.

Copy link

commented May 17, 2019

@adbridge your issue bumps have been sorely needed. Thank you.

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented May 17, 2019

a context that currently has an empty string for the APN setting (as returned by the AT+CGDCONT? command) 'available' for use

@trowbridgec I'm not quite following here... If you don't require any named APN then get_context should be happy to give any. If you have set APN then get_context should give only APN which has a matching name.

@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented May 17, 2019

@AriParkkila maybe I'm not explaining the issue properly.

When the mbed ATHandler calls the AT+CGDCONT? command, the cell module replies with this list of available contexts:

+CGDCONT: 1,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 2,"IPV4V6","ims","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 3,"IPV4V6","sos","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,1<cr><ln>
+CGDCONT: 4,"IPV4V6","attm2mglobal","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 5,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>
+CGDCONT: 6,"IPV4V6","","0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0",0,0,0,0<cr><ln>

The APN that I am trying to use is 11583.mcs which you can see is not one of contexts listed. So, I have just been using context 1 (which shows an empty string as the APN), and everything works fine.

The current logic from the get_context() function tries to match the APN configured in the mbed_app.json file to one of the contexts returned from the AT+CGDCONT? command. If it can't find it, it tries to create a new context with that APN. My cell module only supports up to 6 contexts, so creating a new context returns an error. If I change the logic of the get_context() function to return an unused context (e.g. context 1 in the example above which has no APN assigned to it), I was able to connect without issue.

@maclobdell

This comment has been minimized.

Copy link
Contributor

commented May 19, 2019

@AriParkkila @AnttiKauppila Please let us know if this request is clear to you. Can the logic change to get an unused context?

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented May 20, 2019

@trowbridgec I'm not sure... Would it be better to have getter for a list of APNs from which you could select one? Another (not so optimal) way would be first try to connect with a named APN and in case unsuccessful with a void APN?

@trowbridgec

This comment has been minimized.

Copy link
Contributor Author

commented May 23, 2019

@AriParkkila Would the list of APNs be generated from the APN database (i.e. APN_db.h) or from the results of the AT+CGDCONT? call? From the APN database wouldn't be ideal because it seems to be rather sparse (e.g. the APN for my SIM cards/cellular provider is not in there and neither are some big names like Verizon in the US).

I think the 2nd method might be ok. I have seen that some of our modules will somtimes come up with the correct APN name in one of the contexts (I'm assuming it's because the module itself remembers the last used APN?), so I think the logic to first attempt to connect via a named APN is valid.

Do you want me to update my PR to meet your second suggestion?

@AriParkkila

This comment has been minimized.

Copy link
Contributor

commented May 23, 2019

@trowbridgec That sounds good, but now as I see what you try to achieve virtual get_context() might be the simplest way to do it :)

@0xc0170 0xc0170 added needs: CI and removed needs: review labels May 23, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

commented May 23, 2019

I updated "Release Notes" to contain bit more details.

CI started

@mbed-ci

This comment has been minimized.

Copy link

commented May 23, 2019

Test run: SUCCESS

Summary: 11 of 11 test jobs passed
Build number : 1
Build artifacts

@0xc0170 0xc0170 added needs: review and removed needs: CI labels May 23, 2019

@0xc0170

This comment has been minimized.

Copy link
Member

commented May 23, 2019

@AnttiKauppila Please review this functionality change

@0xc0170 0xc0170 merged commit a434583 into ARMmbed:master May 24, 2019

26 checks passed

continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci/build-ARM Success
Details
jenkins-ci/build-GCC_ARM Success
Details
jenkins-ci/build-IAR Success
Details
jenkins-ci/cloud-client-test Success
Details
jenkins-ci/dynamic-memory-usage Success
Details
jenkins-ci/exporter Success
Details
jenkins-ci/greentea-test Success
Details
jenkins-ci/mbed2-build-ARM Success
Details
jenkins-ci/mbed2-build-GCC_ARM Success
Details
jenkins-ci/mbed2-build-IAR Success
Details
jenkins-ci/unittests Success
Details
travis-ci/astyle Success!
Details
travis-ci/docs Success!
Details
travis-ci/doxy-spellcheck Success!
Details
travis-ci/events Success! Runtime is 8651 cycles.
Details
travis-ci/gitattributestest Success!
Details
travis-ci/include_check Success!
Details
travis-ci/licence_check Success!
Details
travis-ci/littlefs Success! Code size is 8448B.
Details
travis-ci/psa-autogen Success!
Details
travis-ci/tools-py2.7 Success!
Details
travis-ci/tools-py3.5 Success!
Details
travis-ci/tools-py3.6 Success!
Details
travis-ci/tools-py3.7 Success!
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.