Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers UBLOX_PPP.cpp Source File

UBLOX_PPP.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 "UBLOX_PPP.h"
00019 #include "AT_CellularNetwork.h"
00020 
00021 using namespace mbed;
00022 using namespace events;
00023 
00024 #ifdef UBX_MDM_SARA_R41XM
00025 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
00026     AT_CellularNetwork::RegistrationModeDisable,// C_EREG
00027     AT_CellularNetwork::RegistrationModeLAC,    // C_GREG
00028     AT_CellularNetwork::RegistrationModeLAC,    // C_REG
00029     0,  // AT_CGSN_WITH_TYPE
00030     0,  // AT_CGDATA
00031     0,  // AT_CGAUTH
00032     1,  // AT_CNMI
00033     1,  // AT_CSMP
00034     1,  // AT_CMGF
00035     0,  // AT_CSDH
00036     1,  // PROPERTY_IPV4_STACK
00037     0,  // PROPERTY_IPV6_STACK
00038     0,  // PROPERTY_IPV4V6_STACK
00039     0,  // PROPERTY_NON_IP_PDP_TYPE
00040     1,  // PROPERTY_AT_CGEREP
00041 };
00042 #elif defined(UBX_MDM_SARA_U2XX) || defined(UBX_MDM_SARA_G3XX)
00043 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
00044     AT_CellularNetwork::RegistrationModeDisable,// C_EREG
00045     AT_CellularNetwork::RegistrationModeLAC,    // C_GREG
00046     AT_CellularNetwork::RegistrationModeLAC,    // C_REG
00047 #ifdef UBX_MDM_SARA_G3XX
00048     0,  // AT_CGSN_WITH_TYPE
00049 #else
00050     1,  // AT_CGSN_WITH_TYPE
00051 #endif
00052     1,  // AT_CGDATA
00053     0,  // AT_CGAUTH
00054     1,  // AT_CNMI
00055     1,  // AT_CSMP
00056     1,  // AT_CMGF
00057     1,  // AT_CSDH
00058     1,  // PROPERTY_IPV4_STACK
00059     0,  // PROPERTY_IPV6_STACK
00060     0,  // PROPERTY_IPV4V6_STACK
00061     0,  // PROPERTY_NON_IP_PDP_TYPE
00062     1,  // PROPERTY_AT_CGEREP
00063 };
00064 #else
00065 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
00066     0,  // C_EREG
00067     0,  // C_GREG
00068     0,  // C_REG
00069     0,  // AT_CGSN_WITH_TYPE
00070     0,  // AT_CGDATA
00071     0,  // AT_CGAUTH
00072     0,  // AT_CNMI
00073     0,  // AT_CSMP
00074     0,  // AT_CMGF
00075     0,  // AT_CSDH
00076     0,  // PROPERTY_IPV4_STACK
00077     0,  // PROPERTY_IPV6_STACK
00078     0,  // PROPERTY_IPV4V6_STACK
00079     0,  // PROPERTY_NON_IP_PDP_TYPE
00080     0,  // PROPERTY_AT_CGEREP
00081 };
00082 #endif
00083 
00084 UBLOX_PPP::UBLOX_PPP(FileHandle *fh) : AT_CellularDevice(fh)
00085 {
00086     set_cellular_properties(cellular_properties);
00087 }
00088 
00089 #if MBED_CONF_UBLOX_PPP_PROVIDE_DEFAULT
00090 
00091 #if !NSAPI_PPP_AVAILABLE
00092 #error Must define lwip.ppp-enabled
00093 #endif
00094 
00095 #include "UARTSerial.h"
00096 CellularDevice *CellularDevice::get_default_instance()
00097 {
00098     static UARTSerial serial(MBED_CONF_UBLOX_PPP_TX, MBED_CONF_UBLOX_PPP_RX, MBED_CONF_UBLOX_PPP_BAUDRATE);
00099 #if defined (MBED_CONF_UBLOX_AT_RTS) && defined(MBED_CONF_UBLOX_AT_CTS)
00100     tr_debug("UBLOX_PPP flow control: RTS %d CTS %d", MBED_CONF_UBLOX_PPP_RTS, MBED_CONF_UBLOX_PPP_CTS);
00101     serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_UBLOX_PPP_RTS, MBED_CONF_UBLOX_PPP_CTS);
00102 #endif
00103     static UBLOX_PPP device(&serial);
00104     return &device;
00105 }
00106 #endif