Denislam Valeev / Mbed OS Nucleo_rtos_basic
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers AT_CellularInformation.cpp Source File

AT_CellularInformation.cpp

00001 /*
00002  * Copyright (c) 2018, 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 "AT_CellularInformation.h"
00019 
00020 using namespace mbed;
00021 
00022 AT_CellularInformation::AT_CellularInformation(ATHandler &at) : AT_CellularBase(at)
00023 {
00024 }
00025 
00026 AT_CellularInformation::~AT_CellularInformation()
00027 {
00028 }
00029 
00030 nsapi_error_t AT_CellularInformation::get_manufacturer(char *buf, size_t buf_size)
00031 {
00032     return get_info("AT+CGMI", buf, buf_size);
00033 }
00034 
00035 nsapi_error_t AT_CellularInformation::get_model(char *buf, size_t buf_size)
00036 {
00037     return get_info("AT+CGMM", buf, buf_size);
00038 }
00039 
00040 nsapi_error_t AT_CellularInformation::get_revision(char *buf, size_t buf_size)
00041 {
00042     return get_info("AT+CGMR", buf, buf_size);
00043 }
00044 
00045 nsapi_error_t AT_CellularInformation::get_info(const char *cmd, char *buf, size_t buf_size)
00046 {
00047     _at.lock();
00048 
00049     _at.cmd_start(cmd);
00050     _at.cmd_stop();
00051     _at.set_delimiter(0);
00052     _at.resp_start();
00053     _at.read_string(buf, buf_size-1);
00054     _at.resp_stop();
00055     _at.set_default_delimiter();
00056 
00057     return _at.unlock_return_error();
00058 }