Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TELIT_HE910.cpp Source File

TELIT_HE910.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 "TELIT_HE910.h"
00019 #include "AT_CellularNetwork.h"
00020 
00021 using namespace mbed;
00022 using namespace events;
00023 
00024 static const intptr_t cellular_properties[AT_CellularDevice::PROPERTY_MAX] = {
00025     AT_CellularNetwork::RegistrationModeDisable,// C_EREG
00026     AT_CellularNetwork::RegistrationModeLAC,    // C_GREG
00027     AT_CellularNetwork::RegistrationModeLAC,    // C_REG
00028     0,  // AT_CGSN_WITH_TYPE
00029     1,  // AT_CGDATA
00030     0,  // AT_CGAUTH
00031     1,  // AT_CNMI
00032     1,  // AT_CSMP
00033     1,  // AT_CMGF
00034     1,  // AT_CSDH
00035     1,  // PROPERTY_IPV4_STACK
00036     0,  // PROPERTY_IPV6_STACK
00037     0,  // PROPERTY_IPV4V6_STACK
00038     0,  // PROPERTY_NON_IP_PDP_TYPE
00039     1,  // PROPERTY_AT_CGEREP
00040 };
00041 
00042 TELIT_HE910::TELIT_HE910(FileHandle *fh) : AT_CellularDevice(fh)
00043 {
00044     set_cellular_properties(cellular_properties);
00045 }
00046 
00047 uint16_t TELIT_HE910::get_send_delay() const
00048 {
00049     return DEFAULT_DELAY_BETWEEN_AT_COMMANDS;
00050 }
00051 
00052 nsapi_error_t TELIT_HE910::init()
00053 {
00054     nsapi_error_t err = AT_CellularDevice::init();
00055     if (err != NSAPI_ERROR_OK ) {
00056         return err;
00057     }
00058     return _at->at_cmd_discard("&K0;&C1;&D0", "");
00059 }
00060 
00061 #if MBED_CONF_TELIT_HE910_PROVIDE_DEFAULT
00062 #include "UARTSerial.h"
00063 CellularDevice *CellularDevice::get_default_instance()
00064 {
00065     static UARTSerial serial(MBED_CONF_TELIT_HE910_TX, MBED_CONF_TELIT_HE910_RX, MBED_CONF_TELIT_HE910_BAUDRATE);
00066 #if defined (MBED_CONF_TELIT_HE910_RTS) && defined (MBED_CONF_TELIT_HE910_CTS)
00067     tr_debug("TELIT_HE910 flow control: RTS %d CTS %d", MBED_CONF_TELIT_HE910_RTS, MBED_CONF_TELIT_HE910_CTS);
00068     serial.set_flow_control(SerialBase::RTSCTS, MBED_CONF_TELIT_HE910_RTS, MBED_CONF_TELIT_HE910_CTS);
00069 #endif
00070     static TELIT_HE910 device(&serial);
00071     return &device;
00072 }
00073 #endif