Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
QUECTEL_BG96_ControlPlane_netif.cpp
00001 #include "QUECTEL_BG96_ControlPlane_netif.h" 00002 00003 namespace mbed { 00004 00005 QUECTEL_BG96_ControlPlane_netif::QUECTEL_BG96_ControlPlane_netif(ATHandler &at, int cid) : AT_ControlPlane_netif(at, cid) 00006 {} 00007 00008 nsapi_size_or_error_t QUECTEL_BG96_ControlPlane_netif::send(const void *data, nsapi_size_t size) 00009 { 00010 nsapi_size_or_error_t err = _at.at_cmd_discard("+QCFGEXT", "=\"nipds\",0,", "%s%d", data, size); 00011 00012 if (err == NSAPI_ERROR_OK ) { 00013 return size; 00014 } 00015 00016 return err; 00017 } 00018 00019 nsapi_size_or_error_t QUECTEL_BG96_ControlPlane_netif::recv(void *buffer, nsapi_size_t size) 00020 { 00021 _at.lock(); 00022 00023 _at.cmd_start_stop("QCFGEXT", "=", "%s%d", "nipdr", 0); 00024 _at.resp_start("+QCFGEXT: "); 00025 // skip 3 params: "nipdr",<total_receive_length>,<have_read_length> 00026 _at.skip_param(3); 00027 // get to <unread_length> 00028 int unread_length = _at.read_int(); 00029 _at.resp_stop(); 00030 00031 if (!unread_length || unread_length == -1) { 00032 _at.unlock(); 00033 return NSAPI_ERROR_WOULD_BLOCK ; 00034 } 00035 00036 _at.cmd_start_stop("QCFGEXT", "=", "%s%d", "nipdr", unread_length); 00037 00038 _at.resp_start("+QCFGEXT:"); 00039 // skip "nipdr" 00040 _at.skip_param(); 00041 int read_length = _at.read_int(); 00042 _at.read_string((char *)buffer, read_length); 00043 _at.resp_stop(); 00044 nsapi_error_t err = _at.get_last_error(); 00045 _at.unlock(); 00046 00047 if (err == NSAPI_ERROR_OK && read_length) { 00048 return read_length; 00049 } 00050 00051 return NSAPI_ERROR_WOULD_BLOCK ; 00052 } 00053 00054 } // mbed namespace
Generated on Tue Jul 12 2022 13:54:46 by
1.7.2