mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			Make MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP default in mbed_lib.json while
ensuring that, if there is a user-specified APN, it is still used.pull/6166/head
							parent
							
								
									1d1eef47ff
								
							
						
					
					
						commit
						2fe3223612
					
				| 
						 | 
				
			
			@ -53,7 +53,6 @@
 | 
			
		|||
#endif //MBED_CONF_PPP_CELL_IFACE_AT_PARSER_TIMEOUT
 | 
			
		||||
 | 
			
		||||
static bool initialized;
 | 
			
		||||
static bool set_credentials_api_used;
 | 
			
		||||
static bool set_sim_pin_check_request;
 | 
			
		||||
static bool change_pin;
 | 
			
		||||
static device_info dev_info;
 | 
			
		||||
| 
						 | 
				
			
			@ -257,7 +256,7 @@ PPPCellularInterface::PPPCellularInterface(FileHandle *fh, bool debug)
 | 
			
		|||
    _new_pin = NULL;
 | 
			
		||||
    _pin = NULL;
 | 
			
		||||
    _at = NULL;
 | 
			
		||||
    _apn = "internet";
 | 
			
		||||
    _apn = NULL;
 | 
			
		||||
    _uname = NULL;
 | 
			
		||||
    _pwd = NULL;
 | 
			
		||||
    _fh = fh;
 | 
			
		||||
| 
						 | 
				
			
			@ -505,11 +504,8 @@ void  PPPCellularInterface::set_credentials(const char *apn, const char *uname,
 | 
			
		|||
    _apn = apn;
 | 
			
		||||
    _uname = uname;
 | 
			
		||||
    _pwd = pwd;
 | 
			
		||||
    set_credentials_api_used = true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void PPPCellularInterface::setup_at_parser()
 | 
			
		||||
{
 | 
			
		||||
    if (_at) {
 | 
			
		||||
| 
						 | 
				
			
			@ -542,20 +538,15 @@ nsapi_error_t PPPCellularInterface::connect(const char *sim_pin, const char *apn
 | 
			
		|||
        return NSAPI_ERROR_PARAMETER;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (apn) {
 | 
			
		||||
        _apn = apn;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (uname && pwd) {
 | 
			
		||||
        _uname = uname;
 | 
			
		||||
        _pwd = pwd;
 | 
			
		||||
    } else {
 | 
			
		||||
        _uname = NULL;
 | 
			
		||||
        _pwd = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    _pin = sim_pin;
 | 
			
		||||
 | 
			
		||||
    if (apn) {
 | 
			
		||||
        if (pwd && !uname) {
 | 
			
		||||
            return NSAPI_ERROR_PARAMETER;
 | 
			
		||||
        }
 | 
			
		||||
        set_credentials(apn, uname, pwd);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return connect();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -565,6 +556,20 @@ nsapi_error_t PPPCellularInterface::connect()
 | 
			
		|||
    bool success;
 | 
			
		||||
    bool did_init = false;
 | 
			
		||||
    const char *apn_config = NULL;
 | 
			
		||||
    bool user_specified_apn = false;
 | 
			
		||||
 | 
			
		||||
    /* If the user has specified the APN then use that or,
 | 
			
		||||
     * if we are not using the APN database, set _apn to
 | 
			
		||||
     * "internet" as a best guess
 | 
			
		||||
     */
 | 
			
		||||
    if (_apn) {
 | 
			
		||||
        user_specified_apn = true;
 | 
			
		||||
    } else {
 | 
			
		||||
#ifndef MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
 | 
			
		||||
        _apn = "internet";
 | 
			
		||||
        user_specified_apn = true;
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    if (is_connected()) {
 | 
			
		||||
        return NSAPI_ERROR_IS_CONNECTED;
 | 
			
		||||
| 
						 | 
				
			
			@ -580,7 +585,6 @@ nsapi_error_t PPPCellularInterface::connect()
 | 
			
		|||
    do {
 | 
			
		||||
        retry_init:
 | 
			
		||||
 | 
			
		||||
        
 | 
			
		||||
        retcode = NSAPI_ERROR_OK;
 | 
			
		||||
 | 
			
		||||
        /* setup AT parser */
 | 
			
		||||
| 
						 | 
				
			
			@ -643,7 +647,7 @@ nsapi_error_t PPPCellularInterface::connect()
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
#if MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP
 | 
			
		||||
            if (apn_config) {
 | 
			
		||||
            if (!user_specified_apn && apn_config) {
 | 
			
		||||
                _apn = _APN_GET(apn_config);
 | 
			
		||||
                _uname = _APN_GET(apn_config);
 | 
			
		||||
                _pwd = _APN_GET(apn_config);
 | 
			
		||||
| 
						 | 
				
			
			@ -672,6 +676,8 @@ nsapi_error_t PPPCellularInterface::connect()
 | 
			
		|||
            success = _at->send("AT") && _at->recv("OK");
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        tr_info("The APN being used is %s.\n", _apn);
 | 
			
		||||
        
 | 
			
		||||
        /* Attempt to enter data mode */
 | 
			
		||||
        success = set_atd(_at); //enter into Data mode with the modem
 | 
			
		||||
        if (!success) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
	"name": "ppp-cell-iface", 
 | 
			
		||||
		"config": {
 | 
			
		||||
			"baud-rate": 115200,
 | 
			
		||||
			"apn-lookup": false,
 | 
			
		||||
			"apn-lookup": true,
 | 
			
		||||
			"at-parser-buffer-size": 256,
 | 
			
		||||
			"at-parser-timeout": 8000
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue