mirror of https://github.com/ARMmbed/mbed-os.git
cellular: fix coding style
parent
96191e22b2
commit
71d35749f9
|
@ -223,7 +223,7 @@ static void test_credentials()
|
|||
|
||||
static void test_other()
|
||||
{
|
||||
const char* devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
const char *devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
TEST_ASSERT(nw->get_3gpp_error() == 0);
|
||||
|
||||
CellularNetwork::RateControlExceptionReports reports;
|
||||
|
|
|
@ -73,7 +73,7 @@ static void wait_for_power(CellularPower *pwr)
|
|||
|
||||
static void test_power_interface()
|
||||
{
|
||||
const char* devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
const char *devi = CELLULAR_STRINGIFY(CELLULAR_DEVICE);
|
||||
cellular_device = new CELLULAR_DEVICE(queue);
|
||||
cellular_device->set_timeout(5000);
|
||||
CellularPower *pwr = cellular_device->open_power(&cellular_serial);
|
||||
|
@ -89,12 +89,12 @@ static void test_power_interface()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
wait_for_power(pwr);
|
||||
|
||||
err = pwr->opt_power_save_mode(0,0);
|
||||
err = pwr->opt_power_save_mode(0, 0);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) { // TELIT_HE910 and QUECTEL_BG96 just gives an error and no specific error number so we can't know is this real error or that modem/network does not support the command
|
||||
TEST_ASSERT(((AT_CellularPower*)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower*)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularPower *)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower *)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,8 +102,8 @@ static void test_power_interface()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
if (!(strcmp(devi, "TELIT_HE910") == 0 || strcmp(devi, "QUECTEL_BG96") == 0)) { // TELIT_HE910 and QUECTEL_BG96 just gives an error and no specific error number so we can't know is this real error or that modem/network does not support the command
|
||||
TEST_ASSERT(((AT_CellularPower*)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower*)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularPower *)pwr)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularPower *)pwr)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ static EventQueue queue(8 * EVENTS_EVENT_SIZE);
|
|||
static rtos::Semaphore network_semaphore(0);
|
||||
static CellularConnectionFSM *cellularConnectionFSM;
|
||||
static CellularConnectionFSM::CellularState cellular_target_state;
|
||||
static CellularSMS* sms;
|
||||
static CellularSMS *sms;
|
||||
static char service_center_address[SMS_MAX_PHONE_NUMBER_SIZE];
|
||||
static int service_address_type;
|
||||
|
||||
|
@ -199,7 +199,7 @@ static void test_get_sms()
|
|||
|
||||
wait(7);
|
||||
|
||||
TEST_ASSERT(sms->get_sms(buf, buf_len, phone_num, SMS_MAX_PHONE_NUMBER_SIZE, time_stamp, SMS_MAX_TIME_STAMP_SIZE, &buf_size) == buf_len-1);
|
||||
TEST_ASSERT(sms->get_sms(buf, buf_len, phone_num, SMS_MAX_PHONE_NUMBER_SIZE, time_stamp, SMS_MAX_TIME_STAMP_SIZE, &buf_size) == buf_len - 1);
|
||||
TEST_ASSERT(strcmp(phone_num, MBED_CONF_APP_CELLULAR_PHONE_NUMBER) == 0);
|
||||
TEST_ASSERT(strcmp(buf, TEST_MESSAGE) == 0);
|
||||
TEST_ASSERT(buf_size == 0);
|
||||
|
|
|
@ -501,7 +501,7 @@ ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
|
|||
// Consume to delimiter or stop_tag
|
||||
if (!delimiter_found && !_stop_tag->found) {
|
||||
match_pos = 0;
|
||||
while(1) {
|
||||
while (1) {
|
||||
int c = get_char();
|
||||
if (c == -1) {
|
||||
set_error(NSAPI_ERROR_DEVICE_ERROR);
|
||||
|
|
|
@ -625,7 +625,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char *b
|
|||
int len = _at.read_string(time_stamp, SMS_MAX_TIME_STAMP_SIZE);
|
||||
if (len < (SMS_MAX_TIME_STAMP_SIZE - 2)) {
|
||||
time_stamp[len++] = ',';
|
||||
_at.read_string(&time_stamp[len], SMS_MAX_TIME_STAMP_SIZE-len);
|
||||
_at.read_string(&time_stamp[len], SMS_MAX_TIME_STAMP_SIZE - len);
|
||||
}
|
||||
}
|
||||
(void)_at.consume_to_stop_tag(); // consume until <CR><LF>
|
||||
|
|
|
@ -520,7 +520,7 @@ sisr_retry:
|
|||
|
||||
tr_debug("Socket %d, recvfrom %s, %d bytes (err %d)", socket->id, socket->remoteAddress.get_ip_address(), len, _at.get_last_error());
|
||||
|
||||
return (_at.get_last_error() == NSAPI_ERROR_OK) ? ( recv_len ? recv_len : NSAPI_ERROR_WOULD_BLOCK ) : NSAPI_ERROR_DEVICE_ERROR;
|
||||
return (_at.get_last_error() == NSAPI_ERROR_OK) ? (recv_len ? recv_len : NSAPI_ERROR_WOULD_BLOCK) : NSAPI_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
// setup internet connection profile for sockets
|
||||
|
|
|
@ -20,8 +20,7 @@
|
|||
|
||||
#include "AT_CellularDevice.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class UBLOX_AT : public AT_CellularDevice {
|
||||
public:
|
||||
|
|
|
@ -54,7 +54,7 @@ AT_CellularNetwork::RegistrationMode UBLOX_AT_CellularNetwork::has_registration(
|
|||
|
||||
nsapi_error_t UBLOX_AT_CellularNetwork::set_access_technology_impl(RadioAccessTechnology opRat)
|
||||
{
|
||||
switch(opRat) {
|
||||
switch (opRat) {
|
||||
#if defined(TARGET_UBLOX_C030_U201) || defined(TARGET_UBLOX_C027)
|
||||
case RAT_GSM:
|
||||
case RAT_GSM_COMPACT:
|
||||
|
@ -119,9 +119,9 @@ nsapi_error_t UBLOX_AT_CellularNetwork::open_data_channel()
|
|||
{
|
||||
bool success = false;
|
||||
int active = 0;
|
||||
char * config = NULL;
|
||||
char *config = NULL;
|
||||
nsapi_error_t err = NSAPI_ERROR_NO_CONNECTION;
|
||||
char imsi[MAX_IMSI_LENGTH+1];
|
||||
char imsi[MAX_IMSI_LENGTH + 1];
|
||||
|
||||
// do check for stack to validate that we have support for stack
|
||||
_stack = get_stack();
|
||||
|
@ -142,14 +142,14 @@ nsapi_error_t UBLOX_AT_CellularNetwork::open_data_channel()
|
|||
if (_apn == NULL) {
|
||||
err = get_imsi(imsi);
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
config = (char*)apnconfig(imsi);
|
||||
config = (char *)apnconfig(imsi);
|
||||
}
|
||||
}
|
||||
|
||||
// Attempt to connect
|
||||
do {
|
||||
get_next_credentials(&config);
|
||||
if(_uname && _pwd) {
|
||||
if (_uname && _pwd) {
|
||||
_auth = (*_uname && *_pwd) ? _auth : NSAPI_SECURITY_NONE;
|
||||
} else {
|
||||
_auth = NSAPI_SECURITY_NONE;
|
||||
|
@ -166,9 +166,9 @@ nsapi_error_t UBLOX_AT_CellularNetwork::open_data_channel()
|
|||
return err;
|
||||
}
|
||||
|
||||
bool UBLOX_AT_CellularNetwork::activate_profile(const char* apn,
|
||||
const char* username,
|
||||
const char* password)
|
||||
bool UBLOX_AT_CellularNetwork::activate_profile(const char *apn,
|
||||
const char *username,
|
||||
const char *password)
|
||||
{
|
||||
bool activated = false;
|
||||
bool success = false;
|
||||
|
@ -283,7 +283,7 @@ bool UBLOX_AT_CellularNetwork::disconnect_modem_stack()
|
|||
return success;
|
||||
}
|
||||
|
||||
nsapi_error_t UBLOX_AT_CellularNetwork::get_imsi(char* imsi)
|
||||
nsapi_error_t UBLOX_AT_CellularNetwork::get_imsi(char *imsi)
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+CIMI");
|
||||
|
@ -299,7 +299,7 @@ nsapi_error_t UBLOX_AT_CellularNetwork::get_imsi(char* imsi)
|
|||
}
|
||||
|
||||
// Get the next set of credentials, based on IMSI.
|
||||
void UBLOX_AT_CellularNetwork::get_next_credentials(char ** config)
|
||||
void UBLOX_AT_CellularNetwork::get_next_credentials(char **config)
|
||||
{
|
||||
if (*config) {
|
||||
_apn = _APN_GET(*config);
|
||||
|
|
|
@ -21,11 +21,9 @@
|
|||
#include "AT_CellularNetwork.h"
|
||||
#include "APN_db.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class UBLOX_AT_CellularNetwork : public AT_CellularNetwork
|
||||
{
|
||||
class UBLOX_AT_CellularNetwork : public AT_CellularNetwork {
|
||||
public:
|
||||
UBLOX_AT_CellularNetwork(ATHandler &atHandler);
|
||||
virtual ~UBLOX_AT_CellularNetwork();
|
||||
|
@ -69,7 +67,7 @@ private:
|
|||
* NSAPI_SECURITY_CHAP or NSAPI_SECURITY_UNKNOWN).
|
||||
* @return True if successful, otherwise false.
|
||||
*/
|
||||
bool activate_profile(const char* apn, const char* username, const char* password);
|
||||
bool activate_profile(const char *apn, const char *username, const char *password);
|
||||
|
||||
/** Convert nsapi_security_t to the modem security numbers.
|
||||
*
|
||||
|
@ -86,11 +84,11 @@ private:
|
|||
|
||||
/** Read IMSI of modem.
|
||||
*/
|
||||
nsapi_error_t get_imsi(char* imsi);
|
||||
nsapi_error_t get_imsi(char *imsi);
|
||||
|
||||
/** Get the next set of credentials from the database.
|
||||
*/
|
||||
void get_next_credentials(char ** config);
|
||||
void get_next_credentials(char **config);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
|
||||
#include "AT_CellularPower.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class UBLOX_AT_CellularPower : public AT_CellularPower
|
||||
{
|
||||
class UBLOX_AT_CellularPower : public AT_CellularPower {
|
||||
public:
|
||||
UBLOX_AT_CellularPower(ATHandler &atHandler);
|
||||
virtual ~UBLOX_AT_CellularPower();
|
||||
|
|
|
@ -47,11 +47,11 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_accept(void *server, void **socket,
|
|||
// Callback for Socket Read URC.
|
||||
void UBLOX_AT_CellularStack::UUSORD_URC()
|
||||
{
|
||||
int a,b;
|
||||
int a, b;
|
||||
CellularSocket *socket;
|
||||
|
||||
a =_at.read_int();
|
||||
b =_at.read_int();
|
||||
a = _at.read_int();
|
||||
b = _at.read_int();
|
||||
|
||||
socket = find_socket(a);
|
||||
if (socket != NULL) {
|
||||
|
@ -67,11 +67,11 @@ void UBLOX_AT_CellularStack::UUSORD_URC()
|
|||
// Callback for Socket Read From URC.
|
||||
void UBLOX_AT_CellularStack::UUSORF_URC()
|
||||
{
|
||||
int a,b;
|
||||
int a, b;
|
||||
CellularSocket *socket;
|
||||
|
||||
a =_at.read_int();
|
||||
b =_at.read_int();
|
||||
a = _at.read_int();
|
||||
b = _at.read_int();
|
||||
|
||||
socket = find_socket(a);
|
||||
if (socket != NULL) {
|
||||
|
@ -90,7 +90,7 @@ void UBLOX_AT_CellularStack::UUSOCL_URC()
|
|||
int a;
|
||||
CellularSocket *socket;
|
||||
|
||||
a =_at.read_int();
|
||||
a = _at.read_int();
|
||||
socket = find_socket(a);
|
||||
clear_socket(socket);
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void UBLOX_AT_CellularStack::UUPSDD_URC()
|
|||
int a;
|
||||
CellularSocket *socket;
|
||||
|
||||
a =_at.read_int();
|
||||
a = _at.read_int();
|
||||
socket = find_socket(a);
|
||||
clear_socket(socket);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ nsapi_error_t UBLOX_AT_CellularStack::create_socket_impl(CellularSocket *socket)
|
|||
_at.resp_start("+USOCR:");
|
||||
sock_id = _at.read_int();
|
||||
_at.resp_stop();
|
||||
} else if(socket->proto == NSAPI_TCP) {
|
||||
} else if (socket->proto == NSAPI_TCP) {
|
||||
_at.cmd_start("AT+USOCR=6");
|
||||
_at.cmd_stop();
|
||||
|
||||
|
@ -164,7 +164,7 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_connect(nsapi_socket_t handle, cons
|
|||
if (socket) {
|
||||
if (!socket->created) {
|
||||
nsapi_error_t err = create_socket_impl(socket);
|
||||
if(err != NSAPI_ERROR_OK) {
|
||||
if (err != NSAPI_ERROR_OK) {
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ nsapi_error_t UBLOX_AT_CellularStack::socket_close_impl(int sock_id)
|
|||
}
|
||||
|
||||
// Find or create a socket from the list.
|
||||
UBLOX_AT_CellularStack::CellularSocket * UBLOX_AT_CellularStack::find_socket(int id)
|
||||
UBLOX_AT_CellularStack::CellularSocket *UBLOX_AT_CellularStack::find_socket(int id)
|
||||
{
|
||||
CellularSocket *socket = NULL;
|
||||
|
||||
|
@ -428,7 +428,7 @@ UBLOX_AT_CellularStack::CellularSocket * UBLOX_AT_CellularStack::find_socket(int
|
|||
|
||||
|
||||
// Clear out the storage for a socket
|
||||
void UBLOX_AT_CellularStack::clear_socket(CellularSocket * socket)
|
||||
void UBLOX_AT_CellularStack::clear_socket(CellularSocket *socket)
|
||||
{
|
||||
if (socket != NULL) {
|
||||
socket->id = SOCKET_UNUSED;
|
||||
|
@ -439,7 +439,7 @@ void UBLOX_AT_CellularStack::clear_socket(CellularSocket * socket)
|
|||
}
|
||||
}
|
||||
|
||||
const char * UBLOX_AT_CellularStack::get_ip_address()
|
||||
const char *UBLOX_AT_CellularStack::get_ip_address()
|
||||
{
|
||||
_at.lock();
|
||||
_at.cmd_start("AT+UPSND=" PROFILE ",0");
|
||||
|
@ -449,7 +449,7 @@ const char * UBLOX_AT_CellularStack::get_ip_address()
|
|||
if (_at.info_resp()) {
|
||||
_at.skip_param();
|
||||
_at.skip_param();
|
||||
int len = _at.read_string(_ip, NSAPI_IPv4_SIZE-1);
|
||||
int len = _at.read_string(_ip, NSAPI_IPv4_SIZE - 1);
|
||||
if (len == -1) {
|
||||
_ip[0] = '\0';
|
||||
_at.unlock();
|
||||
|
@ -459,7 +459,7 @@ const char * UBLOX_AT_CellularStack::get_ip_address()
|
|||
|
||||
// in case stack type is not IPV4 only, try to look also for IPV6 address
|
||||
if (_stack_type != IPV4_STACK) {
|
||||
len = _at.read_string(_ip, PDP_IPV6_SIZE-1);
|
||||
len = _at.read_string(_ip, PDP_IPV6_SIZE - 1);
|
||||
}
|
||||
}
|
||||
_at.resp_stop();
|
||||
|
|
|
@ -23,11 +23,9 @@
|
|||
#include "drivers/Timer.h"
|
||||
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class UBLOX_AT_CellularStack : public AT_CellularStack
|
||||
{
|
||||
class UBLOX_AT_CellularStack : public AT_CellularStack {
|
||||
public:
|
||||
UBLOX_AT_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
|
||||
virtual ~UBLOX_AT_CellularStack();
|
||||
|
@ -41,7 +39,7 @@ protected:
|
|||
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog);
|
||||
|
||||
virtual nsapi_error_t socket_accept(nsapi_socket_t server,
|
||||
nsapi_socket_t *handle, SocketAddress *address=0);
|
||||
nsapi_socket_t *handle, SocketAddress *address = 0);
|
||||
|
||||
protected: // AT_CellularStack
|
||||
|
||||
|
@ -97,14 +95,14 @@ private:
|
|||
* @param id Socket ID.
|
||||
* @return Socket if True, otherwise NULL.
|
||||
*/
|
||||
CellularSocket * find_socket(int id = SOCKET_UNUSED);
|
||||
CellularSocket *find_socket(int id = SOCKET_UNUSED);
|
||||
|
||||
/** Clear out the storage for a socket.
|
||||
*
|
||||
* @param id Cellular Socket.
|
||||
* @return None
|
||||
*/
|
||||
void clear_socket(CellularSocket * socket);
|
||||
void clear_socket(CellularSocket *socket);
|
||||
};
|
||||
} // namespace mbed
|
||||
#endif /* UBLOX_AT_CELLULARSTACK_H_ */
|
||||
|
|
Loading…
Reference in New Issue