Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

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_CellularNetwork.h"
00019 #include "QUECTEL_BG96_CellularStack.h"
00020 #include "CellularLog.h"
00021 
00022 using namespace mbed;
00023 
00024 QUECTEL_BG96_CellularNetwork::QUECTEL_BG96_CellularNetwork(ATHandler &atHandler, AT_CellularDevice &device) : AT_CellularNetwork(atHandler, device)
00025 {
00026 }
00027 
00028 QUECTEL_BG96_CellularNetwork::~QUECTEL_BG96_CellularNetwork()
00029 {
00030 }
00031 
00032 nsapi_error_t QUECTEL_BG96_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opsAct)
00033 {
00034     _at.lock();
00035 
00036     switch (opsAct) {
00037         case RAT_CATM1:
00038             _at.at_cmd_discard("+QCFG", "=\"nwscanseq\",020301");
00039             _at.at_cmd_discard("+QCFG", "=\"nwscanmode\",3,1");
00040             _at.at_cmd_discard("+QCFG", "=\"iotopmode\",0,1");
00041             break;
00042         case RAT_NB1:
00043             _at.at_cmd_discard("+QCFG", "=\"nwscanseq\",030201");
00044             _at.at_cmd_discard("+QCFG", "=\"nwscanmode\",3,1");
00045             _at.at_cmd_discard("+QCFG", "=\"iotopmode\",1,1");
00046 #ifdef MBED_CONF_CELLULAR_OFFLOAD_DNS_QUERIES
00047             // enable ePCO IE for DNS address
00048             _at.cmd_start("AT+QNVFW=");
00049             _at.write_string("/nv/item_files/modem/nas/nas_ciot_capability_config");
00050             _at.write_string("0101", false);
00051 #endif
00052             break;
00053         case RAT_GSM:
00054         case RAT_GSM_COMPACT:
00055         case RAT_UTRAN:
00056         case RAT_EGPRS:
00057             _at.at_cmd_discard("+QCFG", "=\"nwscanseq\",010203");
00058             _at.at_cmd_discard("+QCFG", "=\"nwscanmode\",1,1");
00059             break;
00060         default:
00061             _at.at_cmd_discard("+QCFG", "=\"nwscanseq\",020301");
00062             _at.at_cmd_discard("+QCFG", "=\"nwscanmode\",0,1");
00063             _at.at_cmd_discard("+QCFG", "=\"iotopmode\",2,1");
00064 
00065             _at.unlock();
00066             _op_act = RAT_UNKNOWN;
00067             return NSAPI_ERROR_UNSUPPORTED ;
00068     }
00069 
00070     return _at.unlock_return_error();
00071 }
00072 
00073 void QUECTEL_BG96_CellularNetwork::get_context_state_command()
00074 {
00075     // read active contexts
00076     _at.cmd_start_stop("+QIACT", "?");
00077     _at.resp_start("+QIACT:");
00078 }
00079