mirror of https://github.com/ARMmbed/mbed-os.git
Artistic style applied and updated power function
parent
a8abeccdac
commit
ffb4f926e9
|
@ -98,7 +98,7 @@ protected:
|
||||||
bool started; // socket has been opened on modem stack
|
bool started; // socket has been opened on modem stack
|
||||||
bool tx_ready; // socket is ready for sending on modem stack
|
bool tx_ready; // socket is ready for sending on modem stack
|
||||||
bool rx_avail; // socket has data for reading on modem stack
|
bool rx_avail; // socket has data for reading on modem stack
|
||||||
volatile nsapi_size_t pending_bytes; // The number of received bytes pending
|
nsapi_size_t pending_bytes; // The number of received bytes pending
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -20,13 +20,14 @@
|
||||||
|
|
||||||
#include "AT_CellularDevice.h"
|
#include "AT_CellularDevice.h"
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed
|
||||||
|
{
|
||||||
|
|
||||||
class UBLOX_AT : public AT_CellularDevice
|
class UBLOX_AT : public AT_CellularDevice
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UBLOX_AT(events::EventQueue &queue);
|
UBLOX_AT(events::EventQueue &queue);
|
||||||
virtual ~UBLOX_AT();
|
virtual ~UBLOX_AT();
|
||||||
|
|
||||||
public: // CellularDevice
|
public: // CellularDevice
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -167,8 +167,8 @@ nsapi_error_t UBLOX_AT_CellularNetwork::open_data_channel()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UBLOX_AT_CellularNetwork::activate_profile(const char* apn,
|
bool UBLOX_AT_CellularNetwork::activate_profile(const char* apn,
|
||||||
const char* username,
|
const char* username,
|
||||||
const char* password)
|
const char* password)
|
||||||
{
|
{
|
||||||
bool activated = false;
|
bool activated = false;
|
||||||
bool success = false;
|
bool success = false;
|
||||||
|
@ -224,7 +224,7 @@ bool UBLOX_AT_CellularNetwork::activate_profile(const char* apn,
|
||||||
// 1 = PAP (Password Authentication Protocol)
|
// 1 = PAP (Password Authentication Protocol)
|
||||||
// 2 = CHAP (Challenge Handshake Authentication Protocol)
|
// 2 = CHAP (Challenge Handshake Authentication Protocol)
|
||||||
for (int protocol = nsapi_security_to_modem_security(NSAPI_SECURITY_NONE);
|
for (int protocol = nsapi_security_to_modem_security(NSAPI_SECURITY_NONE);
|
||||||
success && (protocol <= nsapi_security_to_modem_security(NSAPI_SECURITY_CHAP)); protocol++) {
|
success && (protocol <= nsapi_security_to_modem_security(NSAPI_SECURITY_CHAP)); protocol++) {
|
||||||
if ((_auth == NSAPI_SECURITY_UNKNOWN) || (nsapi_security_to_modem_security(_auth) == protocol)) {
|
if ((_auth == NSAPI_SECURITY_UNKNOWN) || (nsapi_security_to_modem_security(_auth) == protocol)) {
|
||||||
_at.cmd_start("AT+UPSD=0,6,");
|
_at.cmd_start("AT+UPSD=0,6,");
|
||||||
_at.write_int(protocol);
|
_at.write_int(protocol);
|
||||||
|
@ -257,8 +257,7 @@ int UBLOX_AT_CellularNetwork::nsapi_security_to_modem_security(nsapi_security_t
|
||||||
{
|
{
|
||||||
int modem_security = 3;
|
int modem_security = 3;
|
||||||
|
|
||||||
switch (nsapi_security)
|
switch (nsapi_security) {
|
||||||
{
|
|
||||||
case NSAPI_SECURITY_NONE:
|
case NSAPI_SECURITY_NONE:
|
||||||
modem_security = 0;
|
modem_security = 0;
|
||||||
break;
|
break;
|
||||||
|
@ -330,15 +329,17 @@ const char *UBLOX_AT_CellularNetwork::get_gateway()
|
||||||
|
|
||||||
nsapi_error_t UBLOX_AT_CellularNetwork::detach()
|
nsapi_error_t UBLOX_AT_CellularNetwork::detach()
|
||||||
{
|
{
|
||||||
|
nsapi_error_t err;
|
||||||
|
|
||||||
_at.lock();
|
_at.lock();
|
||||||
_at.cmd_start("AT+CGATT=0");
|
_at.cmd_start("AT+CGATT=0");
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
_at.resp_start();
|
_at.resp_start();
|
||||||
_at.resp_stop();
|
_at.resp_stop();
|
||||||
_at.unlock();
|
err = _at.unlock_return_error();
|
||||||
|
|
||||||
// wait added to process CGREG and UUPSDD URC, which comes after detach.
|
// wait added to process CGREG and UUPSDD URC, which comes after detach.
|
||||||
wait_ms(50);
|
wait_ms(50);
|
||||||
|
|
||||||
return _at.get_last_error();
|
return err;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -21,7 +21,8 @@
|
||||||
#include "AT_CellularNetwork.h"
|
#include "AT_CellularNetwork.h"
|
||||||
#include "APN_db.h"
|
#include "APN_db.h"
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed
|
||||||
|
{
|
||||||
|
|
||||||
class UBLOX_AT_CellularNetwork : public AT_CellularNetwork
|
class UBLOX_AT_CellularNetwork : public AT_CellularNetwork
|
||||||
{
|
{
|
||||||
|
@ -45,13 +46,9 @@ protected:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/** The profile to use (on board the modem).
|
|
||||||
*/
|
|
||||||
#define PROFILE "0"
|
|
||||||
|
|
||||||
/** Length of IMSI buffer.
|
/** Length of IMSI buffer.
|
||||||
*/
|
*/
|
||||||
#define MAX_IMSI_LENGTH 15
|
static const int MAX_IMSI_LENGTH = 15;
|
||||||
|
|
||||||
/** The type of authentication to use.
|
/** The type of authentication to use.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -20,7 +20,8 @@
|
||||||
|
|
||||||
#include "AT_CellularPower.h"
|
#include "AT_CellularPower.h"
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed
|
||||||
|
{
|
||||||
|
|
||||||
class UBLOX_AT_CellularPower : public AT_CellularPower
|
class UBLOX_AT_CellularPower : public AT_CellularPower
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -107,17 +107,11 @@ void UBLOX_AT_CellularStack::UUPSDD_URC()
|
||||||
clear_socket(socket);
|
clear_socket(socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int UBLOX_AT_CellularStack::get_max_socket_count()
|
int UBLOX_AT_CellularStack::get_max_socket_count()
|
||||||
{
|
{
|
||||||
return UBLOX_MAX_SOCKET;
|
return UBLOX_MAX_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
int UBLOX_AT_CellularStack::get_max_packet_size()
|
|
||||||
{
|
|
||||||
return UBLOX_MAX_PACKET_SIZE;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
bool UBLOX_AT_CellularStack::is_protocol_supported(nsapi_protocol_t protocol)
|
||||||
{
|
{
|
||||||
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
return (protocol == NSAPI_UDP || protocol == NSAPI_TCP);
|
||||||
|
@ -225,7 +219,7 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_connect(nsapi_socket_t handle, cons
|
||||||
_at.lock();
|
_at.lock();
|
||||||
_at.cmd_start("AT+USOCO=");
|
_at.cmd_start("AT+USOCO=");
|
||||||
_at.write_int(socket->id);
|
_at.write_int(socket->id);
|
||||||
_at.write_string(addr.get_ip_address(), true);
|
_at.write_string(addr.get_ip_address());
|
||||||
_at.write_int(addr.get_port());
|
_at.write_int(addr.get_port());
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
_at.resp_start();
|
_at.resp_start();
|
||||||
|
@ -245,22 +239,22 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
|
||||||
const void *data, nsapi_size_t size)
|
const void *data, nsapi_size_t size)
|
||||||
{
|
{
|
||||||
int sent_len = 0;
|
int sent_len = 0;
|
||||||
uint8_t ch = 0;
|
uint8_t ch = 0, cont = 50;
|
||||||
|
|
||||||
_at.lock();
|
|
||||||
if (socket->proto == NSAPI_UDP) {
|
if (socket->proto == NSAPI_UDP) {
|
||||||
if (size > (nsapi_size_t) get_max_packet_size()) {
|
if (size > UBLOX_MAX_PACKET_SIZE) {
|
||||||
return NSAPI_ERROR_PARAMETER;
|
return NSAPI_ERROR_PARAMETER;
|
||||||
}
|
}
|
||||||
_at.cmd_start("AT+USOST=");
|
_at.cmd_start("AT+USOST=");
|
||||||
_at.write_int(socket->id);
|
_at.write_int(socket->id);
|
||||||
_at.write_string(address.get_ip_address(), true);
|
_at.write_string(address.get_ip_address());
|
||||||
_at.write_int(address.get_port());
|
_at.write_int(address.get_port());
|
||||||
_at.write_int(size);
|
_at.write_int(size);
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
wait_ms(50);
|
wait_ms(50);
|
||||||
while (ch != '@') {
|
while (ch != '@' && cont > 0) {
|
||||||
_at.read_bytes(&ch, 1);
|
_at.read_bytes(&ch, 1);
|
||||||
|
cont--;
|
||||||
}
|
}
|
||||||
_at.write_bytes((uint8_t *)data, size);
|
_at.write_bytes((uint8_t *)data, size);
|
||||||
|
|
||||||
|
@ -271,8 +265,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
|
||||||
|
|
||||||
if ((_at.get_last_error() == NSAPI_ERROR_OK)) {
|
if ((_at.get_last_error() == NSAPI_ERROR_OK)) {
|
||||||
return sent_len;
|
return sent_len;
|
||||||
} else {
|
|
||||||
socket->rx_avail = false;
|
|
||||||
}
|
}
|
||||||
} else if (socket->proto == NSAPI_TCP) {
|
} else if (socket->proto == NSAPI_TCP) {
|
||||||
bool success = true;
|
bool success = true;
|
||||||
|
@ -289,8 +281,9 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
|
||||||
_at.write_int(blk);
|
_at.write_int(blk);
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
wait_ms(50);
|
wait_ms(50);
|
||||||
while (ch != '@') {
|
while (ch != '@' && cont > 0) {
|
||||||
_at.read_bytes(&ch, 1);
|
_at.read_bytes(&ch, 1);
|
||||||
|
cont--;
|
||||||
}
|
}
|
||||||
_at.write_bytes((uint8_t *)buf, blk);
|
_at.write_bytes((uint8_t *)buf, blk);
|
||||||
|
|
||||||
|
@ -300,7 +293,7 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
|
||||||
_at.resp_stop();
|
_at.resp_stop();
|
||||||
|
|
||||||
if ((sent_len >= (int) blk) &&
|
if ((sent_len >= (int) blk) &&
|
||||||
(_at.get_last_error() == NSAPI_ERROR_OK)) {
|
(_at.get_last_error() == NSAPI_ERROR_OK)) {
|
||||||
} else {
|
} else {
|
||||||
success = false;
|
success = false;
|
||||||
}
|
}
|
||||||
|
@ -314,7 +307,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto_impl(CellularSocket
|
||||||
return size - count;
|
return size - count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_at.unlock();
|
|
||||||
|
|
||||||
return _at.get_last_error();
|
return _at.get_last_error();
|
||||||
}
|
}
|
||||||
|
@ -332,7 +324,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
int port = 0;
|
int port = 0;
|
||||||
Timer timer;
|
Timer timer;
|
||||||
|
|
||||||
_at.lock();
|
|
||||||
timer.start();
|
timer.start();
|
||||||
if (socket->proto == NSAPI_UDP) {
|
if (socket->proto == NSAPI_UDP) {
|
||||||
while (success && (size > 0)) {
|
while (success && (size > 0)) {
|
||||||
|
@ -363,7 +354,7 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
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();
|
||||||
|
|
||||||
if (usorf_sz > 0) {
|
if (usorf_sz > 0) {
|
||||||
|
@ -412,7 +403,7 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
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();
|
||||||
|
|
||||||
if (usorf_sz > 0) {
|
if (usorf_sz > 0) {
|
||||||
|
@ -435,8 +426,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
timer.stop();
|
timer.stop();
|
||||||
_at.unlock();
|
|
||||||
|
|
||||||
|
|
||||||
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
if (!count || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
||||||
return NSAPI_ERROR_WOULD_BLOCK;
|
return NSAPI_ERROR_WOULD_BLOCK;
|
||||||
|
@ -453,29 +442,6 @@ nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_recvfrom_impl(CellularSocke
|
||||||
return nsapi_error_size;
|
return nsapi_error_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsapi_size_or_error_t UBLOX_AT_CellularStack::socket_sendto(nsapi_socket_t handle, const SocketAddress &addr, const void *data, unsigned size)
|
|
||||||
{
|
|
||||||
CellularSocket *socket = (CellularSocket *)handle;
|
|
||||||
if (!socket || !socket->created) {
|
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_size_or_error_t ret_val = NSAPI_ERROR_OK;
|
|
||||||
|
|
||||||
/* Check parameters */
|
|
||||||
if (addr.get_ip_version() == NSAPI_UNSPEC) {
|
|
||||||
return NSAPI_ERROR_DEVICE_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
_at.lock();
|
|
||||||
|
|
||||||
ret_val = socket_sendto_impl(socket, addr, data, size);
|
|
||||||
|
|
||||||
_at.unlock();
|
|
||||||
|
|
||||||
return ret_val;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsapi_error_t UBLOX_AT_CellularStack::socket_close_impl(int sock_id)
|
nsapi_error_t UBLOX_AT_CellularStack::socket_close_impl(int sock_id)
|
||||||
{
|
{
|
||||||
_at.lock();
|
_at.lock();
|
||||||
|
@ -484,9 +450,8 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_close_impl(int sock_id)
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
_at.resp_start();
|
_at.resp_start();
|
||||||
_at.resp_stop();
|
_at.resp_stop();
|
||||||
_at.unlock();
|
|
||||||
|
|
||||||
return _at.get_last_error();
|
return _at.unlock_return_error();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find or create a socket from the list.
|
// Find or create a socket from the list.
|
||||||
|
@ -561,19 +526,19 @@ nsapi_error_t UBLOX_AT_CellularStack::gethostbyname(const char *host, SocketAddr
|
||||||
} else {
|
} else {
|
||||||
// This interrogation can sometimes take longer than the usual 8 seconds
|
// This interrogation can sometimes take longer than the usual 8 seconds
|
||||||
_at.cmd_start("AT+UDNSRN=0,");
|
_at.cmd_start("AT+UDNSRN=0,");
|
||||||
_at.write_string(host, true);
|
_at.write_string(host);
|
||||||
_at.cmd_stop();
|
_at.cmd_stop();
|
||||||
|
|
||||||
_at.set_at_timeout(60000);
|
_at.set_at_timeout(60000);
|
||||||
_at.resp_start("+UDNSRN:");
|
_at.resp_start("+UDNSRN:");
|
||||||
if (_at.info_resp()) {
|
if (_at.info_resp()) {
|
||||||
_at.read_string(ipAddress, sizeof(ipAddress));
|
_at.read_string(ipAddress, sizeof(ipAddress));
|
||||||
_at.resp_stop();
|
|
||||||
|
|
||||||
if (address->set_ip_address(ipAddress)) {
|
if (address->set_ip_address(ipAddress)) {
|
||||||
err = NSAPI_ERROR_OK;
|
err = NSAPI_ERROR_OK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_at.resp_stop();
|
||||||
_at.restore_at_timeout();
|
_at.restore_at_timeout();
|
||||||
}
|
}
|
||||||
_at.unlock();
|
_at.unlock();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Arm Limited and affiliates.
|
* Copyright (c) 2018, Arm Limited and affiliates.
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -23,7 +23,8 @@
|
||||||
#include "drivers/Timer.h"
|
#include "drivers/Timer.h"
|
||||||
|
|
||||||
|
|
||||||
namespace mbed {
|
namespace mbed
|
||||||
|
{
|
||||||
|
|
||||||
class UBLOX_AT_CellularStack : public AT_CellularStack
|
class UBLOX_AT_CellularStack : public AT_CellularStack
|
||||||
{
|
{
|
||||||
|
@ -34,7 +35,7 @@ public:
|
||||||
virtual const char *get_ip_address();
|
virtual const char *get_ip_address();
|
||||||
|
|
||||||
virtual nsapi_error_t gethostbyname(const char *host,
|
virtual nsapi_error_t gethostbyname(const char *host,
|
||||||
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
SocketAddress *address, nsapi_version_t version = NSAPI_UNSPEC);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
|
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
|
||||||
|
@ -44,34 +45,32 @@ protected:
|
||||||
|
|
||||||
protected: // AT_CellularStack
|
protected: // AT_CellularStack
|
||||||
|
|
||||||
/** Socket "unused" value.
|
|
||||||
*/
|
|
||||||
#define SOCKET_UNUSED -1
|
|
||||||
|
|
||||||
/** The profile to use (on board the modem).
|
/** The profile to use (on board the modem).
|
||||||
*/
|
*/
|
||||||
#define PROFILE "0"
|
#define PROFILE "0"
|
||||||
|
|
||||||
|
/** Socket "unused" value.
|
||||||
|
*/
|
||||||
|
static const int SOCKET_UNUSED = -1;
|
||||||
|
|
||||||
/** Socket timeout value in milliseconds.
|
/** Socket timeout value in milliseconds.
|
||||||
* Note: the sockets layer above will retry the
|
* Note: the sockets layer above will retry the
|
||||||
* call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
|
* call to the functions here when they return NSAPI_ERROR_WOULD_BLOCK
|
||||||
* and the user has set a larger timeout or full blocking.
|
* and the user has set a larger timeout or full blocking.
|
||||||
*/
|
*/
|
||||||
#define SOCKET_TIMEOUT 5000
|
static const int SOCKET_TIMEOUT = 1000;
|
||||||
|
|
||||||
/** Maximum allowed sockets.
|
/** Maximum allowed sockets.
|
||||||
*/
|
*/
|
||||||
#define UBLOX_MAX_SOCKET 7
|
static const int UBLOX_MAX_SOCKET = 7;
|
||||||
|
|
||||||
/** The maximum number of bytes in a packet that can be write/read from
|
/** The maximum number of bytes in a packet that can be write/read from
|
||||||
* the AT interface in one go.
|
* the AT interface in one go.
|
||||||
*/
|
*/
|
||||||
#define UBLOX_MAX_PACKET_SIZE 1024
|
static const int UBLOX_MAX_PACKET_SIZE = 1024;
|
||||||
|
|
||||||
virtual int get_max_socket_count();
|
virtual int get_max_socket_count();
|
||||||
|
|
||||||
virtual int get_max_packet_size();
|
|
||||||
|
|
||||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
virtual bool is_protocol_supported(nsapi_protocol_t protocol);
|
||||||
|
|
||||||
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto);
|
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto);
|
||||||
|
@ -86,9 +85,6 @@ protected: // AT_CellularStack
|
||||||
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||||
void *buffer, nsapi_size_t size);
|
void *buffer, nsapi_size_t size);
|
||||||
|
|
||||||
virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address,
|
|
||||||
const void *data, nsapi_size_t size);
|
|
||||||
|
|
||||||
virtual nsapi_error_t socket_close_impl(int sock_id);
|
virtual nsapi_error_t socket_close_impl(int sock_id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -70,15 +70,8 @@ void onboard_modem_power_up()
|
||||||
|
|
||||||
void onboard_modem_power_down()
|
void onboard_modem_power_down()
|
||||||
{
|
{
|
||||||
#if defined(TARGET_UBLOX_C030_R410M)
|
|
||||||
/* keep the power line low for 1.5 seconds */
|
/* keep the power line low for 1.5 seconds */
|
||||||
press_power_button(1500000);
|
press_power_button(1500000);
|
||||||
#else
|
|
||||||
/* keep the power line low for 1 seconds */
|
|
||||||
press_power_button(1500000);
|
|
||||||
#endif
|
|
||||||
/* wait for modem to power off properly*/
|
|
||||||
wait(10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //MODEM_ON_BOARD
|
#endif //MODEM_ON_BOARD
|
||||||
|
|
Loading…
Reference in New Issue