mirror of https://github.com/ARMmbed/mbed-os.git
C030_N211 api's update and removed N2XX_CellularNetwork class
parent
6c347eafe5
commit
d34b0475a9
|
@ -297,6 +297,10 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
port = _at.read_int();
|
port = _at.read_int();
|
||||||
usorf_sz = _at.read_int();
|
usorf_sz = _at.read_int();
|
||||||
|
|
||||||
|
if (usorf_sz > size) {
|
||||||
|
usorf_sz = size;
|
||||||
|
}
|
||||||
|
|
||||||
// Must use what +USORF returns here as it may be less or more than we asked for
|
// Must use what +USORF returns here as it may be less or more than we asked for
|
||||||
if (usorf_sz > socket->pending_bytes) {
|
if (usorf_sz > socket->pending_bytes) {
|
||||||
socket->pending_bytes = 0;
|
socket->pending_bytes = 0;
|
||||||
|
@ -304,9 +308,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
socket->pending_bytes -= usorf_sz;
|
socket->pending_bytes -= usorf_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usorf_sz > size) {
|
|
||||||
usorf_sz = size;
|
|
||||||
}
|
|
||||||
_at.read_bytes(&ch, 1);
|
_at.read_bytes(&ch, 1);
|
||||||
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
|
_at.read_bytes((uint8_t *)buffer + count, usorf_sz);
|
||||||
_at.resp_stop();
|
_at.resp_stop();
|
||||||
|
|
|
@ -54,11 +54,6 @@ void UBLOX_N2XX::NPIN_URC()
|
||||||
_at->read_string(simstr, sizeof(simstr));
|
_at->read_string(simstr, sizeof(simstr));
|
||||||
}
|
}
|
||||||
|
|
||||||
AT_CellularNetwork *UBLOX_N2XX::open_network_impl(ATHandler &at)
|
|
||||||
{
|
|
||||||
return new UBLOX_N2XX_CellularNetwork(at);
|
|
||||||
}
|
|
||||||
|
|
||||||
AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
|
AT_CellularContext *UBLOX_N2XX::create_context_impl(ATHandler &at, const char *apn, bool cp_req, bool nonip_req)
|
||||||
{
|
{
|
||||||
return new UBLOX_N2XX_CellularContext(at, this, apn, cp_req, nonip_req);
|
return new UBLOX_N2XX_CellularContext(at, this, apn, cp_req, nonip_req);
|
||||||
|
@ -69,7 +64,6 @@ AT_CellularSMS *UBLOX_N2XX::open_sms_impl(ATHandler &at)
|
||||||
return new UBLOX_N2XX_CellularSMS(at);
|
return new UBLOX_N2XX_CellularSMS(at);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsapi_error_t UBLOX_N2XX::init()
|
nsapi_error_t UBLOX_N2XX::init()
|
||||||
{
|
{
|
||||||
_at->set_at_timeout(5000);
|
_at->set_at_timeout(5000);
|
||||||
|
|
|
@ -18,11 +18,20 @@
|
||||||
#ifndef UBLOX_N2XX_H_
|
#ifndef UBLOX_N2XX_H_
|
||||||
#define UBLOX_N2XX_H_
|
#define UBLOX_N2XX_H_
|
||||||
|
|
||||||
|
#ifdef TARGET_FF_ARDUINO
|
||||||
|
#ifndef MBED_CONF_UBLOX_N2XX_TX
|
||||||
|
#define MBED_CONF_UBLOX_N2XX_TX D1
|
||||||
|
#endif
|
||||||
|
#ifndef MBED_CONF_UBLOX_N2XX_RX
|
||||||
|
#define MBED_CONF_UBLOX_N2XX_RX D0
|
||||||
|
#endif
|
||||||
|
#endif /* TARGET_FF_ARDUINO */
|
||||||
|
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
#include "CellularLog.h"
|
#include "CellularLog.h"
|
||||||
#include "AT_CellularDevice.h"
|
#include "AT_CellularDevice.h"
|
||||||
|
#include "AT_CellularNetwork.h"
|
||||||
#include "UBLOX_N2XX_CellularSMS.h"
|
#include "UBLOX_N2XX_CellularSMS.h"
|
||||||
#include "UBLOX_N2XX_CellularNetwork.h"
|
|
||||||
#include "UBLOX_N2XX_CellularContext.h"
|
#include "UBLOX_N2XX_CellularContext.h"
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed {
|
||||||
|
@ -41,7 +50,6 @@ public:
|
||||||
|
|
||||||
protected: // AT_CellularDevice
|
protected: // AT_CellularDevice
|
||||||
|
|
||||||
virtual AT_CellularNetwork *open_network_impl(ATHandler &at);
|
|
||||||
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
|
virtual AT_CellularContext *create_context_impl(ATHandler &at, const char *apn, bool cp_req = false, bool nonip_req = false);
|
||||||
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
|
virtual AT_CellularSMS *open_sms_impl(ATHandler &at);
|
||||||
|
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019, Arm Limited and affiliates.
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "UBLOX_N2XX_CellularNetwork.h"
|
|
||||||
|
|
||||||
using namespace mbed;
|
|
||||||
|
|
||||||
UBLOX_N2XX_CellularNetwork::UBLOX_N2XX_CellularNetwork(ATHandler &atHandler): AT_CellularNetwork(atHandler)
|
|
||||||
{
|
|
||||||
_op_act = RAT_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
UBLOX_N2XX_CellularNetwork::~UBLOX_N2XX_CellularNetwork()
|
|
||||||
{
|
|
||||||
if (_connection_status_cb) {
|
|
||||||
_connection_status_cb(NSAPI_EVENT_CONNECTION_STATUS_CHANGE, NSAPI_ERROR_CONNECTION_LOST);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_error_t UBLOX_N2XX_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat) // Not understandable, RAT (+CEDRXS)
|
|
||||||
{
|
|
||||||
switch (opRat) {
|
|
||||||
#if defined(TARGET_UBLOX_C030_N211)
|
|
||||||
case RAT_NB1:
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
default: {
|
|
||||||
_op_act = RAT_UNKNOWN;
|
|
||||||
return NSAPI_ERROR_UNSUPPORTED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NSAPI_ERROR_OK;
|
|
||||||
}
|
|
|
@ -1,39 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright (c) 2019, Arm Limited and affiliates.
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef UBLOX_N2XX_CELLULAR_NETWORK_H_
|
|
||||||
#define UBLOX_N2XX_CELLULAR_NETWORK_H_
|
|
||||||
|
|
||||||
#include "AT_CellularNetwork.h"
|
|
||||||
|
|
||||||
namespace mbed {
|
|
||||||
|
|
||||||
class UBLOX_N2XX_CellularNetwork : public AT_CellularNetwork {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
UBLOX_N2XX_CellularNetwork(ATHandler &atHandler);
|
|
||||||
virtual ~UBLOX_N2XX_CellularNetwork();
|
|
||||||
|
|
||||||
protected:
|
|
||||||
|
|
||||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology opRat);
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace mbed
|
|
||||||
|
|
||||||
#endif // UBLOX_N2XX_CELLULAR_NETWORK_H_
|
|
|
@ -119,17 +119,17 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_sendto_impl(CellularSocke
|
||||||
return NSAPI_ERROR_PARAMETER;
|
return NSAPI_ERROR_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sent_len = 0, len = 0;
|
int sent_len = 0;
|
||||||
char *dataStr = (char *) malloc((size * 2) + 1);
|
char *dataStr = new char [(size * 2) + 1]();
|
||||||
memset(dataStr, 0, size*2+1);
|
if (!dataStr)
|
||||||
|
return NSAPI_ERROR_NO_MEMORY;
|
||||||
char_str_to_hex_str((const char*)data, size, dataStr);
|
char_str_to_hex_str((const char*)data, size, dataStr);
|
||||||
len = strlen(dataStr);
|
|
||||||
|
|
||||||
_at.cmd_start("AT+NSOST=");
|
_at.cmd_start("AT+NSOST=");
|
||||||
_at.write_int(socket->id);
|
_at.write_int(socket->id);
|
||||||
_at.write_string(address.get_ip_address());
|
_at.write_string(address.get_ip_address());
|
||||||
_at.write_int(address.get_port());
|
_at.write_int(address.get_port());
|
||||||
_at.write_int(len/2);
|
_at.write_int(size);
|
||||||
_at.write_string(dataStr);
|
_at.write_string(dataStr);
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
|
|
||||||
|
@ -153,15 +153,12 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
|
||||||
nsapi_size_t read_blk, usorf_sz, count = 0, length = size*2;
|
nsapi_size_t read_blk, usorf_sz, count = 0, length = size*2;
|
||||||
bool success = true;
|
bool success = true;
|
||||||
char ipAddress[NSAPI_IP_SIZE];
|
char ipAddress[NSAPI_IP_SIZE];
|
||||||
char *tmpBuf = (char *) malloc(size*2+1);
|
|
||||||
memset(tmpBuf, 0, size*2+1);
|
|
||||||
int port = 0;
|
int port = 0;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
if (socket->pending_bytes == 0) {
|
if (socket->pending_bytes == 0) {
|
||||||
_at.process_oob();
|
_at.process_oob();
|
||||||
if (socket->pending_bytes == 0) {
|
if (socket->pending_bytes == 0) {
|
||||||
free(tmpBuf);
|
|
||||||
return NSAPI_ERROR_WOULD_BLOCK;
|
return NSAPI_ERROR_WOULD_BLOCK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -183,6 +180,11 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
|
||||||
_at.read_string(ipAddress, sizeof(ipAddress));
|
_at.read_string(ipAddress, sizeof(ipAddress));
|
||||||
port = _at.read_int();
|
port = _at.read_int();
|
||||||
usorf_sz = _at.read_int();
|
usorf_sz = _at.read_int();
|
||||||
|
if (usorf_sz > length) {
|
||||||
|
usorf_sz = length;
|
||||||
|
}
|
||||||
|
_at.read_hex_string((char *)buffer + count, usorf_sz*2+1);
|
||||||
|
_at.resp_stop();
|
||||||
|
|
||||||
// Must use what +NSORF returns here as it may be less or more than we asked for
|
// Must use what +NSORF returns here as it may be less or more than we asked for
|
||||||
if (usorf_sz >= socket->pending_bytes) {
|
if (usorf_sz >= socket->pending_bytes) {
|
||||||
|
@ -191,12 +193,6 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
|
||||||
socket->pending_bytes -= usorf_sz;
|
socket->pending_bytes -= usorf_sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (usorf_sz > length) {
|
|
||||||
usorf_sz = length;
|
|
||||||
}
|
|
||||||
_at.read_string(tmpBuf + count, usorf_sz*2+1);
|
|
||||||
_at.resp_stop();
|
|
||||||
|
|
||||||
if (usorf_sz > 0) {
|
if (usorf_sz > 0) {
|
||||||
count += (usorf_sz*2);
|
count += (usorf_sz*2);
|
||||||
length -= (usorf_sz*2);
|
length -= (usorf_sz*2);
|
||||||
|
@ -220,10 +216,7 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
|
||||||
|
|
||||||
socket->pending_bytes = 0;
|
socket->pending_bytes = 0;
|
||||||
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
||||||
free(tmpBuf);
|
|
||||||
return NSAPI_ERROR_WOULD_BLOCK;
|
return NSAPI_ERROR_WOULD_BLOCK;
|
||||||
} else {
|
|
||||||
nsapi_error_size = count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (success && socket->proto == NSAPI_UDP && address) {
|
if (success && socket->proto == NSAPI_UDP && address) {
|
||||||
|
@ -232,9 +225,6 @@ nsapi_size_or_error_t UBLOX_N2XX_CellularStack::socket_recvfrom_impl(CellularSoc
|
||||||
address->set_port(port);
|
address->set_port(port);
|
||||||
}
|
}
|
||||||
|
|
||||||
hex_str_to_char_str(tmpBuf, count, (char*) buffer);
|
|
||||||
|
|
||||||
free(tmpBuf);
|
|
||||||
return nsapi_error_size = count/2;
|
return nsapi_error_size = count/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue