Knight KE / Mbed OS Game_Master
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         return true;
00035     }
00036 
00037     return false;
00038 }
00039 
00040 NetworkStack *QUECTEL_BG96_CellularNetwork::get_stack()
00041 {
00042     if (!_stack) {
00043         _stack = new QUECTEL_BG96_CellularStack(_at, _cid, _ip_stack_type);
00044     }
00045     return _stack;
00046 }
00047 
00048 nsapi_error_t QUECTEL_BG96_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
00049 {
00050     _at.lock();
00051 
00052     switch (opsAct) {
00053         case RAT_CATM1:
00054             _at.cmd_start("AT+QCFG=\"nwscanseq\",020301");
00055             _at.cmd_stop();
00056             _at.resp_start();
00057             _at.resp_stop();
00058             _at.cmd_start("AT+QCFG=\"nwscanmode\",3,1");
00059             _at.cmd_stop();
00060             _at.resp_start();
00061             _at.resp_stop();
00062             _at.cmd_start("AT+QCFG=\"iotopmode\",0,1");
00063             _at.cmd_stop();
00064             _at.resp_start();
00065             _at.resp_stop();
00066             break;
00067         case RAT_NB1:
00068             _at.cmd_start("AT+QCFG=\"nwscanseq\",030201");
00069             _at.cmd_stop();
00070             _at.resp_start();
00071             _at.resp_stop();
00072             _at.cmd_start("AT+QCFG=\"nwscanmode\",3,1");
00073             _at.cmd_stop();
00074             _at.resp_start();
00075             _at.resp_stop();
00076             _at.cmd_start("AT+QCFG=\"iotopmode\",1,1");
00077             _at.cmd_stop();
00078             _at.resp_start();
00079             _at.resp_stop();
00080             break;
00081         case RAT_GSM:
00082         case RAT_GSM_COMPACT:
00083         case RAT_UTRAN:
00084         case RAT_EGPRS:
00085             _at.cmd_start("AT+QCFG=\"nwscanseq\",010203");
00086             _at.cmd_stop();
00087             _at.resp_start();
00088             _at.resp_stop();
00089             _at.cmd_start("AT+QCFG=\"nwscanmode\",1,1");
00090             _at.cmd_stop();
00091             _at.resp_start();
00092             _at.resp_stop();
00093             break;
00094         default:
00095             _at.cmd_start("AT+QCFG=\"nwscanseq\",020301");
00096             _at.cmd_stop();
00097             _at.resp_start();
00098             _at.resp_stop();
00099             _at.cmd_start("AT+QCFG=\"nwscanmode\",0,1"); //auto mode
00100             _at.cmd_stop();
00101             _at.resp_start();
00102             _at.resp_stop();
00103             _at.cmd_start("AT+QCFG=\"iotopmode\",2,1"); //auto mode
00104             _at.cmd_stop();
00105             _at.resp_start();
00106             _at.resp_stop();
00107             _at.unlock();
00108             _op_act = RAT_UNKNOWN;
00109             return NSAPI_ERROR_UNSUPPORTED ;
00110     }
00111 
00112     return _at.unlock_return_error();
00113 }