Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers QUECTEL_BG96_CellularNetwork.cpp Source File

QUECTEL_BG96_CellularNetwork.cpp

00001 /*
00002  * Copyright (c) 2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #include "QUECTEL/BG96/QUECTEL_BG96_CellularNetwork.h"
00019 #include "QUECTEL/BG96/QUECTEL_BG96_CellularStack.h"
00020 
00021 using namespace mbed;
00022 
00023 QUECTEL_BG96_CellularNetwork::QUECTEL_BG96_CellularNetwork(ATHandler &atHandler) : AT_CellularNetwork(atHandler)
00024 {
00025 }
00026 
00027 QUECTEL_BG96_CellularNetwork::~QUECTEL_BG96_CellularNetwork()
00028 {
00029 }
00030 
00031 bool QUECTEL_BG96_CellularNetwork::get_modem_stack_type(nsapi_ip_stack_t requested_stack)
00032 {
00033     if ((requested_stack == IPV4_STACK) ||
00034         (requested_stack == IPV6_STACK) ||
00035         (requested_stack == IPV4V6_STACK)) {
00036         return true;
00037     }
00038 
00039     return false;
00040 }
00041 
00042 NetworkStack *QUECTEL_BG96_CellularNetwork::get_stack()
00043 {
00044     if (!_stack) {
00045         _stack = new QUECTEL_BG96_CellularStack(_at, _cid, _ip_stack_type);
00046     }
00047     return _stack;
00048 }
00049 
00050 nsapi_error_t QUECTEL_BG96_CellularNetwork::set_access_technology_impl(operator_t::RadioAccessTechnology opsAct)
00051 {
00052     _at.lock();
00053 
00054     switch (opsAct) {
00055         case operator_t::RAT_CATM1:
00056             _at.cmd_start("AT+QCFG=\"nwscanseq\",020301");
00057             _at.cmd_stop();
00058             _at.resp_start();
00059             _at.resp_stop();
00060             _at.cmd_start("AT+QCFG=\"nwscanmode\",3,1");
00061             _at.cmd_stop();
00062             _at.resp_start();
00063             _at.resp_stop();
00064             _at.cmd_start("AT+QCFG=\"iotopmode\",0,1");
00065             _at.cmd_stop();
00066             _at.resp_start();
00067             _at.resp_stop();
00068             break;
00069         case operator_t::RAT_NB1:
00070             _at.cmd_start("AT+QCFG=\"nwscanseq\",030201");
00071             _at.cmd_stop();
00072             _at.resp_start();
00073             _at.resp_stop();
00074             _at.cmd_start("AT+QCFG=\"nwscanmode\",3,1");
00075             _at.cmd_stop();
00076             _at.resp_start();
00077             _at.resp_stop();
00078             _at.cmd_start("AT+QCFG=\"iotopmode\",1,1");
00079             _at.cmd_stop();
00080             _at.resp_start();
00081             _at.resp_stop();
00082             break;
00083         case operator_t::RAT_GSM:
00084         case operator_t::RAT_GSM_COMPACT:
00085         case operator_t::RAT_UTRAN:
00086         case operator_t::RAT_EGPRS:
00087             _at.cmd_start("AT+QCFG=\"nwscanseq\",010203");
00088             _at.cmd_stop();
00089             _at.resp_start();
00090             _at.resp_stop();
00091             _at.cmd_start("AT+QCFG=\"nwscanmode\",1,1");
00092             _at.cmd_stop();
00093             _at.resp_start();
00094             _at.resp_stop();
00095             break;
00096         default:
00097             _at.cmd_start("AT+QCFG=\"nwscanseq\",020301");
00098             _at.cmd_stop();
00099             _at.resp_start();
00100             _at.resp_stop();
00101             _at.cmd_start("AT+QCFG=\"nwscanmode\",0,1"); //auto mode
00102             _at.cmd_stop();
00103             _at.resp_start();
00104             _at.resp_stop();
00105             _at.cmd_start("AT+QCFG=\"iotopmode\",2,1"); //auto mode
00106             _at.cmd_stop();
00107             _at.resp_start();
00108             _at.resp_stop();
00109             _at.unlock();
00110             _op_act = operator_t::RAT_UNKNOWN;
00111             return NSAPI_ERROR_UNSUPPORTED ;
00112     }
00113 
00114     return _at.unlock_return_error();
00115 }