mirror of https://github.com/ARMmbed/mbed-os.git
cellular: astyle fix
parent
8292affb53
commit
cde18aa0bc
|
@ -55,25 +55,25 @@ static void open_close_interfaces()
|
|||
nw = device->open_network(NULL);
|
||||
TEST_ASSERT(nw == NULL);
|
||||
|
||||
CellularSIM* sim = device->open_sim(&cellular_serial);
|
||||
CellularSIM *sim = device->open_sim(&cellular_serial);
|
||||
TEST_ASSERT(sim != NULL);
|
||||
device->close_sim();
|
||||
sim = device->open_sim(NULL);
|
||||
TEST_ASSERT(sim == NULL);
|
||||
|
||||
CellularInformation* info = device->open_information(&cellular_serial);
|
||||
CellularInformation *info = device->open_information(&cellular_serial);
|
||||
TEST_ASSERT(info != NULL);
|
||||
device->close_information();
|
||||
info = device->open_information(NULL);
|
||||
TEST_ASSERT(info == NULL);
|
||||
|
||||
CellularPower* power = device->open_power(&cellular_serial);
|
||||
CellularPower *power = device->open_power(&cellular_serial);
|
||||
TEST_ASSERT(power != NULL);
|
||||
device->close_power();
|
||||
power = device->open_power(NULL);
|
||||
TEST_ASSERT(power == NULL);
|
||||
|
||||
CellularSMS* sms = device->open_sms(&cellular_serial);
|
||||
CellularSMS *sms = device->open_sms(&cellular_serial);
|
||||
TEST_ASSERT(sms != NULL);
|
||||
device->close_sms();
|
||||
sms = device->open_sms(NULL);
|
||||
|
@ -86,7 +86,7 @@ static void other_methods()
|
|||
device->set_timeout(5000);
|
||||
device->modem_debug_on(true);
|
||||
device->modem_debug_on(false);
|
||||
NetworkStack* stack = device->get_stack();
|
||||
NetworkStack *stack = device->get_stack();
|
||||
TEST_ASSERT(stack == NULL);
|
||||
|
||||
CellularNetwork *nw = device->open_network(&cellular_serial);
|
||||
|
@ -124,7 +124,7 @@ static Case cases[] = {
|
|||
|
||||
static utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(10*60, "default_auto");
|
||||
GREENTEA_SETUP(10 * 60, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ static void test_information_interface()
|
|||
{
|
||||
CellularInformation *info = cellular.get_device()->open_information(&cellular_serial);
|
||||
const int kbuf_size = 100;
|
||||
char *buf = (char*)malloc(sizeof(char) * kbuf_size);
|
||||
char *buf = (char *)malloc(sizeof(char) * kbuf_size);
|
||||
|
||||
TEST_ASSERT(info->get_manufacturer(buf, kbuf_size) == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT(info->get_model(buf, kbuf_size) == NSAPI_ERROR_OK);
|
||||
|
@ -112,7 +112,7 @@ static Case cases[] = {
|
|||
|
||||
static utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(10*60, "default_auto");
|
||||
GREENTEA_SETUP(10 * 60, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ static rtos::Semaphore network_semaphore(0);
|
|||
static CellularConnectionFSM cellular;
|
||||
static CellularConnectionFSM::CellularState cellular_target_state;
|
||||
static CELLULAR_DEVICE *device;
|
||||
static CellularNetwork* nw;
|
||||
static CellularNetwork *nw;
|
||||
|
||||
|
||||
static bool fsm_callback(int state, int next_state)
|
||||
|
@ -73,7 +73,7 @@ static void test_network_interface_fsm()
|
|||
device = new CELLULAR_DEVICE(queue);
|
||||
TEST_ASSERT(device != NULL);
|
||||
|
||||
CellularNetwork* nw = device->open_network(&cellular_serial);
|
||||
CellularNetwork *nw = device->open_network(&cellular_serial);
|
||||
TEST_ASSERT(nw != NULL);
|
||||
TEST_ASSERT(nw->init() == NSAPI_ERROR_OK);
|
||||
|
||||
|
@ -99,7 +99,7 @@ static void init_network_interface()
|
|||
|
||||
|
||||
static bool get_network_registration(CellularNetwork::RegistrationType type,
|
||||
CellularNetwork::RegistrationStatus &status, bool &is_registered)
|
||||
CellularNetwork::RegistrationStatus &status, bool &is_registered)
|
||||
{
|
||||
is_registered = false;
|
||||
nsapi_error_t err = nw->get_registration_status(type, status);
|
||||
|
@ -147,7 +147,7 @@ static void nw_callback(nsapi_event_t ev, intptr_t intptr)
|
|||
|
||||
static void test_network_registration()
|
||||
{
|
||||
cellular.get_device()->set_timeout(10*1000);
|
||||
cellular.get_device()->set_timeout(10 * 1000);
|
||||
nw = cellular.get_network();
|
||||
TEST_ASSERT(nw != NULL);
|
||||
|
||||
|
@ -224,8 +224,8 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -234,8 +234,8 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
#endif
|
||||
} else {
|
||||
TEST_ASSERT(uplinkRate >= 0);
|
||||
|
@ -245,10 +245,10 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
|
||||
// scanning of operators might take a long time
|
||||
cellular.get_device()->set_timeout(240*1000);
|
||||
cellular.get_device()->set_timeout(240 * 1000);
|
||||
CellularNetwork::operList_t operators;
|
||||
TEST_ASSERT(nw->scan_plmn(operators, uplinkRate) == NSAPI_ERROR_OK);
|
||||
cellular.get_device()->set_timeout(10*1000);
|
||||
cellular.get_device()->set_timeout(10 * 1000);
|
||||
|
||||
|
||||
// all current targets support IPV4
|
||||
|
@ -262,12 +262,12 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != TELIT_HE910 // TELIT_HE910 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_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
#endif
|
||||
} else {
|
||||
// should have some values, only not optional are apn and bearer id
|
||||
CellularNetwork::pdpcontext_params_t* params = params_list.get_head();
|
||||
CellularNetwork::pdpcontext_params_t *params = params_list.get_head();
|
||||
TEST_ASSERT(strlen(params->apn) > 0);
|
||||
TEST_ASSERT(params->bearer_id >= 0)
|
||||
}
|
||||
|
@ -277,8 +277,8 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
#if CELLULAR_DEVICE != QUECTEL_BG96 // QUECTEL_BG96 does not give any specific reason for device error
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
#endif
|
||||
} else {
|
||||
// we should have some values which are not optional
|
||||
|
@ -290,8 +290,8 @@ static void test_other()
|
|||
err = nw->get_signal_quality(rssi, ber);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
} else {
|
||||
// test for values
|
||||
TEST_ASSERT(rssi >= 0);
|
||||
|
@ -319,10 +319,10 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
// if device error then we must check was that really device error or that modem/network does not support the commands
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 4// 4 == NOT SUPPORTED BY THE MODEM
|
||||
&& ((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 4 // 4 == NOT SUPPORTED BY THE MODEM
|
||||
&& ((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
} else {
|
||||
CellularNetwork::operator_names_t* opn = op_names.get_head();
|
||||
CellularNetwork::operator_names_t *opn = op_names.get_head();
|
||||
TEST_ASSERT(strlen(opn->numeric) > 0);
|
||||
TEST_ASSERT(strlen(opn->alpha > 0));
|
||||
}
|
||||
|
@ -336,8 +336,8 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
// if device error then we must check was that really device error or that modem/network does not support the commands
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
} else {
|
||||
TEST_ASSERT(supported_opt != SUPPORTED_UE_OPT_MAX);
|
||||
TEST_ASSERT(preferred_opt != PREFERRED_UE_OPT_MAX);
|
||||
|
@ -347,8 +347,8 @@ static void test_other()
|
|||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_DEVICE_ERROR);
|
||||
if (err == NSAPI_ERROR_DEVICE_ERROR) {
|
||||
// if device error then we must check was that really device error or that modem/network does not support the commands
|
||||
TEST_ASSERT(((AT_CellularNetwork*)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork*)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
TEST_ASSERT(((AT_CellularNetwork *)nw)->get_device_error().errCode == 100 && // 100 == unknown command for modem
|
||||
((AT_CellularNetwork *)nw)->get_device_error().errType == 3); // 3 == CME error from the modem
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -364,8 +364,8 @@ static void test_disconnect()
|
|||
static void test_detach()
|
||||
{
|
||||
// in PPP mode there is NO CARRIER waiting so flush it out
|
||||
rtos::Thread::wait(6*1000);
|
||||
((AT_CellularNetwork*)nw)->get_at_handler().flush();
|
||||
rtos::Thread::wait(6 * 1000);
|
||||
((AT_CellularNetwork *)nw)->get_at_handler().flush();
|
||||
|
||||
nsapi_connection_status_t st = nw->get_connection_status();
|
||||
TEST_ASSERT(st == NSAPI_STATUS_DISCONNECTED);
|
||||
|
@ -399,7 +399,7 @@ static Case cases[] = {
|
|||
|
||||
static utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(10*60, "default_auto");
|
||||
GREENTEA_SETUP(10 * 60, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,14 +44,14 @@
|
|||
#define NETWORK_TIMEOUT (180*1000)
|
||||
|
||||
static UARTSerial cellular_serial(MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE);
|
||||
static CELLULAR_DEVICE* cellular_device;
|
||||
static CELLULAR_DEVICE *cellular_device;
|
||||
static EventQueue queue(2 * EVENTS_EVENT_SIZE);
|
||||
|
||||
static void urc_callback()
|
||||
{
|
||||
}
|
||||
|
||||
static void wait_for_power(CellularPower* pwr)
|
||||
static void wait_for_power(CellularPower *pwr)
|
||||
{
|
||||
nsapi_error_t err = pwr->set_device_ready_urc_cb(&urc_callback);
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
|
@ -72,13 +72,13 @@ static void wait_for_power(CellularPower* pwr)
|
|||
static void test_power_interface()
|
||||
{
|
||||
cellular_device = new CELLULAR_DEVICE(queue);
|
||||
CellularPower* pwr = cellular_device->open_power(&cellular_serial);
|
||||
CellularPower *pwr = cellular_device->open_power(&cellular_serial);
|
||||
|
||||
nsapi_error_t err = pwr->on();
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK || err == NSAPI_ERROR_UNSUPPORTED);
|
||||
wait_for_power(pwr);
|
||||
|
||||
TEST_ASSERT(pwr->set_power_level(1,0) == NSAPI_ERROR_OK);
|
||||
TEST_ASSERT(pwr->set_power_level(1, 0) == NSAPI_ERROR_OK);
|
||||
|
||||
err = pwr->reset();
|
||||
TEST_ASSERT(err == NSAPI_ERROR_OK);
|
||||
|
@ -102,7 +102,7 @@ static Case cases[] = {
|
|||
|
||||
static utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(10*60, "default_auto");
|
||||
GREENTEA_SETUP(10 * 60, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ static char *get_rand_string(char *str, size_t size)
|
|||
if (size) {
|
||||
--size;
|
||||
for (size_t n = 0; n < size; n++) {
|
||||
int key = rand() % (int) (sizeof charset - 1);
|
||||
int key = rand() % (int)(sizeof charset - 1);
|
||||
str[n] = charset[key];
|
||||
}
|
||||
str[size] = '\0';
|
||||
|
@ -144,7 +144,7 @@ static Case cases[] = {
|
|||
|
||||
static utest::v1::status_t test_setup(const size_t number_of_cases)
|
||||
{
|
||||
GREENTEA_SETUP(10*60, "default_auto");
|
||||
GREENTEA_SETUP(10 * 60, "default_auto");
|
||||
return verbose_test_setup_handler(number_of_cases);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,15 +20,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularBase)
|
||||
{
|
||||
Test_AT_CellularBase* unit;
|
||||
Test_AT_CellularBase *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularBase();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -27,9 +27,11 @@ using namespace events;
|
|||
|
||||
class my_base : public AT_CellularBase {
|
||||
public:
|
||||
my_base(ATHandler &at) : AT_CellularBase(at) {
|
||||
my_base(ATHandler &at) : AT_CellularBase(at)
|
||||
{
|
||||
}
|
||||
bool check_not_supported() {
|
||||
bool check_not_supported()
|
||||
{
|
||||
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
|
||||
AT_CellularBase::AT_CGSN_WITH_TYPE,
|
||||
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
|
||||
|
@ -38,12 +40,14 @@ public:
|
|||
return is_supported(AT_CGSN_WITH_TYPE);
|
||||
}
|
||||
|
||||
bool check_supported() {
|
||||
bool check_supported()
|
||||
{
|
||||
set_unsupported_features(NULL);
|
||||
return is_supported(AT_CGSN_WITH_TYPE);
|
||||
}
|
||||
|
||||
bool check_supported_not_found() {
|
||||
bool check_supported_not_found()
|
||||
{
|
||||
static const AT_CellularBase::SupportedFeature unsupported_features[] = {
|
||||
AT_CellularBase::AT_CGSN_WITH_TYPE,
|
||||
AT_CellularBase::SUPPORTED_FEATURE_END_MARK
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARBASE_H
|
||||
#define TEST_AT_CELLULARBASE_H
|
||||
|
||||
class Test_AT_CellularBase
|
||||
{
|
||||
class Test_AT_CellularBase {
|
||||
public:
|
||||
Test_AT_CellularBase();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularDevice)
|
||||
{
|
||||
Test_AT_CellularDevice* unit;
|
||||
Test_AT_CellularDevice *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularDevice();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARDEVICE_H
|
||||
#define TEST_AT_CELLULARDEVICE_H
|
||||
|
||||
class Test_AT_CellularDevice
|
||||
{
|
||||
class Test_AT_CellularDevice {
|
||||
public:
|
||||
Test_AT_CellularDevice();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularInformation)
|
||||
{
|
||||
Test_AT_CellularInformation* unit;
|
||||
Test_AT_CellularInformation *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularInformation();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARINFORMATION_H
|
||||
#define TEST_AT_CELLULARINFORMATION_H
|
||||
|
||||
class Test_AT_CellularInformation
|
||||
{
|
||||
class Test_AT_CellularInformation {
|
||||
public:
|
||||
Test_AT_CellularInformation();
|
||||
|
||||
|
|
|
@ -20,18 +20,16 @@
|
|||
|
||||
TEST_GROUP(AT_CellularNetwork)
|
||||
{
|
||||
Test_AT_CellularNetwork* unit;
|
||||
Test_AT_CellularNetwork *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularNetwork();
|
||||
ATHandler_stub::int_count = kRead_int_table_size;
|
||||
ATHandler_stub::read_string_index = kRead_string_table_size;
|
||||
ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -29,38 +29,66 @@
|
|||
using namespace mbed;
|
||||
using namespace events;
|
||||
|
||||
class my_stack :public AT_CellularStack {
|
||||
class my_stack : public AT_CellularStack {
|
||||
public:
|
||||
my_stack(ATHandler &atHandler) : AT_CellularStack(atHandler, 1, IPV4_STACK) {}
|
||||
virtual int get_max_socket_count() { return 1;}
|
||||
virtual int get_max_packet_size() {return 200;}
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol) {return true;}
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id) {return NSAPI_ERROR_OK;}
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket) {return NSAPI_ERROR_OK;}
|
||||
virtual int get_max_socket_count()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
virtual int get_max_packet_size()
|
||||
{
|
||||
return 200;
|
||||
}
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size) {return 100;}
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size) {return 100;}
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
};
|
||||
|
||||
class my_AT_CN : public AT_CellularNetwork {
|
||||
public:
|
||||
my_AT_CN(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
|
||||
virtual ~my_AT_CN() {}
|
||||
NetworkStack *get_stack() {
|
||||
NetworkStack *get_stack()
|
||||
{
|
||||
if (!_stack) {
|
||||
return new my_stack(get_at_handler());
|
||||
} else {
|
||||
return _stack;
|
||||
}}
|
||||
virtual bool has_registration(RegistrationType reg_type) {
|
||||
}
|
||||
}
|
||||
virtual bool has_registration(RegistrationType reg_type)
|
||||
{
|
||||
if (reg_type == C_GREG) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat) { return NSAPI_ERROR_OK;}
|
||||
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack) {
|
||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack)
|
||||
{
|
||||
if (requested_stack == IPV4_STACK || requested_stack == DEFAULT_STACK) {
|
||||
return true;
|
||||
}
|
||||
|
@ -72,20 +100,27 @@ class my_AT_CNipv6 : public AT_CellularNetwork {
|
|||
public:
|
||||
my_AT_CNipv6(ATHandler &atHandler) : AT_CellularNetwork(atHandler) {}
|
||||
virtual ~my_AT_CNipv6() {}
|
||||
NetworkStack *get_stack() {
|
||||
NetworkStack *get_stack()
|
||||
{
|
||||
if (!_stack) {
|
||||
return new my_stack(get_at_handler());
|
||||
} else {
|
||||
return _stack;
|
||||
}}
|
||||
virtual bool has_registration(RegistrationType reg_type) {
|
||||
}
|
||||
}
|
||||
virtual bool has_registration(RegistrationType reg_type)
|
||||
{
|
||||
if (reg_type == C_GREG) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat) { return NSAPI_ERROR_OK;}
|
||||
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack) {
|
||||
virtual nsapi_error_t set_access_technology_impl(RadioAccessTechnology op_rat)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
virtual bool get_modem_stack_type(nsapi_ip_stack_t requested_stack)
|
||||
{
|
||||
if (requested_stack == IPV6_STACK || requested_stack == DEFAULT_STACK) {
|
||||
return true;
|
||||
}
|
||||
|
@ -194,7 +229,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_activate_context()
|
|||
CHECK(NSAPI_ERROR_OK == my_cn.set_credentials("apn", CellularNetwork::CHAP, "user", "passwd"));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.activate_context());
|
||||
|
||||
// get_context return true and new context created, test delete context
|
||||
// get_context return true and new context created, test delete context
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
ATHandler_stub::bool_value = false;
|
||||
ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
|
||||
|
@ -264,7 +299,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_activate_context()
|
|||
ATHandler_stub::read_string_table[0] = "internet";
|
||||
ATHandler_stub::read_string_table[1] = "IPV4V6";
|
||||
ATHandler_stub::int_value = 1;
|
||||
CHECK(NSAPI_ERROR_OK ==my_cn.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.set_credentials("internet"));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.activate_context());
|
||||
|
||||
|
@ -276,7 +311,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_activate_context()
|
|||
ATHandler_stub::read_string_table[0] = "internet";
|
||||
ATHandler_stub::read_string_table[1] = "IPV4V6";
|
||||
ATHandler_stub::int_value = 1;
|
||||
CHECK(NSAPI_ERROR_OK ==my_cnipv6.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.set_credentials("internet"));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.activate_context());
|
||||
|
||||
|
@ -288,7 +323,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_activate_context()
|
|||
ATHandler_stub::read_string_table[0] = "internet";
|
||||
ATHandler_stub::read_string_table[1] = "IPV6";
|
||||
ATHandler_stub::int_value = 1;
|
||||
CHECK(NSAPI_ERROR_OK ==my_cnipv6.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.set_credentials("internet"));
|
||||
CHECK(NSAPI_ERROR_OK == my_cnipv6.activate_context());
|
||||
|
||||
|
@ -300,7 +335,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_activate_context()
|
|||
ATHandler_stub::read_string_table[0] = "internet";
|
||||
ATHandler_stub::read_string_table[1] = "IP";
|
||||
ATHandler_stub::int_value = 1;
|
||||
CHECK(NSAPI_ERROR_OK ==my_cn.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.set_stack_type(DEFAULT_STACK));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.set_credentials("internet"));
|
||||
CHECK(NSAPI_ERROR_OK == my_cn.activate_context());
|
||||
|
||||
|
@ -366,7 +401,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_stack()
|
|||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
my_AT_CN my_cn(at);
|
||||
my_stack* mystack = (my_stack*)my_cn.get_stack();
|
||||
my_stack *mystack = (my_stack *)my_cn.get_stack();
|
||||
CHECK(mystack);
|
||||
delete mystack;
|
||||
}
|
||||
|
@ -763,7 +798,7 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_scan_plmn()
|
|||
CHECK(NSAPI_ERROR_OK == cn.scan_plmn(ops, c));
|
||||
CHECK(c == 1);
|
||||
CHECK(ops.get_head() != NULL);
|
||||
CellularNetwork::operator_t* op = ops.get_head();
|
||||
CellularNetwork::operator_t *op = ops.get_head();
|
||||
CHECK(op->op_status == CellularNetwork::operator_t::Available);
|
||||
CHECK(strcmp(op->op_long, "12345") == 0);
|
||||
CHECK(strcmp(op->op_short, "33333") == 0);
|
||||
|
@ -921,12 +956,12 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_extended_signal_qualit
|
|||
AT_CellularNetwork cn(at);
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
|
||||
int rx = -1, be = -1, rs = -1, ec = -1, rsrq = -1, rsrp = -1;
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == cn.get_extended_signal_quality(rx, be,rs,ec,rsrq, rsrp));
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == cn.get_extended_signal_quality(rx, be, rs, ec, rsrq, rsrp));
|
||||
CHECK(rx == -1 && be == -1 && rs == -1 && ec == -1 && rsrq == -1 && rsrp == -1);
|
||||
|
||||
ATHandler_stub::int_value = 5;
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
CHECK(NSAPI_ERROR_OK == cn.get_extended_signal_quality(rx, be,rs,ec,rsrq, rsrp));
|
||||
CHECK(NSAPI_ERROR_OK == cn.get_extended_signal_quality(rx, be, rs, ec, rsrq, rsrp));
|
||||
CHECK(rx == 5 && be == 5 && rs == 5 && ec == 5 && rsrq == 5 && rsrp == 5);
|
||||
}
|
||||
|
||||
|
@ -939,12 +974,12 @@ void Test_AT_CellularNetwork::test_AT_CellularNetwork_get_signal_quality()
|
|||
AT_CellularNetwork cn(at);
|
||||
int rs = -1, ber = -1;
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == cn.get_signal_quality(rs,ber));
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == cn.get_signal_quality(rs, ber));
|
||||
CHECK(rs == -1 && ber == -1);
|
||||
|
||||
ATHandler_stub::int_value = 1;
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
CHECK(NSAPI_ERROR_OK == cn.get_signal_quality(rs,ber));
|
||||
CHECK(NSAPI_ERROR_OK == cn.get_signal_quality(rs, ber));
|
||||
CHECK(rs == 1 && ber == 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARNETWORK_H
|
||||
#define TEST_AT_CELLULARNETWORK_H
|
||||
|
||||
class Test_AT_CellularNetwork
|
||||
{
|
||||
class Test_AT_CellularNetwork {
|
||||
public:
|
||||
Test_AT_CellularNetwork();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularPower)
|
||||
{
|
||||
Test_AT_CellularPower* unit;
|
||||
Test_AT_CellularPower *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularPower();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ void Test_AT_CellularPower::test_AT_CellularPower_set_power_level()
|
|||
AT_CellularPower pow(at);
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
CHECK(NSAPI_ERROR_OK == pow.set_power_level(6));
|
||||
CHECK(NSAPI_ERROR_OK == pow.set_power_level(1,1));
|
||||
CHECK(NSAPI_ERROR_OK == pow.set_power_level(1,0));
|
||||
CHECK(NSAPI_ERROR_OK == pow.set_power_level(1, 1));
|
||||
CHECK(NSAPI_ERROR_OK == pow.set_power_level(1, 0));
|
||||
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == pow.set_power_level(6));
|
||||
|
@ -119,24 +119,24 @@ void Test_AT_CellularPower::test_AT_CellularPower_opt_power_save_mode()
|
|||
|
||||
AT_CellularPower pow(at);
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_OK;
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(0,0));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(0, 0));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(10,0));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(10, 0));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(912,0));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(912, 0));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(1834,1834));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(1834, 1834));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(18345,18345));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(18345, 18345));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(101234,101234));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(101234, 101234));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(1012345,1012345));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(1012345, 1012345));
|
||||
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(39612345,39612345));
|
||||
CHECK(NSAPI_ERROR_OK == pow.opt_power_save_mode(39612345, 39612345));
|
||||
|
||||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == pow.opt_power_save_mode(0,0));
|
||||
CHECK(NSAPI_ERROR_DEVICE_ERROR == pow.opt_power_save_mode(0, 0));
|
||||
}
|
||||
|
||||
void Test_AT_CellularPower::test_AT_CellularPower_opt_receive_period()
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARPOWER_H
|
||||
#define TEST_AT_CELLULARPOWER_H
|
||||
|
||||
class Test_AT_CellularPower
|
||||
{
|
||||
class Test_AT_CellularPower {
|
||||
public:
|
||||
Test_AT_CellularPower();
|
||||
|
||||
|
|
|
@ -20,16 +20,14 @@
|
|||
|
||||
TEST_GROUP(AT_CellularSIM)
|
||||
{
|
||||
Test_AT_CellularSIM* unit;
|
||||
Test_AT_CellularSIM *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularSIM();
|
||||
ATHandler_stub::read_string_index = kRead_string_table_size;
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARSIM_H
|
||||
#define TEST_AT_CELLULARSIM_H
|
||||
|
||||
class Test_AT_CellularSIM
|
||||
{
|
||||
class Test_AT_CellularSIM {
|
||||
public:
|
||||
Test_AT_CellularSIM();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularSMS)
|
||||
{
|
||||
Test_AT_CellularSMS* unit;
|
||||
Test_AT_CellularSMS *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularSMS();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARSMS_H
|
||||
#define TEST_AT_CELLULARSMS_H
|
||||
|
||||
class Test_AT_CellularSMS
|
||||
{
|
||||
class Test_AT_CellularSMS {
|
||||
public:
|
||||
Test_AT_CellularSMS();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(AT_CellularStack)
|
||||
{
|
||||
Test_AT_CellularStack* unit;
|
||||
Test_AT_CellularStack *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_AT_CellularStack();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -43,46 +43,97 @@ public:
|
|||
create_error = NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
virtual int get_max_socket_count(){return max_sock_value;}
|
||||
virtual int get_max_socket_count()
|
||||
{
|
||||
return max_sock_value;
|
||||
}
|
||||
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol){return bool_value;}
|
||||
virtual bool is_protocol_supported(nsapi_protocol_t protocol)
|
||||
{
|
||||
return bool_value;
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id){return NSAPI_ERROR_OK;}
|
||||
virtual nsapi_error_t socket_close_impl(int sock_id)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket){return create_error;}
|
||||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket)
|
||||
{
|
||||
return create_error;
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size){return NSAPI_ERROR_OK;}
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size) {return NSAPI_ERROR_OK;}
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto) {return AT_CellularStack::socket_open(handle, proto);}
|
||||
virtual nsapi_error_t socket_open(nsapi_socket_t *handle, nsapi_protocol_t proto)
|
||||
{
|
||||
return AT_CellularStack::socket_open(handle, proto);
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_close(nsapi_socket_t handle) {return AT_CellularStack::socket_close(handle);}
|
||||
virtual nsapi_error_t socket_close(nsapi_socket_t handle)
|
||||
{
|
||||
return AT_CellularStack::socket_close(handle);
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address) {return AT_CellularStack::socket_bind(handle, address);}
|
||||
virtual nsapi_error_t socket_bind(nsapi_socket_t handle, const SocketAddress &address)
|
||||
{
|
||||
return AT_CellularStack::socket_bind(handle, address);
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog) {return AT_CellularStack::socket_listen(handle, backlog);}
|
||||
virtual nsapi_error_t socket_listen(nsapi_socket_t handle, int backlog)
|
||||
{
|
||||
return AT_CellularStack::socket_listen(handle, backlog);
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address) {return AT_CellularStack::socket_connect(handle, address);}
|
||||
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address)
|
||||
{
|
||||
return AT_CellularStack::socket_connect(handle, address);
|
||||
}
|
||||
|
||||
virtual nsapi_error_t socket_accept(nsapi_socket_t server,
|
||||
nsapi_socket_t *handle, SocketAddress *address=0) {return AT_CellularStack::socket_accept(server, handle, address);}
|
||||
nsapi_socket_t *handle, SocketAddress *address = 0)
|
||||
{
|
||||
return AT_CellularStack::socket_accept(server, handle, address);
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
|
||||
const void *data, nsapi_size_t size) {return AT_CellularStack::socket_send(handle, data, size);}
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
return AT_CellularStack::socket_send(handle, data, size);
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
|
||||
void *data, nsapi_size_t size) {return AT_CellularStack::socket_recv(handle, data, size);}
|
||||
void *data, nsapi_size_t size)
|
||||
{
|
||||
return AT_CellularStack::socket_recv(handle, data, size);
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_sendto(nsapi_socket_t handle, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size) {return AT_CellularStack::socket_sendto(handle, address, data, size);}
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
return AT_CellularStack::socket_sendto(handle, address, data, size);
|
||||
}
|
||||
|
||||
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size) {return AT_CellularStack::socket_recvfrom(handle, address, buffer, size);}
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
return AT_CellularStack::socket_recvfrom(handle, address, buffer, size);
|
||||
}
|
||||
|
||||
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data) {return AT_CellularStack::socket_attach(handle, callback, data);}
|
||||
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data)
|
||||
{
|
||||
return AT_CellularStack::socket_attach(handle, callback, data);
|
||||
}
|
||||
};
|
||||
|
||||
Test_AT_CellularStack::Test_AT_CellularStack()
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_AT_CELLULARSTACK_H
|
||||
#define TEST_AT_CELLULARSTACK_H
|
||||
|
||||
class Test_AT_CellularStack
|
||||
{
|
||||
class Test_AT_CellularStack {
|
||||
public:
|
||||
Test_AT_CellularStack();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(ATHandler)
|
||||
{
|
||||
Test_ATHandler* unit;
|
||||
Test_ATHandler *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_ATHandler();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ void Test_ATHandler::test_ATHandler_write_int()
|
|||
|
||||
at.write_int(2147483647);
|
||||
|
||||
at.write_int(2147483647+1);
|
||||
at.write_int(2147483647 + 1);
|
||||
|
||||
// at.at_error(0, DeviceErrorType(0));
|
||||
// at.write_int(4);
|
||||
|
@ -562,7 +562,7 @@ void Test_ATHandler::test_ATHandler_read_string()
|
|||
CHECK(NSAPI_ERROR_OK == at.get_last_error());
|
||||
// To read 0 bytes from: s\r\n
|
||||
CHECK(0 == at.read_string(buf3, 0 + 1/*for NULL*/));
|
||||
// To read 1 byte from: s\r\n -> read s
|
||||
// To read 1 byte from: s\r\n -> read s
|
||||
CHECK(1 == at.read_string(buf3, 1 + 1/*for NULL*/));
|
||||
|
||||
// *** Reading more than available in buffer ***
|
||||
|
@ -780,7 +780,7 @@ void Test_ATHandler::test_ATHandler_read_int()
|
|||
|
||||
ATHandler at(&fh1, que, 0, ",");
|
||||
|
||||
int32_t ret= at.read_int();
|
||||
int32_t ret = at.read_int();
|
||||
CHECK(-1 == ret);
|
||||
at.clear_error();
|
||||
|
||||
|
@ -792,7 +792,7 @@ void Test_ATHandler::test_ATHandler_read_int()
|
|||
|
||||
at.resp_start();
|
||||
|
||||
ret= at.read_int();
|
||||
ret = at.read_int();
|
||||
CHECK(-1 == ret);
|
||||
at.flush();
|
||||
at.clear_error();
|
||||
|
@ -805,7 +805,7 @@ void Test_ATHandler::test_ATHandler_read_int()
|
|||
|
||||
at.resp_start();
|
||||
|
||||
ret= at.read_int();
|
||||
ret = at.read_int();
|
||||
CHECK(2 == ret);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_ATHANDLER_H
|
||||
#define TEST_ATHANDLER_H
|
||||
|
||||
class Test_ATHandler
|
||||
{
|
||||
class Test_ATHandler {
|
||||
public:
|
||||
Test_ATHandler();
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "CppUTest/TestPlugin.h"
|
||||
#include "CppUTest/TestRegistry.h"
|
||||
#include "CppUTestExt/MockSupportPlugin.h"
|
||||
int main(int ac, char** av)
|
||||
int main(int ac, char **av)
|
||||
{
|
||||
return CommandLineTestRunner::RunAllTests(ac, av);
|
||||
}
|
||||
|
|
|
@ -116,7 +116,7 @@ void Test_util::test_util_prefer_ipv6()
|
|||
|
||||
void Test_util::test_util_separate_ip_addresses()
|
||||
{
|
||||
char* s = (char*)malloc(128);
|
||||
char *s = (char *)malloc(128);
|
||||
|
||||
char ip[64] = {0};
|
||||
char subnet[64] = {0};
|
||||
|
|
|
@ -17,8 +17,7 @@
|
|||
#ifndef TEST_UTIL_H
|
||||
#define TEST_UTIL_H
|
||||
|
||||
class Test_util
|
||||
{
|
||||
class Test_util {
|
||||
public:
|
||||
Test_util();
|
||||
|
||||
|
|
|
@ -19,15 +19,13 @@
|
|||
|
||||
TEST_GROUP(util)
|
||||
{
|
||||
Test_util* unit;
|
||||
Test_util *unit;
|
||||
|
||||
void setup()
|
||||
{
|
||||
void setup() {
|
||||
unit = new Test_util();
|
||||
}
|
||||
|
||||
void teardown()
|
||||
{
|
||||
void teardown() {
|
||||
delete unit;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -76,7 +76,7 @@ void ATCmdParser::flush()
|
|||
int ATCmdParser::write(const char *data, int size)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < size; i++) {
|
||||
for (; i < size; i++) {
|
||||
if (putc(data[i]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ int ATCmdParser::write(const char *data, int size)
|
|||
int ATCmdParser::read(char *data, int size)
|
||||
{
|
||||
int i = 0;
|
||||
for ( ; i < size; i++) {
|
||||
for (; i < size; i++) {
|
||||
int c = getc();
|
||||
if (c < 0) {
|
||||
return -1;
|
||||
|
@ -107,7 +107,7 @@ int ATCmdParser::vprintf(const char *format, va_list args)
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
for ( ; _buffer[i]; i++) {
|
||||
for (; _buffer[i]; i++) {
|
||||
if (putc(_buffer[i]) < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
int offset = 0;
|
||||
|
||||
while (format[i]) {
|
||||
if (format[i] == '%' && format[i+1] != '%' && format[i+1] != '*') {
|
||||
if (format[i] == '%' && format[i + 1] != '%' && format[i + 1] != '*') {
|
||||
_buffer[offset++] = '%';
|
||||
_buffer[offset++] = '*';
|
||||
i++;
|
||||
|
@ -152,7 +152,7 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
|
||||
while (true) {
|
||||
// Ran out of space
|
||||
if (j+1 >= _buffer_size - offset) {
|
||||
if (j + 1 >= _buffer_size - offset) {
|
||||
return false;
|
||||
}
|
||||
// Recieve next character
|
||||
|
@ -165,12 +165,12 @@ int ATCmdParser::vscanf(const char *format, va_list args)
|
|||
|
||||
// Check for match
|
||||
int count = -1;
|
||||
sscanf(_buffer+offset, _buffer, &count);
|
||||
sscanf(_buffer + offset, _buffer, &count);
|
||||
|
||||
// We only succeed if all characters in the response are matched
|
||||
if (count == j) {
|
||||
// Store the found results
|
||||
vsscanf(_buffer+offset, format, args);
|
||||
vsscanf(_buffer + offset, format, args);
|
||||
return j;
|
||||
}
|
||||
}
|
||||
|
@ -217,14 +217,14 @@ restart:
|
|||
bool whole_line_wanted = false;
|
||||
|
||||
while (response[i]) {
|
||||
if (response[i] == '%' && response[i+1] != '%' && response[i+1] != '*') {
|
||||
if (response[i] == '%' && response[i + 1] != '%' && response[i + 1] != '*') {
|
||||
_buffer[offset++] = '%';
|
||||
_buffer[offset++] = '*';
|
||||
i++;
|
||||
} else {
|
||||
_buffer[offset++] = response[i++];
|
||||
// Find linebreaks, taking care not to be fooled if they're in a %[^\n] conversion specification
|
||||
if (response[i - 1] == '\n' && !(i >= 3 && response[i-3] == '[' && response[i-2] == '^')) {
|
||||
if (response[i - 1] == '\n' && !(i >= 3 && response[i - 3] == '[' && response[i - 2] == '^')) {
|
||||
whole_line_wanted = true;
|
||||
break;
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ restart:
|
|||
}
|
||||
// Simplify newlines (borrowed from retarget.cpp)
|
||||
if ((c == CR && _in_prev != LF) ||
|
||||
(c == LF && _in_prev != CR)) {
|
||||
(c == LF && _in_prev != CR)) {
|
||||
_in_prev = c;
|
||||
c = '\n';
|
||||
} else if ((c == CR && _in_prev == LF) ||
|
||||
|
@ -274,7 +274,7 @@ restart:
|
|||
// Check for oob data
|
||||
for (struct oob *oob = _oobs; oob; oob = oob->next) {
|
||||
if ((unsigned)j == oob->len && memcmp(
|
||||
oob->prefix, _buffer+offset, oob->len) == 0) {
|
||||
oob->prefix, _buffer + offset, oob->len) == 0) {
|
||||
debug_if(_dbg_on, "AT! %s\n", oob->prefix);
|
||||
oob->cb();
|
||||
|
||||
|
@ -295,18 +295,18 @@ restart:
|
|||
// This allows recv("Foo: %s\n") to work, and not match with just the first character of a string
|
||||
// (scanf does not itself match whitespace in its format string, so \n is not significant to it)
|
||||
} else {
|
||||
sscanf(_buffer+offset, _buffer, &count);
|
||||
sscanf(_buffer + offset, _buffer, &count);
|
||||
}
|
||||
|
||||
// We only succeed if all characters in the response are matched
|
||||
if (count == j) {
|
||||
debug_if(_dbg_on, "AT= %s\n", _buffer+offset);
|
||||
debug_if(_dbg_on, "AT= %s\n", _buffer + offset);
|
||||
// Reuse the front end of the buffer
|
||||
memcpy(_buffer, response, i);
|
||||
_buffer[i] = 0;
|
||||
|
||||
// Store the found results
|
||||
vsscanf(_buffer+offset, _buffer, args);
|
||||
vsscanf(_buffer + offset, _buffer, args);
|
||||
|
||||
// Jump to next line and continue parsing
|
||||
response += i;
|
||||
|
@ -315,8 +315,8 @@ restart:
|
|||
|
||||
// Clear the buffer when we hit a newline or ran out of space
|
||||
// running out of space usually means we ran into binary data
|
||||
if (c == '\n' || j+1 >= _buffer_size - offset) {
|
||||
debug_if(_dbg_on, "AT< %s", _buffer+offset);
|
||||
if (c == '\n' || j + 1 >= _buffer_size - offset) {
|
||||
debug_if(_dbg_on, "AT< %s", _buffer + offset);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
|
@ -398,18 +398,18 @@ bool ATCmdParser::process_oob()
|
|||
struct oob *oob = _oobs;
|
||||
while (oob) {
|
||||
if (i == (int)oob->len && memcmp(
|
||||
oob->prefix, _buffer, oob->len) == 0) {
|
||||
oob->prefix, _buffer, oob->len) == 0) {
|
||||
debug_if(_dbg_on, "AT! %s\r\n", oob->prefix);
|
||||
oob->cb();
|
||||
return true;
|
||||
}
|
||||
oob = oob->next;
|
||||
}
|
||||
|
||||
|
||||
// Clear the buffer when we hit a newline or ran out of space
|
||||
// running out of space usually means we ran into binary data
|
||||
if (i+1 >= _buffer_size ||
|
||||
strcmp(&_buffer[i-_output_delim_size], _output_delimiter) == 0) {
|
||||
if (i + 1 >= _buffer_size ||
|
||||
strcmp(&_buffer[i - _output_delim_size], _output_delimiter) == 0) {
|
||||
|
||||
debug_if(_dbg_on, "AT< %s", _buffer);
|
||||
i = 0;
|
||||
|
|
|
@ -36,7 +36,7 @@ int ATHandler_stub::timeout = 0;
|
|||
bool ATHandler_stub::default_timeout = 0;
|
||||
bool ATHandler_stub::debug_on = 0;
|
||||
ssize_t ATHandler_stub::ssize_value = 0;
|
||||
char* ATHandler_stub::read_string_value = NULL;
|
||||
char *ATHandler_stub::read_string_value = NULL;
|
||||
size_t ATHandler_stub::size_value = 0;
|
||||
size_t ATHandler_stub::return_given_size = false;
|
||||
bool ATHandler_stub::bool_value = false;
|
||||
|
@ -50,7 +50,7 @@ int ATHandler_stub::int_valid_count_table[kRead_int_table_size];
|
|||
int ATHandler_stub::int_count = kRead_int_table_size;
|
||||
|
||||
int ATHandler_stub::read_string_index = kRead_string_table_size;
|
||||
char* ATHandler_stub::read_string_table[kRead_string_table_size];
|
||||
char *ATHandler_stub::read_string_table[kRead_string_table_size];
|
||||
int ATHandler_stub::resp_stop_success_count = kResp_stop_count_default;
|
||||
|
||||
ATHandler::ATHandler(FileHandle *fh, EventQueue &queue, int timeout, const char *output_delimiter, uint16_t send_delay) :
|
||||
|
@ -146,7 +146,8 @@ void ATHandler::clear_error()
|
|||
ATHandler_stub::nsapi_error_ok_counter++;
|
||||
}
|
||||
|
||||
void ATHandler::skip_param(uint32_t count) {
|
||||
void ATHandler::skip_param(uint32_t count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
@ -164,16 +165,16 @@ ssize_t ATHandler::read_string(char *buf, size_t size, bool read_even_stop_tag)
|
|||
|
||||
if (ATHandler_stub::read_string_index == kRead_string_table_size) {
|
||||
if (ATHandler_stub::read_string_value && ATHandler_stub::ssize_value >= 0) {
|
||||
memcpy(buf, ATHandler_stub::read_string_value, ATHandler_stub::ssize_value+1);
|
||||
memcpy(buf, ATHandler_stub::read_string_value, ATHandler_stub::ssize_value + 1);
|
||||
}
|
||||
return ATHandler_stub::ssize_value;
|
||||
}
|
||||
|
||||
ATHandler_stub::read_string_index--;
|
||||
if (ATHandler_stub::read_string_index >= 0) {
|
||||
char* tmp = ATHandler_stub::read_string_table[ATHandler_stub::read_string_index];
|
||||
char *tmp = ATHandler_stub::read_string_table[ATHandler_stub::read_string_index];
|
||||
ssize_t len = strlen(tmp);
|
||||
memcpy(buf, tmp, len+1);
|
||||
memcpy(buf, tmp, len + 1);
|
||||
return len;
|
||||
}
|
||||
|
||||
|
@ -254,7 +255,7 @@ void ATHandler::resp_stop()
|
|||
ATHandler_stub::nsapi_error_value = NSAPI_ERROR_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
void ATHandler::cmd_start(const char* cmd)
|
||||
void ATHandler::cmd_start(const char *cmd)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -262,11 +263,11 @@ void ATHandler::write_int(int32_t param)
|
|||
{
|
||||
}
|
||||
|
||||
void ATHandler::write_string(const char* param, bool useQuotations)
|
||||
void ATHandler::write_string(const char *param, bool useQuotations)
|
||||
{
|
||||
}
|
||||
|
||||
size_t ATHandler::write_bytes(const uint8_t* param, size_t len)
|
||||
size_t ATHandler::write_bytes(const uint8_t *param, size_t len)
|
||||
{
|
||||
if (ATHandler_stub::return_given_size) {
|
||||
return len;
|
||||
|
|
|
@ -28,27 +28,27 @@ static const int kRead_int_table_size = 100;
|
|||
static const int kResp_stop_count_default = 100;
|
||||
|
||||
namespace ATHandler_stub {
|
||||
extern nsapi_error_t nsapi_error_value;
|
||||
extern uint8_t nsapi_error_ok_counter;
|
||||
extern int int_value;
|
||||
extern int ref_count;
|
||||
extern int timeout;
|
||||
extern bool default_timeout;
|
||||
extern bool debug_on;
|
||||
extern ssize_t ssize_value;
|
||||
extern char *read_string_value;
|
||||
extern size_t size_value;
|
||||
extern size_t return_given_size;
|
||||
extern bool bool_value;
|
||||
extern uint8_t resp_info_true_counter;
|
||||
extern uint8_t info_elem_true_counter;
|
||||
extern uint8_t uint8_value;
|
||||
extern mbed::FileHandle_stub *fh_value;
|
||||
extern mbed::device_err_t device_err_value;
|
||||
extern mbed::Callback<void()> callback;
|
||||
extern char *read_string_table[kRead_string_table_size];
|
||||
extern int read_string_index;
|
||||
extern int int_valid_count_table[kRead_int_table_size];
|
||||
extern int int_count;
|
||||
extern int resp_stop_success_count;
|
||||
extern nsapi_error_t nsapi_error_value;
|
||||
extern uint8_t nsapi_error_ok_counter;
|
||||
extern int int_value;
|
||||
extern int ref_count;
|
||||
extern int timeout;
|
||||
extern bool default_timeout;
|
||||
extern bool debug_on;
|
||||
extern ssize_t ssize_value;
|
||||
extern char *read_string_value;
|
||||
extern size_t size_value;
|
||||
extern size_t return_given_size;
|
||||
extern bool bool_value;
|
||||
extern uint8_t resp_info_true_counter;
|
||||
extern uint8_t info_elem_true_counter;
|
||||
extern uint8_t uint8_value;
|
||||
extern mbed::FileHandle_stub *fh_value;
|
||||
extern mbed::device_err_t device_err_value;
|
||||
extern mbed::Callback<void()> callback;
|
||||
extern char *read_string_table[kRead_string_table_size];
|
||||
extern int read_string_index;
|
||||
extern int int_valid_count_table[kRead_int_table_size];
|
||||
extern int int_count;
|
||||
extern int resp_stop_success_count;
|
||||
}
|
||||
|
|
|
@ -27,12 +27,12 @@ ATHandler *AT_CellularBase_stub::handler_at_constructor_value = NULL;
|
|||
device_err_t AT_CellularBase_stub::device_err_value;
|
||||
bool AT_CellularBase_stub::supported_bool = true;
|
||||
|
||||
AT_CellularBase::AT_CellularBase(ATHandler& at) : _at(at)
|
||||
AT_CellularBase::AT_CellularBase(ATHandler &at) : _at(at)
|
||||
{
|
||||
AT_CellularBase_stub::handler_at_constructor_value = &_at;
|
||||
}
|
||||
|
||||
ATHandler& AT_CellularBase::get_at_handler()
|
||||
ATHandler &AT_CellularBase::get_at_handler()
|
||||
{
|
||||
return *AT_CellularBase_stub::handler_value;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
#include "ATHandler.h"
|
||||
|
||||
namespace AT_CellularBase_stub {
|
||||
extern mbed::ATHandler *handler_value;
|
||||
extern mbed::ATHandler *handler_at_constructor_value;
|
||||
extern mbed::device_err_t device_err_value;
|
||||
extern bool supported_bool;
|
||||
extern mbed::ATHandler *handler_value;
|
||||
extern mbed::ATHandler *handler_at_constructor_value;
|
||||
extern mbed::device_err_t device_err_value;
|
||||
extern bool supported_bool;
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ AT_CellularDevice::~AT_CellularDevice()
|
|||
{
|
||||
}
|
||||
|
||||
ATHandler* AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
|
||||
ATHandler *AT_CellularDevice::get_at_handler(FileHandle *fileHandle)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AT_CellularDevice::release_at_handler(ATHandler* at_handler)
|
||||
void AT_CellularDevice::release_at_handler(ATHandler *at_handler)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
CellularNetwork *AT_CellularDevice::open_network(FileHandle *fh)
|
||||
|
|
|
@ -39,19 +39,19 @@ nsapi_error_t AT_CellularNetwork::init()
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||
const char *username, const char *password)
|
||||
const char *username, const char *password)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||
AuthenticationType type, const char *username, const char *password)
|
||||
AuthenticationType type, const char *username, const char *password)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::connect(const char *apn,
|
||||
const char *username, const char *password)
|
||||
const char *username, const char *password)
|
||||
{
|
||||
return connect();
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ nsapi_error_t AT_CellularNetwork::set_blocking(bool blocking)
|
|||
return NSAPI_ERROR_OK;;
|
||||
}
|
||||
|
||||
nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char* pdp_type)
|
||||
nsapi_ip_stack_t AT_CellularNetwork::string_to_stack_type(const char *pdp_type)
|
||||
{
|
||||
return IPV4_STACK;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ nsapi_error_t AT_CellularNetwork::set_registration_urc(RegistrationType type, bo
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode& mode)
|
||||
nsapi_error_t AT_CellularNetwork::get_network_registering_mode(NWRegisteringMode &mode)
|
||||
{
|
||||
mode = NWModeAutomatic;
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -186,7 +186,7 @@ nsapi_error_t AT_CellularNetwork::set_access_technology(RadioAccessTechnology op
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_access_technology(RadioAccessTechnology& rat)
|
||||
nsapi_error_t AT_CellularNetwork::get_access_technology(RadioAccessTechnology &rat)
|
||||
{
|
||||
rat = RAT_CATM1;
|
||||
return NSAPI_ERROR_OK;
|
||||
|
@ -203,21 +203,21 @@ nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(Supported_UE_Opt
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt& supported_opt,
|
||||
Preferred_UE_Opt& preferred_opt)
|
||||
nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
|
||||
Preferred_UE_Opt &preferred_opt)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_rate_control(
|
||||
CellularNetwork::RateControlExceptionReports &reports,
|
||||
CellularNetwork::RateControlUplinkTimeUnit &timeUnit, int &uplinkRate)
|
||||
CellularNetwork::RateControlExceptionReports &reports,
|
||||
CellularNetwork::RateControlUplinkTimeUnit &timeUnit, int &uplinkRate)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_pdpcontext_params(pdpContextList_t& params_list)
|
||||
nsapi_error_t AT_CellularNetwork::get_pdpcontext_params(pdpContextList_t ¶ms_list)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
|
|
@ -70,7 +70,8 @@ nsapi_error_t AT_CellularPower::set_device_ready_urc_cb(mbed::Callback<void()> c
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
void AT_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callback){
|
||||
void AT_CellularPower::remove_device_ready_urc_cb(mbed::Callback<void()> callback)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ nsapi_error_t AT_CellularSIM::set_pin_query(const char *sim_pin, bool query_pin)
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularSIM::get_imsi(char* imsi)
|
||||
nsapi_error_t AT_CellularSIM::get_imsi(char *imsi)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ const uint16_t SMS_MAX_GSM7_CONCATENATED_SINGLE_SMS_SIZE = 153;
|
|||
|
||||
|
||||
AT_CellularSMS::AT_CellularSMS(ATHandler &at) : AT_CellularBase(at), _cb(0), _mode(CellularSMSMmodeText),
|
||||
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
|
||||
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -80,13 +80,13 @@ void AT_CellularSMS::set_extra_sim_wait_time(int sim_wait_time)
|
|||
{
|
||||
}
|
||||
|
||||
char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t& header_size)
|
||||
char *AT_CellularSMS::create_pdu(const char *phone_number, const char *message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t &header_size)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const char* message, int msg_len)
|
||||
nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const char *message, int msg_len)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ nsapi_size_or_error_t AT_CellularSMS::set_cscs(const char *chr_set)
|
|||
// return NSAPI_ERROR_OK;
|
||||
//}
|
||||
|
||||
nsapi_error_t AT_CellularSMS::delete_sms(sms_info_t* sms)
|
||||
nsapi_error_t AT_CellularSMS::delete_sms(sms_info_t *sms)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
@ -125,35 +125,35 @@ nsapi_error_t AT_CellularSMS::delete_all_messages()
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char* buf, uint16_t len, char* phone_num, char* time_stamp)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char *buf, uint16_t len, char *phone_num, char *time_stamp)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
// read msg in PDU mode
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char* phone_num, char* time_stamp)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t *sms, char *buf, char *phone_num, char *time_stamp)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* phone_num, uint16_t phone_len,
|
||||
char* time_stamp, uint16_t time_len, int *buf_size)
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_sms(char *buf, uint16_t len, char *phone_num, uint16_t phone_len,
|
||||
char *time_stamp, uint16_t time_len, int *buf_size)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char* pdu, sms_info_t *info, int *part_number, char *phone_number, char *msg)
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char *pdu, sms_info_t *info, int *part_number, char *phone_number, char *msg)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
// read params from User DEfined Header
|
||||
int AT_CellularSMS::read_udh_from_pdu(const char* pdu, sms_info_t *info, int &part_number, int &padding_bits)
|
||||
// read params from User DEfined Header
|
||||
int AT_CellularSMS::read_udh_from_pdu(const char *pdu, sms_info_t *info, int &part_number, int &padding_bits)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char* pdu, int msg_len, int scheme, char *msg, int padding_bits)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char *pdu, int msg_len, int scheme, char *msg, int padding_bits)
|
||||
{
|
||||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void AT_CellularSMS::free_linked_list()
|
|||
{
|
||||
}
|
||||
|
||||
void AT_CellularSMS::add_info(sms_info_t* info, int index, int part_number)
|
||||
void AT_CellularSMS::add_info(sms_info_t *info, int index, int part_number)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -172,18 +172,18 @@ nsapi_error_t AT_CellularSMS::list_messages()
|
|||
return NSAPI_ERROR_OK;
|
||||
}
|
||||
|
||||
AT_CellularSMS::sms_info_t* AT_CellularSMS::get_oldest_sms_index()
|
||||
AT_CellularSMS::sms_info_t *AT_CellularSMS::get_oldest_sms_index()
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// if time_string_1 is greater (more fresh date) then return 1, same 0, smaller -1. Error -2
|
||||
int AT_CellularSMS::compare_time_strings(const char* time_string_1, const char* time_string_2)
|
||||
int AT_CellularSMS::compare_time_strings(const char *time_string_1, const char *time_string_2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool AT_CellularSMS::create_time(const char* time_string, time_t* time)
|
||||
bool AT_CellularSMS::create_time(const char *time_string, time_t *time)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,39 +31,39 @@ void str_remove_char(char *src, char c)
|
|||
{
|
||||
}
|
||||
|
||||
void uint_to_binary_str(uint32_t num, char* str, uint8_t str_size, uint8_t bit_cnt)
|
||||
void uint_to_binary_str(uint32_t num, char *str, uint8_t str_size, uint8_t bit_cnt)
|
||||
{
|
||||
}
|
||||
|
||||
// converts the given str to hex string to buf
|
||||
uint16_t char_str_to_hex(const char* str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
uint16_t char_str_to_hex(const char *str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void convert_ipv6(char* ip)
|
||||
void convert_ipv6(char *ip)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
char* find_dot_number(char* str, int dot_number)
|
||||
char *find_dot_number(char *str, int dot_number)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void separate_ip4like_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void separate_ip4like_addresses(char *orig, char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
}
|
||||
|
||||
void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void separate_ip_addresses(char *orig, char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
}
|
||||
|
||||
void prefer_ipv6(char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void prefer_ipv6(char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
}
|
||||
|
||||
void int_to_hex_str(uint8_t num, char* buf)
|
||||
void int_to_hex_str(uint8_t num, char *buf)
|
||||
{
|
||||
buf[0] = '0';
|
||||
buf[1] = '2';
|
||||
|
@ -74,17 +74,17 @@ int hex_str_to_int(const char *hex_string, int hex_string_length)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int hex_str_to_char_str(const char* str, uint16_t len, char *buf)
|
||||
int hex_str_to_char_str(const char *str, uint16_t len, char *buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt)
|
||||
void uint_to_binary_str(uint32_t num, char *str, int str_size, int bit_cnt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int char_str_to_hex_str(const char* str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
int char_str_to_hex_str(const char *str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
{
|
||||
//The code is dependent on this, so this is easiest just to put here
|
||||
if (!str || !buf) {
|
||||
|
@ -92,17 +92,17 @@ int char_str_to_hex_str(const char* str, uint16_t len, char *buf, bool omit_lead
|
|||
}
|
||||
|
||||
char *ptr = buf;
|
||||
int i=0;
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
if (omit_leading_zero == true && i == 0 && !(str[i]>>4 & 0x0F)) {
|
||||
if (omit_leading_zero == true && i == 0 && !(str[i] >> 4 & 0x0F)) {
|
||||
*ptr++ = hex_values[(str[i]) & 0x0F];
|
||||
} else {
|
||||
*ptr++ = hex_values[((str[i])>>4) & 0x0F];
|
||||
*ptr++ = hex_values[((str[i]) >> 4) & 0x0F];
|
||||
*ptr++ = hex_values[(str[i]) & 0x0F];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return ptr-buf;
|
||||
return ptr - buf;
|
||||
}
|
||||
|
||||
uint16_t get_dynamic_ip_port()
|
||||
|
|
|
@ -22,29 +22,37 @@ using namespace mbed;
|
|||
|
||||
namespace events {
|
||||
|
||||
EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer) {
|
||||
EventQueue::EventQueue(unsigned event_size, unsigned char *event_pointer)
|
||||
{
|
||||
}
|
||||
|
||||
EventQueue::~EventQueue() {
|
||||
EventQueue::~EventQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void EventQueue::dispatch(int ms) {
|
||||
void EventQueue::dispatch(int ms)
|
||||
{
|
||||
}
|
||||
|
||||
void EventQueue::break_dispatch() {
|
||||
void EventQueue::break_dispatch()
|
||||
{
|
||||
}
|
||||
|
||||
unsigned EventQueue::tick() {
|
||||
unsigned EventQueue::tick()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EventQueue::cancel(int id) {
|
||||
void EventQueue::cancel(int id)
|
||||
{
|
||||
}
|
||||
|
||||
void EventQueue::background(Callback<void(int)> update) {
|
||||
void EventQueue::background(Callback<void(int)> update)
|
||||
{
|
||||
}
|
||||
|
||||
void EventQueue::chain(EventQueue *target) {
|
||||
void EventQueue::chain(EventQueue *target)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -26,14 +26,17 @@ static uint8_t filehandle_stub_short_value_counter = 0;
|
|||
static char *filehandle_stub_table = NULL;
|
||||
static uint8_t filehandle_stub_table_pos = 0;
|
||||
|
||||
class FileHandle_stub : public FileHandle
|
||||
{
|
||||
class FileHandle_stub : public FileHandle {
|
||||
public:
|
||||
ssize_t size_value;
|
||||
|
||||
FileHandle_stub() {size_value = 0;}
|
||||
FileHandle_stub()
|
||||
{
|
||||
size_value = 0;
|
||||
}
|
||||
|
||||
virtual ssize_t read(void *buffer, size_t size){
|
||||
virtual ssize_t read(void *buffer, size_t size)
|
||||
{
|
||||
if (filehandle_stub_table) {
|
||||
ssize_t ret = strlen(filehandle_stub_table) - filehandle_stub_table_pos;
|
||||
if (ret >= 0 && size < ret) {
|
||||
|
@ -49,7 +52,8 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
virtual ssize_t write(const void *buffer, size_t size){
|
||||
virtual ssize_t write(const void *buffer, size_t size)
|
||||
{
|
||||
if (size_value > 0) {
|
||||
size_value--;
|
||||
return size;
|
||||
|
@ -59,11 +63,15 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET){return 0;}
|
||||
virtual off_t seek(off_t offset, int whence = SEEK_SET)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
virtual int close(){}
|
||||
virtual int close() {}
|
||||
|
||||
virtual short poll(short events) const{
|
||||
virtual short poll(short events) const
|
||||
{
|
||||
if (filehandle_stub_short_value_counter) {
|
||||
filehandle_stub_short_value_counter--;
|
||||
return short_value;
|
||||
|
@ -71,7 +79,10 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
virtual void sigio(Callback<void()> func){func();}
|
||||
virtual void sigio(Callback<void()> func)
|
||||
{
|
||||
func();
|
||||
}
|
||||
|
||||
short short_value;
|
||||
};
|
||||
|
|
|
@ -77,7 +77,7 @@ nsapi_error_t NetworkInterface::set_blocking(bool blocking)
|
|||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const*, mbed::Callback<void (int, SocketAddress*)>, nsapi_version)
|
||||
nsapi_value_or_error_t NetworkInterface::gethostbyname_async(char const *, mbed::Callback<void (int, SocketAddress *)>, nsapi_version)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
|
|
@ -68,16 +68,16 @@ NetworkStack *nsapi_create_stack(NetworkStack *stack)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback,
|
||||
nsapi_version_t version)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
nsapi_value_or_error_t NetworkStack::gethostbyname_async(const char *host, hostbyname_cb_t callback,
|
||||
nsapi_version_t version)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
nsapi_error_t NetworkStack::gethostbyname_async_cancel(int id)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
nsapi_error_t NetworkStack::gethostbyname_async_cancel(int id)
|
||||
{
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
|
||||
call_in_callback_cb_t NetworkStack::get_call_in_callback()
|
||||
{
|
||||
|
|
|
@ -19,37 +19,37 @@
|
|||
|
||||
namespace rtos {
|
||||
|
||||
Semaphore::Semaphore(int32_t count)
|
||||
Semaphore::Semaphore(int32_t count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Semaphore::Semaphore(int32_t count, uint16_t max_count)
|
||||
Semaphore::Semaphore(int32_t count, uint16_t max_count)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Semaphore::constructor(int32_t count, uint16_t max_count)
|
||||
void Semaphore::constructor(int32_t count, uint16_t max_count)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
int32_t Semaphore::wait(uint32_t millisec)
|
||||
int32_t Semaphore::wait(uint32_t millisec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t Semaphore::wait_until(uint64_t millisec)
|
||||
int32_t Semaphore::wait_until(uint64_t millisec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
osStatus Semaphore::release(void)
|
||||
osStatus Semaphore::release(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Semaphore::~Semaphore()
|
||||
Semaphore::~Semaphore()
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,8 @@
|
|||
|
||||
namespace rtos {
|
||||
|
||||
osStatus Thread::wait_until(uint64_t millisec) {
|
||||
osStatus Thread::wait_until(uint64_t millisec)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,35 +20,45 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
Timer::Timer() {
|
||||
Timer::Timer()
|
||||
{
|
||||
}
|
||||
|
||||
Timer::Timer(const ticker_data_t *data) {
|
||||
Timer::Timer(const ticker_data_t *data)
|
||||
{
|
||||
}
|
||||
|
||||
Timer::~Timer() {
|
||||
Timer::~Timer()
|
||||
{
|
||||
}
|
||||
|
||||
void Timer::start() {
|
||||
void Timer::start()
|
||||
{
|
||||
}
|
||||
|
||||
void Timer::stop() {;
|
||||
void Timer::stop()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
int Timer::read_us() {
|
||||
int Timer::read_us()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
float Timer::read() {
|
||||
float Timer::read()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Timer::read_ms() {
|
||||
int Timer::read_ms()
|
||||
{
|
||||
timer_stub_value += timer_stub_step;
|
||||
return timer_stub_value;
|
||||
}
|
||||
|
||||
us_timestamp_t Timer::read_high_resolution_us() {
|
||||
us_timestamp_t Timer::read_high_resolution_us()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -56,7 +66,8 @@ void Timer::reset()
|
|||
{
|
||||
}
|
||||
|
||||
Timer::operator float() {
|
||||
Timer::operator float()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ void equeue_cancel(equeue_t *queue, int id)
|
|||
}
|
||||
|
||||
void equeue_background(equeue_t *queue,
|
||||
void (*update)(void *timer, int ms), void *timer)
|
||||
void (*update)(void *timer, int ms), void *timer)
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
namespace mbed_poll_stub {
|
||||
extern int revents_value;
|
||||
extern int int_value;
|
||||
extern int revents_value;
|
||||
extern int int_value;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -17,11 +17,14 @@
|
|||
|
||||
#include "mbed_wait_api.h"
|
||||
|
||||
void wait(float s) {
|
||||
void wait(float s)
|
||||
{
|
||||
}
|
||||
|
||||
void wait_ms(int ms) {
|
||||
void wait_ms(int ms)
|
||||
{
|
||||
}
|
||||
|
||||
void wait_us(int us) {
|
||||
void wait_us(int us)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include "stdlib.h"
|
||||
#include "us_ticker_api.h"
|
||||
|
||||
const ticker_data_t* get_us_ticker_data(void)
|
||||
const ticker_data_t *get_us_ticker_data(void)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -21,13 +21,12 @@
|
|||
#include <cstdarg>
|
||||
#include "FileHandle.h"
|
||||
|
||||
class ATCmdParser
|
||||
{
|
||||
class ATCmdParser {
|
||||
public:
|
||||
ATCmdParser(mbed::FileHandle *fh, const char *output_delimiter = "\r",
|
||||
int buffer_size = 256, int timeout = 8000, bool debug = false){}
|
||||
int buffer_size = 256, int timeout = 8000, bool debug = false) {}
|
||||
|
||||
~ATCmdParser(){}
|
||||
~ATCmdParser() {}
|
||||
};
|
||||
|
||||
#endif //__AT_CMD_PARSER_H__
|
||||
|
|
|
@ -29,15 +29,15 @@ typedef int32_t osStatus;
|
|||
typedef void *osSemaphoreId_t;
|
||||
|
||||
typedef struct {
|
||||
const char *name; ///< name of the semaphore
|
||||
uint32_t attr_bits; ///< attribute bits
|
||||
void *cb_mem; ///< memory for control block
|
||||
uint32_t cb_size; ///< size of provided memory for control block
|
||||
const char *name; ///< name of the semaphore
|
||||
uint32_t attr_bits; ///< attribute bits
|
||||
void *cb_mem; ///< memory for control block
|
||||
uint32_t cb_size; ///< size of provided memory for control block
|
||||
} osSemaphoreAttr_t;
|
||||
|
||||
//Thread
|
||||
typedef enum {
|
||||
osPriorityNormal = 24 ///< Priority: normal
|
||||
osPriorityNormal = 24 ///< Priority: normal
|
||||
} osPriority_t;
|
||||
|
||||
typedef void *osThreadId_t;
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
typedef void* Mutex;
|
||||
typedef void *Mutex;
|
||||
|
|
|
@ -15,4 +15,4 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
typedef void* Semaphore;
|
||||
typedef void *Semaphore;
|
||||
|
|
|
@ -21,40 +21,40 @@
|
|||
#include "inttypes.h"
|
||||
|
||||
typedef struct osRtxSemaphore_s {
|
||||
uint8_t id; ///< Object Identifier
|
||||
uint8_t state; ///< Object State
|
||||
uint8_t flags; ///< Object Flags
|
||||
uint8_t reserved;
|
||||
const char *name; ///< Object Name
|
||||
uint16_t tokens; ///< Current number of tokens
|
||||
uint16_t max_tokens; ///< Maximum number of tokens
|
||||
uint8_t id; ///< Object Identifier
|
||||
uint8_t state; ///< Object State
|
||||
uint8_t flags; ///< Object Flags
|
||||
uint8_t reserved;
|
||||
const char *name; ///< Object Name
|
||||
uint16_t tokens; ///< Current number of tokens
|
||||
uint16_t max_tokens; ///< Maximum number of tokens
|
||||
} osRtxSemaphore_t;
|
||||
|
||||
typedef struct osRtxThread_s {
|
||||
uint8_t id; ///< Object Identifier
|
||||
uint8_t state; ///< Object State
|
||||
uint8_t flags; ///< Object Flags
|
||||
uint8_t attr; ///< Object Attributes
|
||||
const char *name; ///< Object Name
|
||||
struct osRtxThread_s *thread_next; ///< Link pointer to next Thread in Object list
|
||||
struct osRtxThread_s *thread_prev; ///< Link pointer to previous Thread in Object list
|
||||
struct osRtxThread_s *delay_next; ///< Link pointer to next Thread in Delay list
|
||||
struct osRtxThread_s *delay_prev; ///< Link pointer to previous Thread in Delay list
|
||||
struct osRtxThread_s *thread_join; ///< Thread waiting to Join
|
||||
uint32_t delay; ///< Delay Time
|
||||
int8_t priority; ///< Thread Priority
|
||||
int8_t priority_base; ///< Base Priority
|
||||
uint8_t stack_frame; ///< Stack Frame (EXC_RETURN[7..0])
|
||||
uint8_t flags_options; ///< Thread/Event Flags Options
|
||||
uint32_t wait_flags; ///< Waiting Thread/Event Flags
|
||||
uint32_t thread_flags; ///< Thread Flags
|
||||
struct osRtxMutex_s *mutex_list; ///< Link pointer to list of owned Mutexes
|
||||
void *stack_mem; ///< Stack Memory
|
||||
uint32_t stack_size; ///< Stack Size
|
||||
uint32_t sp; ///< Current Stack Pointer
|
||||
uint32_t thread_addr; ///< Thread entry address
|
||||
uint32_t tz_memory; ///< TrustZone Memory Identifier
|
||||
void *context; ///< Context for OsEventObserver objects
|
||||
uint8_t id; ///< Object Identifier
|
||||
uint8_t state; ///< Object State
|
||||
uint8_t flags; ///< Object Flags
|
||||
uint8_t attr; ///< Object Attributes
|
||||
const char *name; ///< Object Name
|
||||
struct osRtxThread_s *thread_next; ///< Link pointer to next Thread in Object list
|
||||
struct osRtxThread_s *thread_prev; ///< Link pointer to previous Thread in Object list
|
||||
struct osRtxThread_s *delay_next; ///< Link pointer to next Thread in Delay list
|
||||
struct osRtxThread_s *delay_prev; ///< Link pointer to previous Thread in Delay list
|
||||
struct osRtxThread_s *thread_join; ///< Thread waiting to Join
|
||||
uint32_t delay; ///< Delay Time
|
||||
int8_t priority; ///< Thread Priority
|
||||
int8_t priority_base; ///< Base Priority
|
||||
uint8_t stack_frame; ///< Stack Frame (EXC_RETURN[7..0])
|
||||
uint8_t flags_options; ///< Thread/Event Flags Options
|
||||
uint32_t wait_flags; ///< Waiting Thread/Event Flags
|
||||
uint32_t thread_flags; ///< Thread Flags
|
||||
struct osRtxMutex_s *mutex_list; ///< Link pointer to list of owned Mutexes
|
||||
void *stack_mem; ///< Stack Memory
|
||||
uint32_t stack_size; ///< Stack Size
|
||||
uint32_t sp; ///< Current Stack Pointer
|
||||
uint32_t thread_addr; ///< Thread entry address
|
||||
uint32_t tz_memory; ///< TrustZone Memory Identifier
|
||||
void *context; ///< Context for OsEventObserver objects
|
||||
} osRtxThread_t;
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -14,4 +14,4 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#define NAME_MAX 255
|
||||
#define NAME_MAX 255
|
||||
|
|
|
@ -16,17 +16,17 @@
|
|||
|
||||
/* ----------------------------------------------------------------
|
||||
APN stands for Access Point Name, a setting on your modem or phone
|
||||
that identifies an external network your phone can access for data
|
||||
(e.g. 3G or 4G Internet service on your phone).
|
||||
|
||||
that identifies an external network your phone can access for data
|
||||
(e.g. 3G or 4G Internet service on your phone).
|
||||
|
||||
The APN settings can be forced when calling the join function.
|
||||
Below is a list of known APNs that us used if no apn config
|
||||
Below is a list of known APNs that us used if no apn config
|
||||
is forced. This list could be extended by other settings.
|
||||
|
||||
|
||||
For further reading:
|
||||
wiki apn: http://en.wikipedia.org/wiki/Access_Point_Name
|
||||
wiki mcc/mnc: http://en.wikipedia.org/wiki/Mobile_country_code
|
||||
google: https://www.google.de/search?q=APN+list
|
||||
google: https://www.google.de/search?q=APN+list
|
||||
---------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
@ -44,15 +44,15 @@
|
|||
/**
|
||||
* APN lookup struct
|
||||
*/
|
||||
typedef struct {
|
||||
const char* mccmnc; /**< mobile country code (MCC) and mobile network code MNC */
|
||||
const char* cfg; /**< APN configuartion string, use _APN macro to generate */
|
||||
typedef struct {
|
||||
const char *mccmnc; /**< mobile country code (MCC) and mobile network code MNC */
|
||||
const char *cfg; /**< APN configuartion string, use _APN macro to generate */
|
||||
} APN_t;
|
||||
|
||||
/**
|
||||
* Default APN settings used by many networks
|
||||
*/
|
||||
static const char* apndef = _APN("internet",,);
|
||||
static const char *apndef = _APN("internet",,);
|
||||
|
||||
/**
|
||||
* List of special APNs for different network operators.
|
||||
|
@ -73,14 +73,17 @@ static const APN_t apnlut[] = {
|
|||
|
||||
// 460 China - CN
|
||||
{ /* CN Mobile */"460-00", _APN("cmnet",,)
|
||||
_APN("cmwap",,) },
|
||||
_APN("cmwap",,)
|
||||
},
|
||||
{ /* Unicom */ "460-01", _APN("3gnet",,)
|
||||
_APN("uninet","uninet","uninet") },
|
||||
|
||||
_APN("uninet", "uninet", "uninet")
|
||||
},
|
||||
|
||||
// 262 Germany - DE
|
||||
{ /* T-Mobile */ "262-01", _APN("internet.t-mobile","t-mobile","tm") },
|
||||
{ /* T-Mobile */ "262-02,06",
|
||||
_APN("m2m.business",,) },
|
||||
{ /* T-Mobile */ "262-01", _APN("internet.t-mobile", "t-mobile", "tm") },
|
||||
{ /* T-Mobile */ "262-02,06",
|
||||
_APN("m2m.business",,)
|
||||
},
|
||||
|
||||
// 222 Italy - IT
|
||||
{ /* TIM */ "222-01", _APN("ibox.tim.it",,) },
|
||||
|
@ -89,15 +92,17 @@ static const APN_t apnlut[] = {
|
|||
|
||||
// 440 Japan - JP
|
||||
{ /* Softbank */ "440-04,06,20,40,41,42,43,44,45,46,47,48,90,91,92,93,94,95"
|
||||
",96,97,98"
|
||||
_APN("open.softbank.ne.jp","opensoftbank","ebMNuX1FIHg9d3DA")
|
||||
_APN("smile.world","dna1trop","so2t3k3m2a") },
|
||||
",96,97,98"
|
||||
_APN("open.softbank.ne.jp", "opensoftbank", "ebMNuX1FIHg9d3DA")
|
||||
_APN("smile.world", "dna1trop", "so2t3k3m2a")
|
||||
},
|
||||
{ /* NTTDoCoMo */"440-09,10,11,12,13,14,15,16,17,18,19,21,22,23,24,25,26,27,"
|
||||
"28,29,30,31,32,33,34,35,36,37,38,39,58,59,60,61,62,63,"
|
||||
"64,65,66,67,68,69,87,99",
|
||||
_APN("bmobilewap",,) /*BMobile*/
|
||||
_APN("mpr2.bizho.net","Mopera U",) /* DoCoMo */
|
||||
_APN("bmobile.ne.jp","bmobile@wifi2","bmobile") /*BMobile*/ },
|
||||
"28,29,30,31,32,33,34,35,36,37,38,39,58,59,60,61,62,63,"
|
||||
"64,65,66,67,68,69,87,99",
|
||||
_APN("bmobilewap",,) /*BMobile*/
|
||||
_APN("mpr2.bizho.net", "Mopera U",) /* DoCoMo */
|
||||
_APN("bmobile.ne.jp", "bmobile@wifi2", "bmobile") /*BMobile*/
|
||||
},
|
||||
|
||||
// 204 Netherlands - NL
|
||||
{ /* Vodafone */ "204-04", _APN("public4.m2minternet.com",,) },
|
||||
|
@ -106,38 +111,44 @@ static const APN_t apnlut[] = {
|
|||
{ /* Si.mobil */ "293-40", _APN("internet.simobil.si",,) },
|
||||
{ /* Tusmobil */ "293-70", _APN("internet.tusmobil.si",,) },
|
||||
|
||||
// 240 Sweden SE
|
||||
// 240 Sweden SE
|
||||
{ /* Telia */ "240-01", _APN("online.telia.se",,) },
|
||||
{ /* Telenor */ "240-06,08",
|
||||
_APN("services.telenor.se",,) },
|
||||
_APN("services.telenor.se",,)
|
||||
},
|
||||
{ /* Tele2 */ "240-07", _APN("mobileinternet.tele2.se",,) },
|
||||
|
||||
|
||||
// 228 Switzerland - CH
|
||||
{ /* Swisscom */ "228-01", _APN("gprs.swisscom.ch",,) },
|
||||
{ /* Orange */ "228-03", _APN("internet",,) /* contract */
|
||||
_APN("click",,) /* pre-pay */ },
|
||||
_APN("click",,) /* pre-pay */
|
||||
},
|
||||
|
||||
// 234 United Kingdom - GB
|
||||
{ /* O2 */ "234-02,10,11",
|
||||
_APN("mobile.o2.co.uk","faster","web") /* contract */
|
||||
_APN("mobile.o2.co.uk","bypass","web") /* pre-pay */
|
||||
_APN("payandgo.o2.co.uk","payandgo","payandgo") },
|
||||
{ /* Vodafone */ "234-15", _APN("internet","web","web") /* contract */
|
||||
_APN("pp.vodafone.co.uk","wap","wap") /* pre-pay */ },
|
||||
_APN("mobile.o2.co.uk", "faster", "web") /* contract */
|
||||
_APN("mobile.o2.co.uk", "bypass", "web") /* pre-pay */
|
||||
_APN("payandgo.o2.co.uk", "payandgo", "payandgo")
|
||||
},
|
||||
{ /* Vodafone */ "234-15", _APN("internet", "web", "web") /* contract */
|
||||
_APN("pp.vodafone.co.uk", "wap", "wap") /* pre-pay */
|
||||
},
|
||||
{ /* Three */ "234-20", _APN("three.co.uk",,) },
|
||||
{ /* Jersey */ "234-50", _APN("jtm2m",,) /* as used on u-blox C030 U201 boards */ },
|
||||
|
||||
// 310 United States of America - US
|
||||
{ /* T-Mobile */ "310-026,260,490",
|
||||
_APN("epc.tmobile.com",,)
|
||||
_APN("fast.tmobile.com",,) /* LTE */ },
|
||||
_APN("epc.tmobile.com",,)
|
||||
_APN("fast.tmobile.com",,) /* LTE */
|
||||
},
|
||||
{ /* AT&T */ "310-030,150,170,260,410,560,680",
|
||||
_APN("phone",,)
|
||||
_APN("wap.cingular","WAP@CINGULARGPRS.COM","CINGULAR1")
|
||||
_APN("isp.cingular","ISP@CINGULARGPRS.COM","CINGULAR1") },
|
||||
_APN("phone",,)
|
||||
_APN("wap.cingular", "WAP@CINGULARGPRS.COM", "CINGULAR1")
|
||||
_APN("isp.cingular", "ISP@CINGULARGPRS.COM", "CINGULAR1")
|
||||
},
|
||||
|
||||
// 901 International - INT
|
||||
{ /* Transatel */ "901-37", _APN("netgprs.com","tsl","tsl") },
|
||||
{ /* Transatel */ "901-37", _APN("netgprs.com", "tsl", "tsl") },
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -145,26 +156,27 @@ static const APN_t apnlut[] = {
|
|||
*
|
||||
* @param imsi strinf containing IMSI
|
||||
*/
|
||||
inline const char* apnconfig(const char* imsi)
|
||||
inline const char *apnconfig(const char *imsi)
|
||||
{
|
||||
const char* config = NULL;
|
||||
const char *config = NULL;
|
||||
if (imsi && *imsi) {
|
||||
// many carriers use internet without username and password, os use this as default
|
||||
// now try to lookup the setting for our table
|
||||
for (size_t i = 0; i < sizeof(apnlut)/sizeof(*apnlut) && !config; i ++) {
|
||||
const char* p = apnlut[i].mccmnc;
|
||||
for (size_t i = 0; i < sizeof(apnlut) / sizeof(*apnlut) && !config; i ++) {
|
||||
const char *p = apnlut[i].mccmnc;
|
||||
// check the MCC
|
||||
if ((0 == memcmp(imsi, p, 3))) {
|
||||
p += 3;
|
||||
// check all the MNC, MNC length can be 2 or 3 digits
|
||||
while (((p[0] == '-') || (p[0] == ',')) &&
|
||||
(p[1] >= '0') && (p[1] <= '9') &&
|
||||
while (((p[0] == '-') || (p[0] == ',')) &&
|
||||
(p[1] >= '0') && (p[1] <= '9') &&
|
||||
(p[2] >= '0') && (p[2] <= '9') && !config) {
|
||||
int l = ((p[3] >= '0') && (p[3] <= '9')) ? 3 : 2;
|
||||
if (0 == memcmp(imsi+3,p+1,l))
|
||||
if (0 == memcmp(imsi + 3, p + 1, l)) {
|
||||
config = apnlut[i].cfg;
|
||||
}
|
||||
p += 1 + l;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,13 +37,12 @@
|
|||
|
||||
#define RETRY_COUNT_DEFAULT 3
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
CellularConnectionFSM::CellularConnectionFSM() :
|
||||
_serial(0), _state(STATE_INIT), _next_state(_state), _status_callback(0), _event_status_cb(0), _network(0), _power(0), _sim(0),
|
||||
_queue(8 * EVENTS_EVENT_SIZE), _queue_thread(0), _cellularDevice(0), _retry_count(0), _event_timeout(-1),
|
||||
_at_queue(8 * EVENTS_EVENT_SIZE), _event_id(0), _plmn(0), _command_success(false), _plmn_network_found(false)
|
||||
_serial(0), _state(STATE_INIT), _next_state(_state), _status_callback(0), _event_status_cb(0), _network(0), _power(0), _sim(0),
|
||||
_queue(8 * EVENTS_EVENT_SIZE), _queue_thread(0), _cellularDevice(0), _retry_count(0), _event_timeout(-1),
|
||||
_at_queue(8 * EVENTS_EVENT_SIZE), _event_id(0), _plmn(0), _command_success(false), _plmn_network_found(false)
|
||||
{
|
||||
memset(_sim_pin, 0, sizeof(_sim_pin));
|
||||
#if MBED_CONF_CELLULAR_RANDOM_MAX_START_DELAY == 0
|
||||
|
@ -147,7 +146,7 @@ bool CellularConnectionFSM::power_on()
|
|||
void CellularConnectionFSM::set_sim_pin(const char *sim_pin)
|
||||
{
|
||||
strncpy(_sim_pin, sim_pin, sizeof(_sim_pin));
|
||||
_sim_pin[sizeof(_sim_pin)-1] = '\0';
|
||||
_sim_pin[sizeof(_sim_pin) - 1] = '\0';
|
||||
}
|
||||
|
||||
void CellularConnectionFSM::set_plmn(const char *plmn)
|
||||
|
@ -202,7 +201,7 @@ bool CellularConnectionFSM::is_registered()
|
|||
}
|
||||
|
||||
bool CellularConnectionFSM::get_network_registration(CellularNetwork::RegistrationType type,
|
||||
CellularNetwork::RegistrationStatus &status, bool &is_registered)
|
||||
CellularNetwork::RegistrationStatus &status, bool &is_registered)
|
||||
{
|
||||
is_registered = false;
|
||||
bool is_roaming = false;
|
||||
|
@ -581,7 +580,7 @@ void CellularConnectionFSM::event()
|
|||
if (_event_timeout == -1) {
|
||||
_event_timeout = 0;
|
||||
}
|
||||
_event_id = _queue.call_in(_event_timeout*1000, callback(this, &CellularConnectionFSM::event));
|
||||
_event_id = _queue.call_in(_event_timeout * 1000, callback(this, &CellularConnectionFSM::event));
|
||||
if (!_event_id) {
|
||||
report_failure("Cellular event failure!");
|
||||
return;
|
||||
|
|
|
@ -43,8 +43,7 @@ const int MAX_RETRY_ARRAY_SIZE = 10;
|
|||
*
|
||||
* Finite State Machine for connecting to cellular network
|
||||
*/
|
||||
class CellularConnectionFSM
|
||||
{
|
||||
class CellularConnectionFSM {
|
||||
public:
|
||||
CellularConnectionFSM();
|
||||
virtual ~CellularConnectionFSM();
|
||||
|
@ -148,7 +147,7 @@ public:
|
|||
*
|
||||
* @param plmn operator in numeric format. See more from 3GPP TS 27.007 chapter 7.3.
|
||||
*/
|
||||
void set_plmn(const char* plmn);
|
||||
void set_plmn(const char *plmn);
|
||||
|
||||
/** returns readable format of the given state. Used for printing states while debugging.
|
||||
*
|
||||
|
@ -186,7 +185,7 @@ private:
|
|||
NetworkStack *get_stack();
|
||||
|
||||
private:
|
||||
void report_failure(const char* msg);
|
||||
void report_failure(const char *msg);
|
||||
void event();
|
||||
void ready_urc_cb();
|
||||
|
||||
|
@ -203,7 +202,7 @@ private:
|
|||
events::EventQueue _queue;
|
||||
rtos::Thread *_queue_thread;
|
||||
CellularDevice *_cellularDevice;
|
||||
char _sim_pin[PIN_SIZE+1];
|
||||
char _sim_pin[PIN_SIZE + 1];
|
||||
int _retry_count;
|
||||
int _start_time;
|
||||
int _event_timeout;
|
||||
|
|
|
@ -63,9 +63,9 @@ void EasyCellularConnection::network_callback(nsapi_event_t ev, intptr_t ptr)
|
|||
}
|
||||
|
||||
EasyCellularConnection::EasyCellularConnection(bool debug) :
|
||||
_is_connected(false), _is_initialized(false), _target_state(CellularConnectionFSM::STATE_POWER_ON), _cellularSerial(
|
||||
MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE), _cellularSemaphore(0), _cellularConnectionFSM(0), _credentials_err(
|
||||
NSAPI_ERROR_OK), _status_cb(0)
|
||||
_is_connected(false), _is_initialized(false), _target_state(CellularConnectionFSM::STATE_POWER_ON), _cellularSerial(
|
||||
MDMTXD, MDMRXD, MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE), _cellularSemaphore(0), _cellularConnectionFSM(0), _credentials_err(
|
||||
NSAPI_ERROR_OK), _status_cb(0)
|
||||
{
|
||||
tr_info("EasyCellularConnection()");
|
||||
#if USE_APN_LOOKUP
|
||||
|
@ -203,9 +203,9 @@ nsapi_error_t EasyCellularConnection::connect()
|
|||
if (err == NSAPI_ERROR_OK) {
|
||||
const char *apn_config = apnconfig(imsi);
|
||||
if (apn_config) {
|
||||
const char* apn = _APN_GET(apn_config);
|
||||
const char* uname = _APN_GET(apn_config);
|
||||
const char* pwd = _APN_GET(apn_config);
|
||||
const char *apn = _APN_GET(apn_config);
|
||||
const char *uname = _APN_GET(apn_config);
|
||||
const char *pwd = _APN_GET(apn_config);
|
||||
tr_info("Looked up APN %s", apn);
|
||||
err = _cellularConnectionFSM->get_network()->set_credentials(apn, uname, pwd);
|
||||
}
|
||||
|
|
|
@ -25,15 +25,13 @@
|
|||
|
||||
#define USE_APN_LOOKUP (MBED_CONF_CELLULAR_USE_APN_LOOKUP || (NSAPI_PPP_AVAILABLE && MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP))
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
/** EasyCellularConnection class
|
||||
*
|
||||
* Simplified adapter for cellular connection
|
||||
*/
|
||||
class EasyCellularConnection: public CellularBase
|
||||
{
|
||||
class EasyCellularConnection: public CellularBase {
|
||||
|
||||
public:
|
||||
EasyCellularConnection(bool debug = false);
|
||||
|
@ -136,7 +134,7 @@ public:
|
|||
*
|
||||
* @param plmn operator in numeric format. See more from 3GPP TS 27.007 chapter 7.3.
|
||||
*/
|
||||
void set_plmn(const char* plmn);
|
||||
void set_plmn(const char *plmn);
|
||||
protected:
|
||||
|
||||
/** Provide access to the NetworkStack object
|
||||
|
|
|
@ -27,8 +27,7 @@
|
|||
#include "CellularInformation.h"
|
||||
#include "NetworkStack.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
/**
|
||||
* Class CellularDevice
|
||||
|
@ -36,8 +35,7 @@ namespace mbed
|
|||
* An abstract interface that defines opening and closing of cellular interfaces.
|
||||
* Deleting/Closing of opened interfaces can be done only via this class.
|
||||
*/
|
||||
class CellularDevice
|
||||
{
|
||||
class CellularDevice {
|
||||
public:
|
||||
/** virtual Destructor
|
||||
*/
|
||||
|
|
|
@ -35,8 +35,7 @@ const int MAX_OPERATOR_NAME_SHORT = 8;
|
|||
*
|
||||
* An abstract interface for connecting to a network and getting information from it.
|
||||
*/
|
||||
class CellularNetwork : public NetworkInterface
|
||||
{
|
||||
class CellularNetwork : public NetworkInterface {
|
||||
protected:
|
||||
// friend of CellularDevice so that it's the only way to close/delete this class.
|
||||
friend class CellularDevice;
|
||||
|
@ -117,18 +116,18 @@ public:
|
|||
};
|
||||
|
||||
enum RadioAccessTechnology {
|
||||
RAT_GSM,
|
||||
RAT_GSM_COMPACT,
|
||||
RAT_UTRAN,
|
||||
RAT_EGPRS,
|
||||
RAT_HSDPA,
|
||||
RAT_HSUPA,
|
||||
RAT_HSDPA_HSUPA,
|
||||
RAT_E_UTRAN,
|
||||
RAT_CATM1,
|
||||
RAT_NB1,
|
||||
RAT_UNKNOWN
|
||||
};
|
||||
RAT_GSM,
|
||||
RAT_GSM_COMPACT,
|
||||
RAT_UTRAN,
|
||||
RAT_EGPRS,
|
||||
RAT_HSDPA,
|
||||
RAT_HSUPA,
|
||||
RAT_HSDPA_HSUPA,
|
||||
RAT_E_UTRAN,
|
||||
RAT_CATM1,
|
||||
RAT_NB1,
|
||||
RAT_UNKNOWN
|
||||
};
|
||||
|
||||
// 3GPP TS 27.007 - 7.3 PLMN selection +COPS
|
||||
struct operator_t {
|
||||
|
@ -140,13 +139,14 @@ public:
|
|||
};
|
||||
|
||||
Status op_status;
|
||||
char op_long[MAX_OPERATOR_NAME_LONG+1];
|
||||
char op_short[MAX_OPERATOR_NAME_SHORT+1];
|
||||
char op_num[MAX_OPERATOR_NAME_SHORT+1];
|
||||
char op_long[MAX_OPERATOR_NAME_LONG + 1];
|
||||
char op_short[MAX_OPERATOR_NAME_SHORT + 1];
|
||||
char op_num[MAX_OPERATOR_NAME_SHORT + 1];
|
||||
RadioAccessTechnology op_rat;
|
||||
operator_t *next;
|
||||
|
||||
operator_t() {
|
||||
operator_t()
|
||||
{
|
||||
op_status = Unknown;
|
||||
op_rat = RAT_UNKNOWN;
|
||||
next = NULL;
|
||||
|
@ -157,14 +157,14 @@ public:
|
|||
|
||||
/* PDP Context information */
|
||||
struct pdpcontext_params_t {
|
||||
char apn[MAX_ACCESSPOINT_NAME_LENGTH+1];
|
||||
char local_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char local_subnet_mask[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char gateway_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char dns_primary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char dns_secondary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char p_cscf_prim_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char p_cscf_sec_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT+1];
|
||||
char apn[MAX_ACCESSPOINT_NAME_LENGTH + 1];
|
||||
char local_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char local_subnet_mask[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char gateway_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char dns_primary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char dns_secondary_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char p_cscf_prim_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
char p_cscf_sec_addr[MAX_IPV6_ADDR_IN_IPV4LIKE_DOTTED_FORMAT + 1];
|
||||
int cid;
|
||||
int bearer_id;
|
||||
int im_signalling_flag;
|
||||
|
@ -174,9 +174,10 @@ public:
|
|||
int local_addr_ind;
|
||||
int non_ip_mtu;
|
||||
int serving_plmn_rate_control_value;
|
||||
pdpcontext_params_t* next;
|
||||
pdpcontext_params_t *next;
|
||||
|
||||
pdpcontext_params_t() {
|
||||
pdpcontext_params_t()
|
||||
{
|
||||
apn[0] = '\0';
|
||||
local_addr[0] = '\0';
|
||||
local_subnet_mask[0] = '\0';
|
||||
|
@ -200,10 +201,11 @@ public:
|
|||
typedef CellularList<pdpcontext_params_t> pdpContextList_t;
|
||||
|
||||
struct operator_names_t {
|
||||
char numeric[MAX_OPERATOR_NAME_SHORT+1];
|
||||
char alpha[MAX_OPERATOR_NAME_LONG+1];
|
||||
operator_names_t* next;
|
||||
operator_names_t() {
|
||||
char numeric[MAX_OPERATOR_NAME_SHORT + 1];
|
||||
char alpha[MAX_OPERATOR_NAME_LONG + 1];
|
||||
operator_names_t *next;
|
||||
operator_names_t()
|
||||
{
|
||||
numeric[0] = '\0';
|
||||
alpha[0] = '\0';
|
||||
next = NULL;
|
||||
|
@ -240,7 +242,7 @@ public:
|
|||
* @param mode on successful return contains the current network registering mode
|
||||
* @return zero on success
|
||||
*/
|
||||
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode& mode) = 0;
|
||||
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode &mode) = 0;
|
||||
|
||||
/** Activate/deactivate listening of network events for the given RegistrationType.
|
||||
* This should be called after network class is created and ready to receive AT commands.
|
||||
|
@ -280,7 +282,7 @@ public:
|
|||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t set_credentials(const char *apn, AuthenticationType type,
|
||||
const char *username = 0, const char *password = 0) = 0;
|
||||
const char *username = 0, const char *password = 0) = 0;
|
||||
|
||||
/** Request attach to network.
|
||||
*
|
||||
|
@ -289,7 +291,7 @@ public:
|
|||
* @return zero on success
|
||||
*/
|
||||
MBED_DEPRECATED_SINCE("mbed-os-5.9", "Parameter timeout will be deprecated. Use mbed-os/features/cellular/framework/API/CellularDevice.h set_timeout instead.")
|
||||
virtual nsapi_error_t set_attach(int timeout = 10*1000) = 0;
|
||||
virtual nsapi_error_t set_attach(int timeout = 10 * 1000) = 0;
|
||||
|
||||
/** Request attach status from network.
|
||||
*
|
||||
|
@ -313,7 +315,7 @@ public:
|
|||
* @return zero on success
|
||||
*/
|
||||
virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports,
|
||||
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate) = 0;
|
||||
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate) = 0;
|
||||
|
||||
/** Get backoff timer value
|
||||
*
|
||||
|
@ -334,7 +336,7 @@ public:
|
|||
* @param rat Radio access technology
|
||||
* @return zero on success
|
||||
*/
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat) = 0;
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology &rat) = 0;
|
||||
|
||||
/** Scans for operators module can reach.
|
||||
*
|
||||
|
@ -359,8 +361,8 @@ public:
|
|||
* @param preferred_opt Preferred CIoT EPS optimizations.
|
||||
* @return zero on success
|
||||
*/
|
||||
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt& supported_opt,
|
||||
Preferred_UE_Opt& preferred_opt) = 0;
|
||||
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
|
||||
Preferred_UE_Opt &preferred_opt) = 0;
|
||||
|
||||
/** Start the interface. Attempts to connect to a cellular network.
|
||||
*
|
||||
|
@ -407,7 +409,7 @@ public:
|
|||
* @param params_list reference to linked list which is filled on successful call
|
||||
* @return 0 on success, negative error code on failure
|
||||
*/
|
||||
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t& params_list) = 0;
|
||||
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t ¶ms_list) = 0;
|
||||
|
||||
/** Get extended signal quality parameters.
|
||||
*
|
||||
|
|
|
@ -20,16 +20,14 @@
|
|||
#include "nsapi_types.h"
|
||||
#include "Callback.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
/**
|
||||
* Class CellularPower
|
||||
*
|
||||
* An interface that provides power handling functions for modem/module.
|
||||
*/
|
||||
class CellularPower
|
||||
{
|
||||
class CellularPower {
|
||||
protected:
|
||||
// friend of CellularDevice so that it's the only way to close/delete this class.
|
||||
friend class CellularDevice;
|
||||
|
|
|
@ -40,8 +40,7 @@ const int SMS_ERROR_MULTIPART_ALL_PARTS_NOT_READ = -5001;
|
|||
*
|
||||
* An abstract interface for SMS sending, reading and deleting.
|
||||
*/
|
||||
class CellularSMS
|
||||
{
|
||||
class CellularSMS {
|
||||
protected:
|
||||
// friend of CellularDevice so that it's the only way to close/delete this class.
|
||||
friend class CellularDevice;
|
||||
|
@ -72,7 +71,7 @@ public:
|
|||
* @param msg_len Length of the message
|
||||
* @return possible error code or length of the sent sms
|
||||
*/
|
||||
virtual nsapi_size_or_error_t send_sms(const char* phone_number, const char* message, int msg_len) = 0;
|
||||
virtual nsapi_size_or_error_t send_sms(const char *phone_number, const char *message, int msg_len) = 0;
|
||||
|
||||
/** Gets the oldest received sms.
|
||||
*
|
||||
|
@ -88,8 +87,8 @@ public:
|
|||
* @return possible error code or size of buf. Will return SMS_ERROR_MULTIPART_ALL_PARTS_NOT_READ
|
||||
* if sms was multipart but not all parts are present/failed to read.
|
||||
*/
|
||||
virtual nsapi_size_or_error_t get_sms(char* buf, uint16_t buf_len, char* phone_num, uint16_t phone_len,
|
||||
char* time_stamp, uint16_t time_len, int *buf_size) = 0;
|
||||
virtual nsapi_size_or_error_t get_sms(char *buf, uint16_t buf_len, char *phone_num, uint16_t phone_len,
|
||||
char *time_stamp, uint16_t time_len, int *buf_size) = 0;
|
||||
|
||||
/** Callback which is called when new sms is received. SMS can be fetched via method get_sms().
|
||||
*
|
||||
|
|
|
@ -1013,8 +1013,8 @@ void ATHandler::set_string(char *dest, const char *src, size_t src_len)
|
|||
const char *ATHandler::mem_str(const char *dest, size_t dest_len, const char *src, size_t src_len)
|
||||
{
|
||||
if (dest_len > src_len) {
|
||||
for(size_t i = 0; i < dest_len - src_len + 1; ++i) {
|
||||
if(memcmp(dest + i, src, src_len) == 0) {
|
||||
for (size_t i = 0; i < dest_len - src_len + 1; ++i) {
|
||||
if (memcmp(dest + i, src, src_len) == 0) {
|
||||
return dest + i;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@
|
|||
|
||||
#include "ATHandler.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
/**
|
||||
* Class AT_CellularDevice
|
||||
|
@ -37,8 +36,7 @@ namespace mbed
|
|||
* A class defines opening and closing of cellular interfaces.
|
||||
* Deleting/Closing of opened interfaces can be done only through this class.
|
||||
*/
|
||||
class AT_CellularDevice : public CellularDevice
|
||||
{
|
||||
class AT_CellularDevice : public CellularDevice {
|
||||
public:
|
||||
AT_CellularDevice(events::EventQueue &queue);
|
||||
virtual ~AT_CellularDevice();
|
||||
|
@ -52,7 +50,7 @@ protected:
|
|||
*
|
||||
* @param at_handler
|
||||
*/
|
||||
void release_at_handler(ATHandler* at_handler);
|
||||
void release_at_handler(ATHandler *at_handler);
|
||||
|
||||
public: // CellularDevice
|
||||
virtual CellularNetwork *open_network(FileHandle *fh);
|
||||
|
@ -87,8 +85,8 @@ protected:
|
|||
AT_CellularNetwork *_network;
|
||||
AT_CellularSMS *_sms;
|
||||
AT_CellularSIM *_sim;
|
||||
AT_CellularPower* _power;
|
||||
AT_CellularInformation* _information;
|
||||
AT_CellularPower *_power;
|
||||
AT_CellularInformation *_information;
|
||||
|
||||
protected:
|
||||
events::EventQueue &_queue;
|
||||
|
|
|
@ -195,7 +195,7 @@ void AT_CellularNetwork::urc_cgreg()
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||
const char *username, const char *password)
|
||||
const char *username, const char *password)
|
||||
{
|
||||
free_credentials();
|
||||
|
||||
|
@ -231,7 +231,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
||||
AuthenticationType type, const char *username, const char *password)
|
||||
AuthenticationType type, const char *username, const char *password)
|
||||
{
|
||||
nsapi_error_t err = set_credentials(apn, username, password);
|
||||
if (err) {
|
||||
|
@ -244,7 +244,7 @@ nsapi_error_t AT_CellularNetwork::set_credentials(const char *apn,
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::connect(const char *apn,
|
||||
const char *username, const char *password)
|
||||
const char *username, const char *password)
|
||||
{
|
||||
nsapi_error_t err = set_credentials(apn, username, password);
|
||||
if (err) {
|
||||
|
@ -1012,7 +1012,7 @@ nsapi_error_t AT_CellularNetwork::scan_plmn(operList_t &operators, int &opsCount
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(Supported_UE_Opt supported_opt,
|
||||
Preferred_UE_Opt preferred_opt)
|
||||
Preferred_UE_Opt preferred_opt)
|
||||
{
|
||||
_at.lock();
|
||||
|
||||
|
@ -1029,7 +1029,7 @@ nsapi_error_t AT_CellularNetwork::set_ciot_optimization_config(Supported_UE_Opt
|
|||
}
|
||||
|
||||
nsapi_error_t AT_CellularNetwork::get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
|
||||
Preferred_UE_Opt &preferred_opt)
|
||||
Preferred_UE_Opt &preferred_opt)
|
||||
{
|
||||
_at.lock();
|
||||
|
||||
|
|
|
@ -31,8 +31,7 @@ namespace mbed {
|
|||
*
|
||||
* Class for connecting to a network and getting information from it.
|
||||
*/
|
||||
class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase
|
||||
{
|
||||
class AT_CellularNetwork : public CellularNetwork, public AT_CellularBase {
|
||||
|
||||
public:
|
||||
|
||||
|
@ -47,7 +46,7 @@ public: // NetworkInterface
|
|||
const char *username = 0, const char *password = 0);
|
||||
|
||||
virtual nsapi_error_t set_credentials(const char *apn, AuthenticationType type,
|
||||
const char *username = 0, const char *password = 0);
|
||||
const char *username = 0, const char *password = 0);
|
||||
|
||||
virtual nsapi_error_t connect(const char *apn,
|
||||
const char *username = 0, const char *password = 0);
|
||||
|
@ -66,18 +65,18 @@ public: // CellularNetwork
|
|||
|
||||
virtual nsapi_error_t set_registration(const char *plmn = 0);
|
||||
|
||||
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode& mode);
|
||||
virtual nsapi_error_t get_network_registering_mode(NWRegisteringMode &mode);
|
||||
|
||||
virtual nsapi_error_t get_registration_status(RegistrationType type, RegistrationStatus &status);
|
||||
|
||||
virtual nsapi_error_t set_attach(int timeout = 10*1000);
|
||||
virtual nsapi_error_t set_attach(int timeout = 10 * 1000);
|
||||
|
||||
virtual nsapi_error_t get_attach(AttachStatus &status);
|
||||
|
||||
virtual nsapi_error_t detach();
|
||||
|
||||
virtual nsapi_error_t get_rate_control(CellularNetwork::RateControlExceptionReports &reports,
|
||||
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate);
|
||||
CellularNetwork::RateControlUplinkTimeUnit &time_unit, int &uplink_rate);
|
||||
|
||||
virtual nsapi_error_t get_apn_backoff_timer(int &backoff_timer);
|
||||
|
||||
|
@ -90,21 +89,21 @@ public: // CellularNetwork
|
|||
virtual const char *get_ip_address();
|
||||
|
||||
virtual nsapi_error_t set_access_technology(RadioAccessTechnology rat);
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology& rat);
|
||||
virtual nsapi_error_t get_access_technology(RadioAccessTechnology &rat);
|
||||
|
||||
virtual nsapi_error_t scan_plmn(operList_t &operators, int &ops_count);
|
||||
|
||||
virtual nsapi_error_t set_ciot_optimization_config(Supported_UE_Opt supported_opt,
|
||||
Preferred_UE_Opt preferred_opt);
|
||||
|
||||
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt& supported_opt,
|
||||
Preferred_UE_Opt& preferred_opt);
|
||||
virtual nsapi_error_t get_ciot_optimization_config(Supported_UE_Opt &supported_opt,
|
||||
Preferred_UE_Opt &preferred_opt);
|
||||
|
||||
virtual nsapi_error_t set_stack_type(nsapi_ip_stack_t stack_type);
|
||||
|
||||
virtual nsapi_ip_stack_t get_stack_type();
|
||||
|
||||
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t& params_list);
|
||||
virtual nsapi_error_t get_pdpcontext_params(pdpContextList_t ¶ms_list);
|
||||
|
||||
virtual nsapi_error_t get_extended_signal_quality(int &rxlev, int &ber, int &rscp, int &ecno, int &rsrq, int &rsrp);
|
||||
|
||||
|
@ -151,7 +150,7 @@ private:
|
|||
void urc_cgreg();
|
||||
void urc_cgev();
|
||||
|
||||
nsapi_ip_stack_t string_to_stack_type(const char* pdp_type);
|
||||
nsapi_ip_stack_t string_to_stack_type(const char *pdp_type);
|
||||
|
||||
void free_credentials();
|
||||
|
||||
|
|
|
@ -112,34 +112,34 @@ nsapi_error_t AT_CellularPower::opt_power_save_mode(int periodic_time, int activ
|
|||
1 1 0 value is incremented in multiples of 320 hours (NOTE 1)
|
||||
1 1 1 value indicates that the timer is deactivated (NOTE 2).
|
||||
*/
|
||||
char pt[8+1];// timer value encoded as 3GPP IE
|
||||
char pt[8 + 1]; // timer value encoded as 3GPP IE
|
||||
const int ie_value_max = 0x1f;
|
||||
uint32_t periodic_timer = 0;
|
||||
if (periodic_time <= 2*ie_value_max) { // multiples of 2 seconds
|
||||
periodic_timer = periodic_time/2;
|
||||
if (periodic_time <= 2 * ie_value_max) { // multiples of 2 seconds
|
||||
periodic_timer = periodic_time / 2;
|
||||
strcpy(pt, "01100000");
|
||||
} else {
|
||||
if (periodic_time <= 30*ie_value_max) { // multiples of 30 seconds
|
||||
periodic_timer = periodic_time/30;
|
||||
if (periodic_time <= 30 * ie_value_max) { // multiples of 30 seconds
|
||||
periodic_timer = periodic_time / 30;
|
||||
strcpy(pt, "10000000");
|
||||
} else {
|
||||
if (periodic_time <= 60*ie_value_max) { // multiples of 1 minute
|
||||
periodic_timer = periodic_time/60;
|
||||
if (periodic_time <= 60 * ie_value_max) { // multiples of 1 minute
|
||||
periodic_timer = periodic_time / 60;
|
||||
strcpy(pt, "10100000");
|
||||
} else {
|
||||
if (periodic_time <= 10*60*ie_value_max) { // multiples of 10 minutes
|
||||
periodic_timer = periodic_time/(10*60);
|
||||
if (periodic_time <= 10 * 60 * ie_value_max) { // multiples of 10 minutes
|
||||
periodic_timer = periodic_time / (10 * 60);
|
||||
strcpy(pt, "00000000");
|
||||
} else {
|
||||
if (periodic_time <= 60*60*ie_value_max) { // multiples of 1 hour
|
||||
periodic_timer = periodic_time/(60*60);
|
||||
if (periodic_time <= 60 * 60 * ie_value_max) { // multiples of 1 hour
|
||||
periodic_timer = periodic_time / (60 * 60);
|
||||
strcpy(pt, "00100000");
|
||||
} else {
|
||||
if (periodic_time <= 10*60*60*ie_value_max) { // multiples of 10 hours
|
||||
periodic_timer = periodic_time/(10*60*60);
|
||||
if (periodic_time <= 10 * 60 * 60 * ie_value_max) { // multiples of 10 hours
|
||||
periodic_timer = periodic_time / (10 * 60 * 60);
|
||||
strcpy(pt, "01000000");
|
||||
} else { // multiples of 320 hours
|
||||
int t = periodic_time / (320*60*60);
|
||||
int t = periodic_time / (320 * 60 * 60);
|
||||
if (t > ie_value_max) {
|
||||
t = ie_value_max;
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ nsapi_error_t AT_CellularPower::opt_power_save_mode(int periodic_time, int activ
|
|||
}
|
||||
}
|
||||
|
||||
uint_to_binary_str(periodic_timer, &pt[3], sizeof(pt)-3, PSMTimerBits);
|
||||
uint_to_binary_str(periodic_timer, &pt[3], sizeof(pt) - 3, PSMTimerBits);
|
||||
pt[8] = '\0';
|
||||
|
||||
/**
|
||||
|
@ -170,17 +170,17 @@ nsapi_error_t AT_CellularPower::opt_power_save_mode(int periodic_time, int activ
|
|||
|
||||
Other values shall be interpreted as multiples of 1 minute in this version of the protocol.
|
||||
*/
|
||||
char at[8+1];
|
||||
char at[8 + 1];
|
||||
uint32_t active_timer; // timer value encoded as 3GPP IE
|
||||
if (active_time <= 2*ie_value_max) { // multiples of 2 seconds
|
||||
active_timer = active_time/2;
|
||||
if (active_time <= 2 * ie_value_max) { // multiples of 2 seconds
|
||||
active_timer = active_time / 2;
|
||||
strcpy(at, "00000000");
|
||||
} else {
|
||||
if (active_time <= 60*ie_value_max) { // multiples of 1 minute
|
||||
active_timer = (1<<5) | (active_time/60);
|
||||
if (active_time <= 60 * ie_value_max) { // multiples of 1 minute
|
||||
active_timer = (1 << 5) | (active_time / 60);
|
||||
strcpy(at, "00100000");
|
||||
} else { // multiples of decihours
|
||||
int t = active_time / (6*60);
|
||||
int t = active_time / (6 * 60);
|
||||
if (t > ie_value_max) {
|
||||
t = ie_value_max;
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ nsapi_error_t AT_CellularPower::opt_power_save_mode(int periodic_time, int activ
|
|||
}
|
||||
}
|
||||
|
||||
uint_to_binary_str(active_timer, &at[3], sizeof(at)-3, PSMTimerBits);
|
||||
uint_to_binary_str(active_timer, &at[3], sizeof(at) - 3, PSMTimerBits);
|
||||
pt[8] = '\0';
|
||||
|
||||
// request for both GPRS and LTE
|
||||
|
|
|
@ -28,8 +28,7 @@ namespace mbed {
|
|||
*
|
||||
* Class that provides power handling functions for modem/module.
|
||||
*/
|
||||
class AT_CellularPower : public CellularPower, public AT_CellularBase
|
||||
{
|
||||
class AT_CellularPower : public CellularPower, public AT_CellularBase {
|
||||
public:
|
||||
AT_CellularPower(ATHandler &atHandler);
|
||||
virtual ~AT_CellularPower();
|
||||
|
|
|
@ -172,10 +172,10 @@ static const int gsm_to_ascii[] = {
|
|||
224 // 127
|
||||
};
|
||||
|
||||
const int GSM_TO_ASCII_TABLE_SIZE = sizeof(gsm_to_ascii)/sizeof(gsm_to_ascii[0]);
|
||||
const int GSM_TO_ASCII_TABLE_SIZE = sizeof(gsm_to_ascii) / sizeof(gsm_to_ascii[0]);
|
||||
|
||||
AT_CellularSMS::AT_CellularSMS(ATHandler &at) : AT_CellularBase(at), _cb(0), _mode(CellularSMSMmodeText),
|
||||
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
|
||||
_use_8bit_encoding(false), _sim_wait_time(0), _sms_message_ref_number(1), _sms_info(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -281,14 +281,14 @@ void AT_CellularSMS::set_extra_sim_wait_time(int sim_wait_time)
|
|||
_sim_wait_time = sim_wait_time;
|
||||
}
|
||||
|
||||
char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t& header_size)
|
||||
char *AT_CellularSMS::create_pdu(const char *phone_number, const char *message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t &header_size)
|
||||
{
|
||||
int totalPDULength = 0;
|
||||
int number_len = strlen(phone_number);
|
||||
|
||||
totalPDULength += number_len;
|
||||
if (number_len&0x01) {// if phone number length is not even length we must pad it and so +1
|
||||
if (number_len & 0x01) { // if phone number length is not even length we must pad it and so +1
|
||||
totalPDULength += 1;
|
||||
}
|
||||
|
||||
|
@ -297,12 +297,12 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
totalPDULength += 12;
|
||||
}
|
||||
// there might be need for padding so some more space
|
||||
totalPDULength +=2;
|
||||
totalPDULength += 2;
|
||||
|
||||
// message 7-bit padded and it will be converted to hex so it will take twice as much space
|
||||
totalPDULength += (message_length - (message_length/8))*2;
|
||||
totalPDULength += (message_length - (message_length / 8)) * 2;
|
||||
|
||||
char* pdu = (char*)calloc(totalPDULength, sizeof(char));
|
||||
char *pdu = (char *)calloc(totalPDULength, sizeof(char));
|
||||
if (!pdu) {
|
||||
return NULL;
|
||||
}
|
||||
|
@ -324,8 +324,8 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
pdu[x++] = '0';
|
||||
pdu[x++] = '0';
|
||||
// [6] and [7] Length of the Destination Phone Number
|
||||
int_to_hex_str(number_len, pdu+x);
|
||||
x+=2;
|
||||
int_to_hex_str(number_len, pdu + x);
|
||||
x += 2;
|
||||
// Type of the Destination Phone Number
|
||||
pdu[x++] = '8';
|
||||
pdu[x++] = '1';
|
||||
|
@ -333,10 +333,10 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
// phone number as reverse nibble encoded
|
||||
int i = 0;
|
||||
for (; i < number_len; i += 2) {
|
||||
if (i+1 == number_len) {
|
||||
if (i + 1 == number_len) {
|
||||
pdu[x++] = 'f';
|
||||
} else {
|
||||
pdu[x++] = phone_number[i+1];
|
||||
pdu[x++] = phone_number[i + 1];
|
||||
}
|
||||
pdu[x++] = phone_number[i];
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
uint8_t udhlen = 0;
|
||||
// Length can be update after we have created PDU, store position for later use.
|
||||
int lengthPos = x;
|
||||
x +=2;
|
||||
x += 2;
|
||||
|
||||
int paddingBits = 0;
|
||||
if (msg_parts > 1) { // concatenated, must use UDH
|
||||
|
@ -371,17 +371,17 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
pdu[x++] = '0';
|
||||
pdu[x++] = '3';
|
||||
// A reference number (must be the same for all parts of the same larger messages)
|
||||
int_to_hex_str(_sms_message_ref_number&0xFF, pdu+x);
|
||||
x +=2;
|
||||
int_to_hex_str(_sms_message_ref_number & 0xFF, pdu + x);
|
||||
x += 2;
|
||||
// How many parts does this message have?
|
||||
int_to_hex_str(msg_parts, pdu+x);
|
||||
x +=2;
|
||||
int_to_hex_str(msg_parts, pdu + x);
|
||||
x += 2;
|
||||
// this is a part number
|
||||
int_to_hex_str(msg_part_number, pdu+x);
|
||||
x +=2;
|
||||
int_to_hex_str(msg_part_number, pdu + x);
|
||||
x += 2;
|
||||
|
||||
// if there is padding bits then udhlen is octet bigger as we need to keep septet boundary
|
||||
paddingBits = (udhlen * 8 ) % 7;
|
||||
paddingBits = (udhlen * 8) % 7;
|
||||
if (paddingBits) {
|
||||
paddingBits = 7 - paddingBits;
|
||||
udhlen += 1;
|
||||
|
@ -389,11 +389,11 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
}
|
||||
|
||||
if (_use_8bit_encoding) {
|
||||
char_str_to_hex_str(message, message_length, pdu+x);
|
||||
char_str_to_hex_str(message, message_length, pdu + x);
|
||||
} else {
|
||||
// we might need to send zero length sms
|
||||
if (message_length) {
|
||||
if (pack_7_bit_gsm_and_hex(message, message_length, pdu+x, paddingBits) == 0) {
|
||||
if (pack_7_bit_gsm_and_hex(message, message_length, pdu + x, paddingBits) == 0) {
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -401,16 +401,16 @@ char* AT_CellularSMS::create_pdu(const char* phone_number, const char* message,
|
|||
}
|
||||
|
||||
// now we know the correct length of the UDL (User Data Length)
|
||||
int_to_hex_str(message_length + udhlen, pdu+lengthPos);
|
||||
int_to_hex_str(message_length + udhlen, pdu + lengthPos);
|
||||
header_size = x;
|
||||
|
||||
return pdu;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const char* message, int msg_len)
|
||||
nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const char *message, int msg_len)
|
||||
{
|
||||
int single_sms_max_length = _use_8bit_encoding ? SMS_MAX_SIZE_8BIT_SINGLE_SMS_SIZE :
|
||||
SMS_MAX_SIZE_GSM7_SINGLE_SMS_SIZE;
|
||||
SMS_MAX_SIZE_GSM7_SINGLE_SMS_SIZE;
|
||||
if ((_mode == CellularSMSMmodeText && msg_len > single_sms_max_length) || !phone_number) {
|
||||
return NSAPI_ERROR_PARAMETER;
|
||||
}
|
||||
|
@ -424,14 +424,14 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const c
|
|||
|
||||
if (_mode == CellularSMSMmodeText) {
|
||||
_at.cmd_start("AT+CMGS=");
|
||||
_at.write_string(phone_number+remove_plus_sign);
|
||||
_at.write_string(phone_number + remove_plus_sign);
|
||||
_at.cmd_stop();
|
||||
|
||||
wait_ms(_sim_wait_time);
|
||||
_at.resp_start("> ", true);
|
||||
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK) {
|
||||
write_size = _at.write_bytes((uint8_t*)message, msg_len);
|
||||
write_size = _at.write_bytes((uint8_t *)message, msg_len);
|
||||
if (write_size < msg_len) {
|
||||
// sending can be cancelled by giving <ESC> character (IRA 27).
|
||||
_at.cmd_start(ESC);
|
||||
|
@ -450,15 +450,15 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const c
|
|||
// GSM 7 bit default but support is done for 8 bit data.
|
||||
int sms_count;
|
||||
int concatenated_sms_length = _use_8bit_encoding ? SMS_MAX_8BIT_CONCATENATED_SINGLE_SMS_SIZE :
|
||||
SMS_MAX_GSM7_CONCATENATED_SINGLE_SMS_SIZE;
|
||||
SMS_MAX_GSM7_CONCATENATED_SINGLE_SMS_SIZE;
|
||||
|
||||
if (msg_len <= single_sms_max_length) {
|
||||
// single message
|
||||
sms_count = 1;
|
||||
} else {
|
||||
// concatenated message
|
||||
sms_count = msg_len/concatenated_sms_length;
|
||||
if (msg_len%concatenated_sms_length != 0) {
|
||||
sms_count = msg_len / concatenated_sms_length;
|
||||
if (msg_len % concatenated_sms_length != 0) {
|
||||
sms_count++;
|
||||
}
|
||||
}
|
||||
|
@ -477,8 +477,8 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const c
|
|||
pdu_len = remaining_len > concatenated_sms_length ? concatenated_sms_length : remaining_len;
|
||||
}
|
||||
|
||||
pdu_str = create_pdu(phone_number+remove_plus_sign, message + i*concatenated_sms_length, pdu_len,
|
||||
sms_count, i+1, header_len);
|
||||
pdu_str = create_pdu(phone_number + remove_plus_sign, message + i * concatenated_sms_length, pdu_len,
|
||||
sms_count, i + 1, header_len);
|
||||
if (!pdu_str) {
|
||||
_at.unlock();
|
||||
return NSAPI_ERROR_NO_MEMORY;
|
||||
|
@ -487,21 +487,21 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char* phone_number, const c
|
|||
|
||||
// specification says that service center number should not be included so we subtract -2 from pdu_len as we use '00' for automatic service center number
|
||||
_at.cmd_start("AT+CMGS=");
|
||||
_at.write_int((pdu_len-2)/2);
|
||||
_at.write_int((pdu_len - 2) / 2);
|
||||
_at.cmd_stop();
|
||||
|
||||
wait_ms(_sim_wait_time);
|
||||
_at.resp_start("> ", true);
|
||||
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK) {
|
||||
write_size = _at.write_bytes((uint8_t*)pdu_str, pdu_len);
|
||||
write_size = _at.write_bytes((uint8_t *)pdu_str, pdu_len);
|
||||
if (write_size < pdu_len) {
|
||||
// calculate exact size of what we have send
|
||||
if (write_size <= header_len) {
|
||||
// managed only to write header or some of it so actual msg write size in this iteration is 0
|
||||
write_size = 0;
|
||||
} else {
|
||||
write_size = (write_size - header_len)/2; // as hex encoded so divide by two
|
||||
write_size = (write_size - header_len) / 2; // as hex encoded so divide by two
|
||||
}
|
||||
msg_write_len += write_size;
|
||||
|
||||
|
@ -578,7 +578,7 @@ nsapi_size_or_error_t AT_CellularSMS::set_cscs(const char *chr_set)
|
|||
return _at.unlock_return_error();
|
||||
}
|
||||
|
||||
nsapi_error_t AT_CellularSMS::delete_sms(sms_info_t* sms)
|
||||
nsapi_error_t AT_CellularSMS::delete_sms(sms_info_t *sms)
|
||||
{
|
||||
_at.lock();
|
||||
for (int i = 0; i < sms->parts; i++) {
|
||||
|
@ -607,8 +607,8 @@ nsapi_error_t AT_CellularSMS::delete_all_messages()
|
|||
}
|
||||
|
||||
// read msg in text mode
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char* buf, uint16_t len, char* phone_num,
|
||||
char* time_stamp)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char *buf, uint16_t len, char *phone_num,
|
||||
char *time_stamp)
|
||||
{
|
||||
/*
|
||||
* +CMGR: <stat>,<oa>,<alpha>,<scts>[,<tooa>,<fo>,<pid>,<dcs>,<sca>,<tosca>,<length>]<CR><LF><data><CR><LF>OK<CR><LF>
|
||||
|
@ -635,8 +635,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char* b
|
|||
// Received message
|
||||
if (phone_num) {
|
||||
_at.read_string(phone_num, SMS_MAX_PHONE_NUMBER_SIZE);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_at.skip_param(); // <oa>,<alpha>
|
||||
}
|
||||
_at.skip_param(); // <alpha>
|
||||
|
@ -657,7 +656,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms_from_index(int msg_index, char* b
|
|||
}
|
||||
|
||||
// read msg in PDU mode
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char* phone_num, char* time_stamp)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t *sms, char *buf, char *phone_num, char *time_stamp)
|
||||
{
|
||||
// +CMGR: <stat>,[<alpha>],<length><CR><LF><pdu>
|
||||
int index;
|
||||
|
@ -681,15 +680,15 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char*
|
|||
if ((_at.get_last_error() == NSAPI_ERROR_OK) && (status == 0 || status == 1)) {
|
||||
msg_len = _at.read_int();
|
||||
if (msg_len > 0) {
|
||||
pduSize = msg_len*2 + 20;// *2 as it's hex encoded and +20 as service center number is not included in size given by CMGR
|
||||
pdu = (char*)calloc(pduSize, sizeof(char));
|
||||
pduSize = msg_len * 2 + 20; // *2 as it's hex encoded and +20 as service center number is not included in size given by CMGR
|
||||
pdu = (char *)calloc(pduSize, sizeof(char));
|
||||
if (!pdu) {
|
||||
_at.resp_stop();
|
||||
return NSAPI_ERROR_NO_MEMORY;
|
||||
}
|
||||
_at.read_string(pdu, pduSize, true);
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK) {
|
||||
msg_len = get_data_from_pdu(pdu, NULL, NULL, phone_num, buf+index);
|
||||
msg_len = get_data_from_pdu(pdu, NULL, NULL, phone_num, buf + index);
|
||||
if (msg_len >= 0) { // we need to allow zero length messages
|
||||
index += msg_len;
|
||||
} else {
|
||||
|
@ -711,8 +710,7 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char*
|
|||
}
|
||||
buf[index] = '\0';
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
tr_warn("NOT all concatenated parts were received...");
|
||||
index = SMS_ERROR_MULTIPART_ALL_PARTS_NOT_READ;
|
||||
}
|
||||
|
@ -720,8 +718,8 @@ nsapi_size_or_error_t AT_CellularSMS::read_sms(sms_info_t* sms, char* buf, char*
|
|||
return index;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* phone_num, uint16_t phone_len,
|
||||
char* time_stamp, uint16_t time_len, int *buf_size)
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_sms(char *buf, uint16_t len, char *phone_num, uint16_t phone_len,
|
||||
char *time_stamp, uint16_t time_len, int *buf_size)
|
||||
{
|
||||
// validate buffer sizes already here to avoid any necessary function calls and locking of _at
|
||||
if ((phone_num && phone_len < SMS_MAX_PHONE_NUMBER_SIZE) || (time_stamp && time_len < SMS_MAX_TIME_STAMP_SIZE) ||
|
||||
|
@ -734,10 +732,10 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* pho
|
|||
nsapi_size_or_error_t err = list_messages();
|
||||
if (err == NSAPI_ERROR_OK) {
|
||||
// we return the oldest sms and delete it after successful read
|
||||
sms_info_t* info = get_oldest_sms_index();
|
||||
sms_info_t *info = get_oldest_sms_index();
|
||||
|
||||
if (info) {
|
||||
if (info->msg_size+1 > len) { // +1 for '\0'
|
||||
if (info->msg_size + 1 > len) { // +1 for '\0'
|
||||
tr_warn("Given buf too small, len is: %d but is must be: %d", len, info->msg_size);
|
||||
if (buf_size) {
|
||||
*buf_size = info->msg_size;
|
||||
|
@ -776,8 +774,8 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* pho
|
|||
return err;
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char* pdu, sms_info_t *info, int *part_number,
|
||||
char *phone_number, char *msg)
|
||||
nsapi_size_or_error_t AT_CellularSMS::get_data_from_pdu(const char *pdu, sms_info_t *info, int *part_number,
|
||||
char *phone_number, char *msg)
|
||||
{
|
||||
int index = 0;
|
||||
int tmp;
|
||||
|
@ -789,81 +787,81 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* pho
|
|||
// read Length of the SMSC information
|
||||
oaLength = hex_str_to_int(pdu, 2);
|
||||
index += 2; // length we just read
|
||||
index += oaLength*2; // skip service center number
|
||||
index += oaLength * 2; // skip service center number
|
||||
|
||||
// read first the lower part of first octet as there is message type
|
||||
index++;
|
||||
tmp = hex_str_to_int(pdu+index, 1);
|
||||
tmp = hex_str_to_int(pdu + index, 1);
|
||||
//wait_ms(200);
|
||||
if ((tmp & 0x03) == 0) {// SMS-DELIVER type, last two bits should be zero
|
||||
// UDH present? Check from first octets higher part
|
||||
tmp = hex_str_to_int(pdu + (--index), 1);
|
||||
userDataHeader = ((tmp & 0x04) == 0) ? false : true;
|
||||
|
||||
index +=2; // we just read the high bits of first octet so move +2
|
||||
index += 2; // we just read the high bits of first octet so move +2
|
||||
// originating address length
|
||||
oaLength = hex_str_to_int(pdu+index, 2);
|
||||
index +=2; // add index over address length
|
||||
index +=2; // skip number type
|
||||
oaLength = hex_str_to_int(pdu + index, 2);
|
||||
index += 2; // add index over address length
|
||||
index += 2; // skip number type
|
||||
if (phone_number) {
|
||||
// phone number as reverse nibble encoded
|
||||
int a = 0;
|
||||
for (; a < oaLength; a +=2) {
|
||||
if (a+1 == oaLength) {
|
||||
phone_number[a] = pdu[index+a+1];
|
||||
for (; a < oaLength; a += 2) {
|
||||
if (a + 1 == oaLength) {
|
||||
phone_number[a] = pdu[index + a + 1];
|
||||
} else {
|
||||
phone_number[a] = pdu[index+a+1];
|
||||
phone_number[a+1] = pdu[index+a];
|
||||
phone_number[a] = pdu[index + a + 1];
|
||||
phone_number[a + 1] = pdu[index + a];
|
||||
}
|
||||
}
|
||||
phone_number[oaLength] = '\0';
|
||||
}
|
||||
|
||||
index += oaLength;
|
||||
if (oaLength&0x01) { // if phone number length is odd then it has padded F so skip that
|
||||
if (oaLength & 0x01) { // if phone number length is odd then it has padded F so skip that
|
||||
index++;
|
||||
}
|
||||
index +=2; // skip TP-Protocol identifier
|
||||
index += 2; // skip TP-Protocol identifier
|
||||
|
||||
dataScheme = hex_str_to_int(pdu+index, 2);
|
||||
index +=2; // skip TP-Data-Coding-Scheme
|
||||
dataScheme = hex_str_to_int(pdu + index, 2);
|
||||
index += 2; // skip TP-Data-Coding-Scheme
|
||||
|
||||
// next one is date, it's length is 7 octets according to 3GPP TS 23.040
|
||||
// create time string
|
||||
if (info) {
|
||||
int i = 0;
|
||||
// year
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
info->date[i++] = '/';
|
||||
// month
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
info->date[i++] = '/';
|
||||
// Day
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
info->date[i++] = ',';
|
||||
// Hour
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
info->date[i++] = ':';
|
||||
// Minute
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
info->date[i++] = ':';
|
||||
// Second
|
||||
info->date[i++] = pdu[index+1];
|
||||
info->date[i++] = pdu[index + 1];
|
||||
info->date[i++] = pdu[index];
|
||||
index+=2;
|
||||
index += 2;
|
||||
// timezone related to GMT. pdu[index+1] most significant bit indicates the sign related to gmt
|
||||
tmp = hex_str_to_int(pdu+index+1, 1);
|
||||
if (tmp&0x08) {
|
||||
tmp = hex_str_to_int(pdu + index + 1, 1);
|
||||
if (tmp & 0x08) {
|
||||
info->date[i++] = '-';
|
||||
} else {
|
||||
info->date[i++] = '+';
|
||||
|
@ -874,19 +872,19 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* pho
|
|||
info->date[i++] = '0' + (tmp & 0x07);
|
||||
info->date[i++] = pdu[index];
|
||||
info->date[i] = '\0';
|
||||
index+=2;
|
||||
index += 2;
|
||||
} else {
|
||||
index+=14;
|
||||
index += 14;
|
||||
}
|
||||
|
||||
int udl = hex_str_to_int(pdu+index, 2);
|
||||
index +=2;
|
||||
int udl = hex_str_to_int(pdu + index, 2);
|
||||
index += 2;
|
||||
|
||||
int paddingBits = 0;
|
||||
int partnro = 1;
|
||||
if (userDataHeader) {
|
||||
// we need to read User Defined Header to know what part number this message is.
|
||||
index += read_udh_from_pdu(pdu+index, info, partnro, paddingBits);
|
||||
index += read_udh_from_pdu(pdu + index, info, partnro, paddingBits);
|
||||
}
|
||||
|
||||
if (part_number) {
|
||||
|
@ -895,38 +893,37 @@ nsapi_size_or_error_t AT_CellularSMS::get_sms(char* buf, uint16_t len, char* pho
|
|||
|
||||
if (msg) {
|
||||
// we are reading the message
|
||||
err = read_pdu_payload(pdu+index, udl, dataScheme, msg, paddingBits);
|
||||
}
|
||||
else {
|
||||
err = read_pdu_payload(pdu + index, udl, dataScheme, msg, paddingBits);
|
||||
} else {
|
||||
if (dataScheme == 0x00) {
|
||||
// when listing messages we need to calculated length. Other way would be unpacking the whole message.
|
||||
err = strlen(pdu+index) >> 1;
|
||||
err = strlen(pdu + index) >> 1;
|
||||
err *= 8;
|
||||
err /= 7;
|
||||
} else if (dataScheme == 0x04) {
|
||||
err = strlen(pdu+index) >> 1;
|
||||
err = strlen(pdu + index) >> 1;
|
||||
} else {
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// message was not DELIVER so discard it
|
||||
return NSAPI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
}
|
||||
|
||||
// read params from User Defined Header
|
||||
int AT_CellularSMS::read_udh_from_pdu(const char* pdu, sms_info_t *info, int &part_number, int &padding_bits) {
|
||||
// read params from User Defined Header
|
||||
int AT_CellularSMS::read_udh_from_pdu(const char *pdu, sms_info_t *info, int &part_number, int &padding_bits)
|
||||
{
|
||||
|
||||
int index = 0;
|
||||
int udhLength = hex_str_to_int(pdu, 2);
|
||||
index +=2;
|
||||
index += 2;
|
||||
|
||||
// if there is padding bits then udhlen is octet bigger as we need to keep septet boundary
|
||||
padding_bits = ((udhLength+1) * 8 ) % 7; // +1 is for udhLength itself
|
||||
padding_bits = ((udhLength + 1) * 8) % 7; // +1 is for udhLength itself
|
||||
|
||||
if (padding_bits) {
|
||||
padding_bits = 7 - padding_bits;
|
||||
|
@ -934,39 +931,39 @@ int AT_CellularSMS::read_udh_from_pdu(const char* pdu, sms_info_t *info, int &pa
|
|||
padding_bits = 0;
|
||||
}
|
||||
|
||||
int tmp = hex_str_to_int(pdu+index, 2);
|
||||
index +=4;
|
||||
int tmp = hex_str_to_int(pdu + index, 2);
|
||||
index += 4;
|
||||
|
||||
if (tmp == 0) { // 8-bit reference number
|
||||
if (info) {
|
||||
info->msg_ref_number = (uint16_t)hex_str_to_int(pdu+index, 2);
|
||||
info->msg_ref_number = (uint16_t)hex_str_to_int(pdu + index, 2);
|
||||
}
|
||||
index +=2;
|
||||
index += 2;
|
||||
} else { // 16-bit reference number
|
||||
if (info) {
|
||||
info->msg_ref_number = (uint16_t)hex_str_to_int(pdu+index+2, 2);
|
||||
tmp = hex_str_to_int(pdu+index, 2);
|
||||
info->msg_ref_number = (uint16_t)hex_str_to_int(pdu + index + 2, 2);
|
||||
tmp = hex_str_to_int(pdu + index, 2);
|
||||
info->msg_ref_number |= (tmp << 8);
|
||||
}
|
||||
index +=4;
|
||||
index += 4;
|
||||
}
|
||||
|
||||
if (info) {
|
||||
info->parts = hex_str_to_int(pdu+index, 2);
|
||||
info->parts = hex_str_to_int(pdu + index, 2);
|
||||
}
|
||||
index +=2;
|
||||
index += 2;
|
||||
|
||||
part_number = hex_str_to_int(pdu+index, 2);
|
||||
index +=2;
|
||||
part_number = hex_str_to_int(pdu + index, 2);
|
||||
index += 2;
|
||||
|
||||
return (udhLength*2 + 2); // udh in hex and udhl
|
||||
return (udhLength * 2 + 2); // udh in hex and udhl
|
||||
}
|
||||
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char* pdu, int msg_len, int scheme, char *msg, int padding_bits)
|
||||
nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char *pdu, int msg_len, int scheme, char *msg, int padding_bits)
|
||||
{
|
||||
if (scheme == 0x00) {
|
||||
// 7 bit gsm encoding, must do the conversions from hex to 7-bit encoding and to ascii
|
||||
return unpack_7_bit_gsm_to_str(pdu, strlen(pdu)/2, msg, padding_bits, msg_len);
|
||||
return unpack_7_bit_gsm_to_str(pdu, strlen(pdu) / 2, msg, padding_bits, msg_len);
|
||||
} else if (scheme == 0x04) {
|
||||
// 8bit scheme so just convert hexstring to charstring
|
||||
return hex_str_to_char_str(pdu, strlen(pdu), msg);
|
||||
|
@ -978,8 +975,8 @@ nsapi_size_or_error_t AT_CellularSMS::read_pdu_payload(const char* pdu, int msg_
|
|||
|
||||
void AT_CellularSMS::free_linked_list()
|
||||
{
|
||||
sms_info_t* info = _sms_info;
|
||||
sms_info_t* old;
|
||||
sms_info_t *info = _sms_info;
|
||||
sms_info_t *old;
|
||||
while (info) {
|
||||
old = info;
|
||||
info = info->next_info;
|
||||
|
@ -988,17 +985,18 @@ void AT_CellularSMS::free_linked_list()
|
|||
_sms_info = NULL;
|
||||
}
|
||||
|
||||
void AT_CellularSMS::add_info(sms_info_t* info, int index, int part_number) {
|
||||
void AT_CellularSMS::add_info(sms_info_t *info, int index, int part_number)
|
||||
{
|
||||
// check for same message reference id. If found, update it and delete the given info.
|
||||
// if NOT found then add to the end of the list.
|
||||
|
||||
if (!_sms_info) {
|
||||
info->msg_index[part_number-1] = index; // part numbering starts from 1 so -1 to put to right index
|
||||
info->msg_index[part_number - 1] = index; // part numbering starts from 1 so -1 to put to right index
|
||||
_sms_info = info;
|
||||
return;
|
||||
}
|
||||
sms_info_t* current = _sms_info;
|
||||
sms_info_t* prev;
|
||||
sms_info_t *current = _sms_info;
|
||||
sms_info_t *prev;
|
||||
bool found_msg = false;
|
||||
while (current) {
|
||||
prev = current;
|
||||
|
@ -1008,7 +1006,7 @@ void AT_CellularSMS::add_info(sms_info_t* info, int index, int part_number) {
|
|||
info->parts > info->parts_added) {
|
||||
// multipart sms, update msg size and index
|
||||
current->msg_size += info->msg_size;
|
||||
current->msg_index[part_number-1] = index; // part numbering starts from 1 so -1 to put to right index
|
||||
current->msg_index[part_number - 1] = index; // part numbering starts from 1 so -1 to put to right index
|
||||
current->parts_added++;
|
||||
// update oldest part as date
|
||||
if (compare_time_strings(info->date, current->date) == -1) {
|
||||
|
@ -1025,7 +1023,7 @@ void AT_CellularSMS::add_info(sms_info_t* info, int index, int part_number) {
|
|||
delete info;
|
||||
} else {
|
||||
// message not found, add to linked list
|
||||
info->msg_index[part_number-1] = index;
|
||||
info->msg_index[part_number - 1] = index;
|
||||
prev->next_info = info;
|
||||
}
|
||||
}
|
||||
|
@ -1043,7 +1041,7 @@ nsapi_error_t AT_CellularSMS::list_messages()
|
|||
}
|
||||
_at.cmd_stop();
|
||||
|
||||
sms_info_t* info = NULL;
|
||||
sms_info_t *info = NULL;
|
||||
// init for 1 so that in text mode we will add to the correct place without any additional logic in addInfo() in text mode
|
||||
int part_number = 1;
|
||||
int index = 0;
|
||||
|
@ -1065,8 +1063,8 @@ nsapi_error_t AT_CellularSMS::list_messages()
|
|||
index = _at.read_int();
|
||||
_at.skip_param(2); // <stat>,[<alpha>]
|
||||
length = _at.read_int();
|
||||
length = length*2 + 20;// *2 as it's hex encoded and +20 as service center number is not included in size given by CMGL
|
||||
pdu = (char*)calloc(length, sizeof(char));
|
||||
length = length * 2 + 20; // *2 as it's hex encoded and +20 as service center number is not included in size given by CMGL
|
||||
pdu = (char *)calloc(length, sizeof(char));
|
||||
if (!pdu) {
|
||||
delete info;
|
||||
_at.resp_stop();
|
||||
|
@ -1100,7 +1098,7 @@ nsapi_error_t AT_CellularSMS::list_messages()
|
|||
return _at.get_last_error();
|
||||
}
|
||||
|
||||
AT_CellularSMS::sms_info_t* AT_CellularSMS::get_oldest_sms_index()
|
||||
AT_CellularSMS::sms_info_t *AT_CellularSMS::get_oldest_sms_index()
|
||||
{
|
||||
/*
|
||||
* Different scenarios when finding the oldest concatenated sms
|
||||
|
@ -1114,8 +1112,8 @@ AT_CellularSMS::sms_info_t* AT_CellularSMS::get_oldest_sms_index()
|
|||
*/
|
||||
|
||||
// if text mode we need to read sms with +CMGR because time stamp is optional while looping with +CMGL
|
||||
sms_info_t* retVal = NULL;
|
||||
sms_info_t* current = _sms_info;
|
||||
sms_info_t *retVal = NULL;
|
||||
sms_info_t *current = _sms_info;
|
||||
nsapi_size_or_error_t err = 0;
|
||||
while (current) {
|
||||
if (_mode == CellularSMSMmodeText) {
|
||||
|
@ -1139,7 +1137,7 @@ AT_CellularSMS::sms_info_t* AT_CellularSMS::get_oldest_sms_index()
|
|||
}
|
||||
|
||||
// if time_string_1 is greater (more fresh date) then return 1, same 0, smaller -1. Error -2
|
||||
int AT_CellularSMS::compare_time_strings(const char* time_string_1, const char* time_string_2)
|
||||
int AT_CellularSMS::compare_time_strings(const char *time_string_1, const char *time_string_2)
|
||||
{
|
||||
time_t t1;
|
||||
time_t t2;
|
||||
|
@ -1162,7 +1160,7 @@ int AT_CellularSMS::compare_time_strings(const char* time_string_1, const char*
|
|||
return retVal;
|
||||
}
|
||||
|
||||
bool AT_CellularSMS::create_time(const char* time_string, time_t* time)
|
||||
bool AT_CellularSMS::create_time(const char *time_string, time_t *time)
|
||||
{
|
||||
const int kNumberOfElements = 8;
|
||||
tm time_struct = { 0 };
|
||||
|
@ -1186,8 +1184,8 @@ bool AT_CellularSMS::create_time(const char* time_string, time_t* time)
|
|||
return retVal;
|
||||
}
|
||||
|
||||
uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, char *buf,
|
||||
int number_of_padding_bit)
|
||||
uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char *str, uint16_t len, char *buf,
|
||||
int number_of_padding_bit)
|
||||
{
|
||||
uint16_t strCnt = 0;
|
||||
uint16_t i = 0;
|
||||
|
@ -1198,12 +1196,12 @@ uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, c
|
|||
return 0;
|
||||
}
|
||||
// convert to 7bit gsm first
|
||||
char* gsm_str = (char*)malloc(len);
|
||||
char *gsm_str = (char *)malloc(len);
|
||||
if (!gsm_str) {
|
||||
return 0;
|
||||
}
|
||||
for (uint16_t y = 0; y < len; y++) {
|
||||
for (int x=0; x < GSM_TO_ASCII_TABLE_SIZE; x++) {
|
||||
for (int x = 0; x < GSM_TO_ASCII_TABLE_SIZE; x++) {
|
||||
if (gsm_to_ascii[x] == str[y]) {
|
||||
gsm_str[y] = x;
|
||||
}
|
||||
|
@ -1212,26 +1210,26 @@ uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, c
|
|||
|
||||
// then packing and converting to hex
|
||||
if (number_of_padding_bit) {
|
||||
tmp = gsm_str[strCnt]<<number_of_padding_bit;
|
||||
tmp = gsm_str[strCnt] << number_of_padding_bit;
|
||||
strCnt++;
|
||||
char_str_to_hex_str(&tmp, 1, &buf[i*2]);
|
||||
char_str_to_hex_str(&tmp, 1, &buf[i * 2]);
|
||||
i++;
|
||||
}
|
||||
|
||||
while (strCnt < len) {
|
||||
if (number_of_padding_bit) {
|
||||
shift = (i+number_of_padding_bit-2)%7;
|
||||
shift = (i + number_of_padding_bit - 2) % 7;
|
||||
} else {
|
||||
shift = i%7;
|
||||
shift = i % 7;
|
||||
}
|
||||
|
||||
if (strCnt+1 == len) {
|
||||
tmp = (gsm_str[strCnt]>>shift);
|
||||
if (strCnt + 1 == len) {
|
||||
tmp = (gsm_str[strCnt] >> shift);
|
||||
} else {
|
||||
tmp = (gsm_str[strCnt]>>shift) | (gsm_str[strCnt+1] <<(7-shift));
|
||||
tmp = (gsm_str[strCnt] >> shift) | (gsm_str[strCnt + 1] << (7 - shift));
|
||||
}
|
||||
|
||||
char_str_to_hex_str(&tmp, 1, buf+(i*2));
|
||||
char_str_to_hex_str(&tmp, 1, buf + (i * 2));
|
||||
|
||||
if (shift == 6) {
|
||||
strCnt++;
|
||||
|
@ -1245,8 +1243,8 @@ uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, c
|
|||
return i;
|
||||
}
|
||||
|
||||
uint16_t AT_CellularSMS::unpack_7_bit_gsm_to_str(const char* str, int len, char *buf, int padding_bits,
|
||||
int msg_len)
|
||||
uint16_t AT_CellularSMS::unpack_7_bit_gsm_to_str(const char *str, int len, char *buf, int padding_bits,
|
||||
int msg_len)
|
||||
{
|
||||
int strCount = 0;
|
||||
uint16_t decodedCount = 0;
|
||||
|
@ -1256,27 +1254,27 @@ uint16_t AT_CellularSMS::pack_7_bit_gsm_and_hex(const char* str, uint16_t len, c
|
|||
|
||||
if (padding_bits) {
|
||||
hex_str_to_char_str(str, 2, &tmp);
|
||||
buf[decodedCount] = gsm_to_ascii[(tmp>>padding_bits) & 0x7F];
|
||||
buf[decodedCount] = gsm_to_ascii[(tmp >> padding_bits) & 0x7F];
|
||||
strCount++;
|
||||
decodedCount++;
|
||||
}
|
||||
|
||||
while (strCount < len) {
|
||||
shift = (strCount-padding_bits)%7;
|
||||
hex_str_to_char_str(str + strCount*2, 2, &tmp);
|
||||
shift = (strCount - padding_bits) % 7;
|
||||
hex_str_to_char_str(str + strCount * 2, 2, &tmp);
|
||||
if (shift == 0) {
|
||||
buf[decodedCount] = gsm_to_ascii[tmp & 0x7F];
|
||||
} else if (shift == 6) {
|
||||
hex_str_to_char_str(str + (strCount-1)*2, 2, &tmp1);
|
||||
buf[decodedCount] = gsm_to_ascii[(((tmp1>>2)) | (tmp << 6)) & 0x7F];
|
||||
if (decodedCount+1 < msg_len) {
|
||||
hex_str_to_char_str(str + strCount*2, 2, &tmp);
|
||||
hex_str_to_char_str(str + (strCount - 1) * 2, 2, &tmp1);
|
||||
buf[decodedCount] = gsm_to_ascii[(((tmp1 >> 2)) | (tmp << 6)) & 0x7F];
|
||||
if (decodedCount + 1 < msg_len) {
|
||||
hex_str_to_char_str(str + strCount * 2, 2, &tmp);
|
||||
decodedCount++;
|
||||
buf[decodedCount] = gsm_to_ascii[(tmp>>1) & 0x7F];
|
||||
buf[decodedCount] = gsm_to_ascii[(tmp >> 1) & 0x7F];
|
||||
}
|
||||
} else {
|
||||
hex_str_to_char_str(str + (strCount-1)*2, 2, &tmp1);
|
||||
buf[decodedCount] = gsm_to_ascii[(((tmp1>>(8- shift))) | ((tmp << shift))) & 0x7F];
|
||||
hex_str_to_char_str(str + (strCount - 1) * 2, 2, &tmp1);
|
||||
buf[decodedCount] = gsm_to_ascii[(((tmp1 >> (8 - shift))) | ((tmp << shift))) & 0x7F];
|
||||
}
|
||||
|
||||
strCount++;
|
||||
|
|
|
@ -30,8 +30,7 @@ namespace mbed {
|
|||
*
|
||||
* Class for SMS sending, reading and deleting.
|
||||
*/
|
||||
class AT_CellularSMS: public CellularSMS, public AT_CellularBase
|
||||
{
|
||||
class AT_CellularSMS: public CellularSMS, public AT_CellularBase {
|
||||
|
||||
public:
|
||||
AT_CellularSMS(ATHandler &atHandler);
|
||||
|
@ -42,10 +41,10 @@ public:
|
|||
|
||||
virtual nsapi_error_t initialize(CellularSMSMmode mode);
|
||||
|
||||
virtual nsapi_size_or_error_t send_sms(const char* phone_number, const char* message, int msg_len);
|
||||
virtual nsapi_size_or_error_t send_sms(const char *phone_number, const char *message, int msg_len);
|
||||
|
||||
virtual nsapi_size_or_error_t get_sms(char* buf, uint16_t buf_len, char* phone_num, uint16_t phone_len,
|
||||
char* time_stamp, uint16_t time_len, int *buf_size);
|
||||
virtual nsapi_size_or_error_t get_sms(char *buf, uint16_t buf_len, char *phone_num, uint16_t phone_len,
|
||||
char *time_stamp, uint16_t time_len, int *buf_size);
|
||||
|
||||
virtual void set_sms_callback(Callback<void()> func);
|
||||
|
||||
|
@ -69,7 +68,7 @@ private:
|
|||
uint8_t parts_added;
|
||||
uint16_t msg_ref_number;
|
||||
struct sms_info_t *next_info;
|
||||
sms_info_t() : msg_size(0), parts(1), parts_added(1), msg_ref_number(0), next_info(0){};
|
||||
sms_info_t() : msg_size(0), parts(1), parts_added(1), msg_ref_number(0), next_info(0) {};
|
||||
};
|
||||
|
||||
// application callback function for received sms
|
||||
|
@ -119,7 +118,7 @@ private:
|
|||
* @param sms struct containing index array to delete
|
||||
* @return zero for success
|
||||
*/
|
||||
nsapi_error_t delete_sms(sms_info_t* sms);
|
||||
nsapi_error_t delete_sms(sms_info_t *sms);
|
||||
|
||||
/**
|
||||
* Internal helper methods
|
||||
|
@ -127,19 +126,19 @@ private:
|
|||
nsapi_error_t list_messages();
|
||||
int read_sms_params(char *, char *);
|
||||
void free_linked_list();
|
||||
void add_info(sms_info_t* info, int index, int part_number);
|
||||
int read_udh_from_pdu(const char* pdu, sms_info_t *info, int &part_number, int &padding_bits);
|
||||
nsapi_size_or_error_t get_data_from_pdu(const char* pdu, sms_info_t *info, int *part_number,
|
||||
void add_info(sms_info_t *info, int index, int part_number);
|
||||
int read_udh_from_pdu(const char *pdu, sms_info_t *info, int &part_number, int &padding_bits);
|
||||
nsapi_size_or_error_t get_data_from_pdu(const char *pdu, sms_info_t *info, int *part_number,
|
||||
char *phone_number = NULL, char *msg = NULL);
|
||||
nsapi_size_or_error_t read_pdu_payload(const char* pdu, int msg_len, int scheme, char *msg, int padding_bits);
|
||||
sms_info_t* get_oldest_sms_index();
|
||||
bool create_time(const char* time_string, time_t* time);
|
||||
int compare_time_strings(const char* time_string_1, const char* time_string_2);
|
||||
char* create_pdu(const char* phone_number, const char* message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t& header_size);
|
||||
nsapi_size_or_error_t read_sms_from_index(int msg_index, char* buf, uint16_t len, char* phone_num,
|
||||
char* time_stamp);
|
||||
nsapi_size_or_error_t read_sms(sms_info_t* sms, char* buf, char* phone_num, char* time_stamp);
|
||||
nsapi_size_or_error_t read_pdu_payload(const char *pdu, int msg_len, int scheme, char *msg, int padding_bits);
|
||||
sms_info_t *get_oldest_sms_index();
|
||||
bool create_time(const char *time_string, time_t *time);
|
||||
int compare_time_strings(const char *time_string_1, const char *time_string_2);
|
||||
char *create_pdu(const char *phone_number, const char *message, uint8_t message_length, uint8_t msg_parts,
|
||||
uint8_t msg_part_number, uint8_t &header_size);
|
||||
nsapi_size_or_error_t read_sms_from_index(int msg_index, char *buf, uint16_t len, char *phone_num,
|
||||
char *time_stamp);
|
||||
nsapi_size_or_error_t read_sms(sms_info_t *sms, char *buf, char *phone_num, char *time_stamp);
|
||||
|
||||
/** Packs the given str from ascii to 7bit gsm format and converts it to hex to the given buf.
|
||||
*
|
||||
|
@ -149,7 +148,7 @@ private:
|
|||
* @param number_of_padding_bit padding bits needed to keep the octet boundary
|
||||
* @return length of buffer buf or zero on failure
|
||||
*/
|
||||
uint16_t pack_7_bit_gsm_and_hex(const char* str, uint16_t len, char *buf, int number_of_padding_bit);
|
||||
uint16_t pack_7_bit_gsm_and_hex(const char *str, uint16_t len, char *buf, int number_of_padding_bit);
|
||||
|
||||
/** Unpacks the given hex- and 7-bit gsm encoded str to ascii string
|
||||
*
|
||||
|
@ -161,8 +160,8 @@ private:
|
|||
* @return length of the destination buffer buf
|
||||
*
|
||||
*/
|
||||
uint16_t unpack_7_bit_gsm_to_str(const char* str, int len, char *buf, int padding_bits,
|
||||
int msg_len);
|
||||
uint16_t unpack_7_bit_gsm_to_str(const char *str, int len, char *buf, int padding_bits,
|
||||
int msg_len);
|
||||
};
|
||||
|
||||
} // namespace mbed
|
||||
|
|
|
@ -22,9 +22,9 @@
|
|||
using namespace mbed_cellular_util;
|
||||
using namespace mbed;
|
||||
|
||||
AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type) : AT_CellularBase(at), _socket(NULL),_socket_count(0),_cid(cid), _stack_type(stack_type)
|
||||
AT_CellularStack::AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type) : AT_CellularBase(at), _socket(NULL), _socket_count(0), _cid(cid), _stack_type(stack_type)
|
||||
{
|
||||
memset(_ip,0, PDP_IPV6_SIZE);
|
||||
memset(_ip, 0, PDP_IPV6_SIZE);
|
||||
}
|
||||
|
||||
AT_CellularStack::~AT_CellularStack()
|
||||
|
@ -44,7 +44,7 @@ AT_CellularStack::~AT_CellularStack()
|
|||
/** NetworkStack
|
||||
*/
|
||||
|
||||
const char * AT_CellularStack::get_ip_address()
|
||||
const char *AT_CellularStack::get_ip_address()
|
||||
{
|
||||
_at.lock();
|
||||
|
||||
|
@ -58,7 +58,7 @@ const char * AT_CellularStack::get_ip_address()
|
|||
|
||||
_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();
|
||||
|
@ -68,7 +68,7 @@ const char * 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) {
|
||||
(void)_at.read_string(_ip, PDP_IPV6_SIZE-1);
|
||||
(void)_at.read_string(_ip, PDP_IPV6_SIZE - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ nsapi_error_t AT_CellularStack::socket_close(nsapi_socket_t handle)
|
|||
int err = NSAPI_ERROR_DEVICE_ERROR;
|
||||
|
||||
struct CellularSocket *socket = (struct CellularSocket *)handle;
|
||||
if (!socket){
|
||||
if (!socket) {
|
||||
return err;
|
||||
}
|
||||
int sock_id = socket->id;
|
||||
|
@ -265,7 +265,7 @@ nsapi_size_or_error_t AT_CellularStack::socket_sendto(nsapi_socket_t handle, con
|
|||
_at.lock();
|
||||
|
||||
ret_val = socket_sendto_impl(socket, addr, data, size);
|
||||
|
||||
|
||||
if (ret_val <= 0) {
|
||||
tr_error("Error sending to: %s error code: %d", addr.get_ip_address(), ret_val);
|
||||
} else {
|
||||
|
|
|
@ -34,8 +34,7 @@ namespace mbed {
|
|||
*
|
||||
* Implements NetworkStack and introduces interface for modem specific stack implementations.
|
||||
*/
|
||||
class AT_CellularStack : public NetworkStack, public AT_CellularBase
|
||||
{
|
||||
class AT_CellularStack : public NetworkStack, public AT_CellularBase {
|
||||
|
||||
public:
|
||||
AT_CellularStack(ATHandler &at, int cid, nsapi_ip_stack_t stack_type);
|
||||
|
@ -64,26 +63,25 @@ protected: // NetworkStack
|
|||
virtual nsapi_error_t socket_connect(nsapi_socket_t handle, const SocketAddress &address);
|
||||
|
||||
virtual nsapi_error_t socket_accept(nsapi_socket_t server,
|
||||
nsapi_socket_t *handle, SocketAddress *address=0);
|
||||
nsapi_socket_t *handle, SocketAddress *address = 0);
|
||||
|
||||
virtual nsapi_size_or_error_t socket_send(nsapi_socket_t handle,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
virtual nsapi_size_or_error_t socket_recv(nsapi_socket_t handle,
|
||||
void *data, nsapi_size_t size);
|
||||
void *data, 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);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
virtual nsapi_size_or_error_t socket_recvfrom(nsapi_socket_t handle, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size);
|
||||
void *buffer, nsapi_size_t size);
|
||||
|
||||
virtual void socket_attach(nsapi_socket_t handle, void (*callback)(void *), void *data);
|
||||
|
||||
protected:
|
||||
|
||||
class CellularSocket
|
||||
{
|
||||
class CellularSocket {
|
||||
public:
|
||||
// Socket id from cellular device
|
||||
int id;
|
||||
|
@ -137,7 +135,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
const void *data, nsapi_size_t size) = 0;
|
||||
|
||||
/**
|
||||
* Implements modem specific AT command set for receiving data
|
||||
|
@ -150,7 +148,7 @@ protected:
|
|||
* code on failure
|
||||
*/
|
||||
virtual nsapi_size_or_error_t socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size) = 0;
|
||||
void *buffer, nsapi_size_t size) = 0;
|
||||
|
||||
// socket container
|
||||
CellularSocket **_socket;
|
||||
|
|
|
@ -27,18 +27,17 @@ namespace mbed {
|
|||
* Templated linked list class for common usage.
|
||||
*
|
||||
*/
|
||||
template <class T> class CellularList
|
||||
{
|
||||
template <class T> class CellularList {
|
||||
private:
|
||||
T *_head, *_tail;
|
||||
public:
|
||||
CellularList()
|
||||
{
|
||||
_head=NULL;
|
||||
_tail=NULL;
|
||||
_head = NULL;
|
||||
_tail = NULL;
|
||||
}
|
||||
|
||||
~CellularList()
|
||||
~CellularList()
|
||||
{
|
||||
T *temp = _head;
|
||||
while (temp) {
|
||||
|
@ -48,40 +47,40 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
T* add_new()
|
||||
T *add_new()
|
||||
{
|
||||
T *temp=new T;
|
||||
if (!temp) {
|
||||
return NULL;
|
||||
}
|
||||
temp->next = NULL;
|
||||
if (_head == NULL) {
|
||||
_head = temp;
|
||||
} else {
|
||||
_tail->next=temp;
|
||||
}
|
||||
_tail = temp;
|
||||
T *temp = new T;
|
||||
if (!temp) {
|
||||
return NULL;
|
||||
}
|
||||
temp->next = NULL;
|
||||
if (_head == NULL) {
|
||||
_head = temp;
|
||||
} else {
|
||||
_tail->next = temp;
|
||||
}
|
||||
_tail = temp;
|
||||
|
||||
return _tail;
|
||||
return _tail;
|
||||
}
|
||||
|
||||
void delete_last()
|
||||
{
|
||||
T* previous = NULL;
|
||||
T *current=_head;
|
||||
T *previous = NULL;
|
||||
T *current = _head;
|
||||
|
||||
if (!current) {
|
||||
return;
|
||||
}
|
||||
|
||||
while (current->next != NULL) {
|
||||
previous=current;
|
||||
current=current->next;
|
||||
previous = current;
|
||||
current = current->next;
|
||||
}
|
||||
|
||||
if (previous) {
|
||||
_tail=previous;
|
||||
previous->next=NULL;
|
||||
_tail = previous;
|
||||
previous->next = NULL;
|
||||
} else {
|
||||
_head = NULL;
|
||||
_tail = NULL;
|
||||
|
@ -98,7 +97,7 @@ public:
|
|||
delete temp;
|
||||
temp = _head;
|
||||
}
|
||||
_tail=NULL;
|
||||
_tail = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace mbed_cellular_util {
|
||||
|
||||
void convert_ipv6(char* ip)
|
||||
void convert_ipv6(char *ip)
|
||||
{
|
||||
if (!ip) {
|
||||
return;
|
||||
|
@ -56,21 +56,21 @@ void convert_ipv6(char* ip)
|
|||
bool set_colon = false;
|
||||
for (i = 0; i < len; i++) {
|
||||
if (ip[i] == '.') {
|
||||
b = (char)strtol (ip+ip_pos, NULL, 10); // convert to char to int so we can change it to hex string
|
||||
pos += char_str_to_hex_str(&b, 1, ip+pos, !set_colon); // omit leading zeroes with using set_colon flag
|
||||
b = (char)strtol(ip + ip_pos, NULL, 10); // convert to char to int so we can change it to hex string
|
||||
pos += char_str_to_hex_str(&b, 1, ip + pos, !set_colon); // omit leading zeroes with using set_colon flag
|
||||
if (set_colon) {
|
||||
ip[pos++] = ':';
|
||||
set_colon = false;
|
||||
} else {
|
||||
set_colon = true;
|
||||
}
|
||||
ip_pos = i+1; // skip the '.'
|
||||
ip_pos = i + 1; // skip the '.'
|
||||
}
|
||||
|
||||
// handle the last part which does not end with '.' but '\0'
|
||||
if (i == len -1) {
|
||||
b = (char)strtol(ip+ip_pos, NULL, 10);
|
||||
pos += char_str_to_hex_str(&b, 1, ip+pos, !set_colon);
|
||||
if (i == len - 1) {
|
||||
b = (char)strtol(ip + ip_pos, NULL, 10);
|
||||
pos += char_str_to_hex_str(&b, 1, ip + pos, !set_colon);
|
||||
ip[pos] = '\0';
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void convert_ipv6(char* ip)
|
|||
}
|
||||
|
||||
// For example "32.1.13.184.0.0.205.48.0.0.0.0.0.0.0.0"
|
||||
void separate_ip4like_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void separate_ip4like_addresses(char *orig, char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
// ipv4-like notation
|
||||
int len = strlen(orig);
|
||||
|
@ -108,9 +108,9 @@ void separate_ip4like_addresses(char* orig, char* ip, size_t ip_size, char* ip2,
|
|||
}
|
||||
} else if (count == 7) { // ipv4 and subnet mask. Need to separate those.
|
||||
temp = &orig[pos];
|
||||
if ((uint8_t)ip_size > temp-orig) {
|
||||
memcpy(ip, orig, temp-orig);
|
||||
ip[temp-orig] = '\0';
|
||||
if ((uint8_t)ip_size > temp - orig) {
|
||||
memcpy(ip, orig, temp - orig);
|
||||
ip[temp - orig] = '\0';
|
||||
}
|
||||
temp++; // skip the '.'
|
||||
if (ip2 && (ip2_size > strlen(temp))) {
|
||||
|
@ -128,11 +128,11 @@ void separate_ip4like_addresses(char* orig, char* ip, size_t ip_size, char* ip2,
|
|||
if (ip2) {
|
||||
ip2[0] = '\0';
|
||||
}
|
||||
} else if (count == 31){ // ipv6 + ipv6subnet mask in ipv4-like notation separated by dot '.'
|
||||
} else if (count == 31) { // ipv6 + ipv6subnet mask in ipv4-like notation separated by dot '.'
|
||||
temp = &orig[pos];
|
||||
if ((uint8_t)ip_size > temp-orig) {
|
||||
memcpy(ip, orig, temp-orig);
|
||||
ip[temp-orig] = '\0';
|
||||
if ((uint8_t)ip_size > temp - orig) {
|
||||
memcpy(ip, orig, temp - orig);
|
||||
ip[temp - orig] = '\0';
|
||||
convert_ipv6(ip);
|
||||
}
|
||||
temp++; // skip the '.'
|
||||
|
@ -144,7 +144,7 @@ void separate_ip4like_addresses(char* orig, char* ip, size_t ip_size, char* ip2,
|
|||
}
|
||||
}
|
||||
|
||||
void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void separate_ip_addresses(char *orig, char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
// orig can include ipv4, ipv6, both or two ip4/ipv6 addresses.
|
||||
// also format depends on possible AT+CGPIAF
|
||||
|
@ -166,9 +166,9 @@ void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size
|
|||
temp = strstr(orig, " ");
|
||||
// found space as separator and it wasn't in beginning --> contains 2 ip addresses
|
||||
if (temp && temp != orig) {
|
||||
if ((uint8_t)ip_size > temp-orig) {
|
||||
memcpy(ip, orig, temp-orig);
|
||||
ip[temp-orig] = '\0';
|
||||
if ((uint8_t)ip_size > temp - orig) {
|
||||
memcpy(ip, orig, temp - orig);
|
||||
ip[temp - orig] = '\0';
|
||||
} else {
|
||||
ip[0] = '\0';
|
||||
}
|
||||
|
@ -201,17 +201,16 @@ void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size
|
|||
// found space as separator and it wasn't in beginning --> contains 2 ip addresses
|
||||
if (temp && temp != orig) {
|
||||
separate_ip4like_addresses(temp++, ip2, ip2_size, NULL, 0);
|
||||
orig[temp-orig-1] = '\0';
|
||||
orig[temp - orig - 1] = '\0';
|
||||
separate_ip4like_addresses(orig, ip, ip_size, NULL, 0);
|
||||
orig[temp-orig-1] = ' '; // put space back to keep orig as original
|
||||
}
|
||||
else {
|
||||
orig[temp - orig - 1] = ' '; // put space back to keep orig as original
|
||||
} else {
|
||||
separate_ip4like_addresses(orig, ip, ip_size, ip2, ip2_size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void prefer_ipv6(char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
||||
void prefer_ipv6(char *ip, size_t ip_size, char *ip2, size_t ip2_size)
|
||||
{
|
||||
if (!ip || !ip2) {
|
||||
return;
|
||||
|
@ -242,7 +241,7 @@ void prefer_ipv6(char* ip, size_t ip_size, char* ip2, size_t ip2_size)
|
|||
}
|
||||
}
|
||||
|
||||
void int_to_hex_str(uint8_t num, char* buf)
|
||||
void int_to_hex_str(uint8_t num, char *buf)
|
||||
{
|
||||
char charNum = num;
|
||||
char_str_to_hex_str(&charNum, 1, buf);
|
||||
|
@ -253,7 +252,7 @@ int hex_str_to_int(const char *hex_string, int hex_string_length)
|
|||
const int base = 16;
|
||||
int character_as_integer, integer_output = 0;
|
||||
|
||||
for (int i=0;i<hex_string_length && hex_string[i] != '\0';i++) {
|
||||
for (int i = 0; i < hex_string_length && hex_string[i] != '\0'; i++) {
|
||||
if (hex_string[i] >= '0' && hex_string[i] <= '9') {
|
||||
character_as_integer = hex_string[i] - '0';
|
||||
} else if (hex_string[i] >= 'A' && hex_string[i] <= 'F') {
|
||||
|
@ -268,20 +267,20 @@ int hex_str_to_int(const char *hex_string, int hex_string_length)
|
|||
return integer_output;
|
||||
}
|
||||
|
||||
int hex_str_to_char_str(const char* str, uint16_t len, char *buf)
|
||||
int hex_str_to_char_str(const char *str, uint16_t len, char *buf)
|
||||
{
|
||||
int strcount = 0;
|
||||
for (int i = 0; i+1 < len; i += 2) {
|
||||
int upper = hex_str_to_int(str+i, 1);
|
||||
int lower = hex_str_to_int(str+i+1, 1);
|
||||
buf[strcount] = ((upper<<4) & 0xF0) | (lower & 0x0F);
|
||||
for (int i = 0; i + 1 < len; i += 2) {
|
||||
int upper = hex_str_to_int(str + i, 1);
|
||||
int lower = hex_str_to_int(str + i + 1, 1);
|
||||
buf[strcount] = ((upper << 4) & 0xF0) | (lower & 0x0F);
|
||||
strcount++;
|
||||
}
|
||||
|
||||
return strcount;
|
||||
}
|
||||
|
||||
void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt)
|
||||
void uint_to_binary_str(uint32_t num, char *str, int str_size, int bit_cnt)
|
||||
{
|
||||
if (!str || str_size < bit_cnt) {
|
||||
return;
|
||||
|
@ -291,7 +290,7 @@ void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt)
|
|||
for (int i = 31; i >= 0; i--) {
|
||||
tmp = num >> i;
|
||||
if (i < bit_cnt) {
|
||||
if (tmp&1) {
|
||||
if (tmp & 1) {
|
||||
str[pos] = 1 + '0';
|
||||
} else {
|
||||
str[pos] = 0 + '0';
|
||||
|
@ -301,24 +300,24 @@ void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt)
|
|||
}
|
||||
}
|
||||
|
||||
int char_str_to_hex_str(const char* str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
int char_str_to_hex_str(const char *str, uint16_t len, char *buf, bool omit_leading_zero)
|
||||
{
|
||||
if (!str || !buf) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char *ptr = buf;
|
||||
int i=0;
|
||||
int i = 0;
|
||||
while (i < len) {
|
||||
if (omit_leading_zero == true && i == 0 && !(str[i]>>4 & 0x0F)) {
|
||||
if (omit_leading_zero == true && i == 0 && !(str[i] >> 4 & 0x0F)) {
|
||||
*ptr++ = hex_values[(str[i]) & 0x0F];
|
||||
} else {
|
||||
*ptr++ = hex_values[((str[i])>>4) & 0x0F];
|
||||
*ptr++ = hex_values[((str[i]) >> 4) & 0x0F];
|
||||
*ptr++ = hex_values[(str[i]) & 0x0F];
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return ptr-buf;
|
||||
return ptr - buf;
|
||||
}
|
||||
|
||||
uint16_t get_dynamic_ip_port()
|
||||
|
|
|
@ -38,7 +38,7 @@ static const char hex_values[] = "0123456789ABCDEF";
|
|||
*
|
||||
* @param ip IP address that can be IPv4 or IPv6 in different formats from AT command +CGPADDR. Converted result uses same buffer.
|
||||
*/
|
||||
void convert_ipv6(char* ip);
|
||||
void convert_ipv6(char *ip);
|
||||
|
||||
/** Separates IP addresses from the given 'orig' string. 'orig' may contain zero, one or two IP addresses in various formats.
|
||||
* See AT command +CGPIAF from 3GPP TS 27.007 for details. Does also needed conversions for IPv6 addresses.
|
||||
|
@ -50,7 +50,7 @@ void convert_ipv6(char* ip);
|
|||
* @param ip2_size size of preallocated buffer ip2
|
||||
*
|
||||
*/
|
||||
void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size_t ip2_size);
|
||||
void separate_ip_addresses(char *orig, char *ip, size_t ip_size, char *ip2, size_t ip2_size);
|
||||
|
||||
/** Swaps the arrays if param IP does not contain IPv6 address but param ip2 does.
|
||||
*
|
||||
|
@ -59,14 +59,14 @@ void separate_ip_addresses(char* orig, char* ip, size_t ip_size, char* ip2, size
|
|||
* @param ip2 IP address
|
||||
* @param ip2_size size of buffer ip2
|
||||
*/
|
||||
void prefer_ipv6(char* ip, size_t ip_size, char* ip2, size_t ip2_size);
|
||||
void prefer_ipv6(char *ip, size_t ip_size, char *ip2, size_t ip2_size);
|
||||
|
||||
/** Converts the given int to two hex characters
|
||||
*
|
||||
* @param num number to be converted to hex string
|
||||
* @param buf preallocated buffer that will contain 2 char length hex value
|
||||
*/
|
||||
void int_to_hex_str(uint8_t num, char* buf);
|
||||
void int_to_hex_str(uint8_t num, char *buf);
|
||||
|
||||
/** Converts the given buffer 'str' to hex buffer 'buf. First 'len' char's are converted to two hex bytes.
|
||||
*
|
||||
|
@ -75,7 +75,7 @@ void int_to_hex_str(uint8_t num, char* buf);
|
|||
* @param buf destination buffer for hex converted chars. Buffer should be double the size of str to fit hex-encoded string.
|
||||
* @param omit_leading_zero if true then possible leading zeroes are omitted
|
||||
*/
|
||||
int char_str_to_hex_str(const char* str, uint16_t len, char *buf, bool omit_leading_zero = false);
|
||||
int char_str_to_hex_str(const char *str, uint16_t len, char *buf, bool omit_leading_zero = false);
|
||||
|
||||
/** Converts the given hex string to integer
|
||||
*
|
||||
|
@ -92,7 +92,7 @@ int hex_str_to_int(const char *hex_string, int hex_string_length);
|
|||
* @param buf preallocated buffer where result conversion is stored
|
||||
* @return length of the buf
|
||||
*/
|
||||
int hex_str_to_char_str(const char* str, uint16_t len, char *buf);
|
||||
int hex_str_to_char_str(const char *str, uint16_t len, char *buf);
|
||||
|
||||
/** Converts the given uint to binary string. Fills the given str starting from [0] with the number of bits defined by bit_cnt
|
||||
* For example uint_to_binary_string(9, str, 10) would fill str "0000001001"
|
||||
|
@ -103,7 +103,7 @@ int hex_str_to_char_str(const char* str, uint16_t len, char *buf);
|
|||
* @param str_size size of the str buffer
|
||||
* @param bit_cnt defines how many bits are filled to buffer started from lsb
|
||||
*/
|
||||
void uint_to_binary_str(uint32_t num, char* str, int str_size, int bit_cnt);
|
||||
void uint_to_binary_str(uint32_t num, char *str, int str_size, int bit_cnt);
|
||||
|
||||
/** Get dynamic port for socket
|
||||
*
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95 : public AT_CellularDevice
|
||||
{
|
||||
class QUECTEL_BC95 : public AT_CellularDevice {
|
||||
public:
|
||||
|
||||
QUECTEL_BC95(events::EventQueue &queue);
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95_CellularNetwork : public AT_CellularNetwork
|
||||
{
|
||||
class QUECTEL_BC95_CellularNetwork : public AT_CellularNetwork {
|
||||
public:
|
||||
QUECTEL_BC95_CellularNetwork(ATHandler &atHandler);
|
||||
virtual ~QUECTEL_BC95_CellularNetwork();
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95_CellularPower : public AT_CellularPower
|
||||
{
|
||||
class QUECTEL_BC95_CellularPower : public AT_CellularPower {
|
||||
public:
|
||||
QUECTEL_BC95_CellularPower(ATHandler &atHandler);
|
||||
virtual ~QUECTEL_BC95_CellularPower();
|
||||
|
|
|
@ -43,7 +43,7 @@ nsapi_error_t QUECTEL_BC95_CellularStack::socket_accept(void *server, void **soc
|
|||
|
||||
void QUECTEL_BC95_CellularStack::urc_nsonmi()
|
||||
{
|
||||
int sock_id =_at.read_int();
|
||||
int sock_id = _at.read_int();
|
||||
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
CellularSocket *sock = _socket[i];
|
||||
|
@ -137,12 +137,12 @@ nsapi_error_t QUECTEL_BC95_CellularStack::create_socket_impl(CellularSocket *soc
|
|||
}
|
||||
|
||||
nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size)
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
int sent_len = 0;
|
||||
|
||||
char *hexstr = new char[size*2+1];
|
||||
int hexlen = char_str_to_hex_str((const char*)data, size, hexstr);
|
||||
char *hexstr = new char[size * 2 + 1];
|
||||
int hexlen = char_str_to_hex_str((const char *)data, size, hexstr);
|
||||
// NULL terminated for write_string
|
||||
hexstr[hexlen] = 0;
|
||||
_at.cmd_start("AT+NSOST=");
|
||||
|
@ -168,9 +168,9 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
|
|||
}
|
||||
|
||||
nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size)
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
nsapi_size_or_error_t recv_len=0;
|
||||
nsapi_size_or_error_t recv_len = 0;
|
||||
int port;
|
||||
char ip_address[NSAPI_IP_SIZE];
|
||||
|
||||
|
@ -184,7 +184,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
|
|||
_at.read_string(ip_address, sizeof(ip_address));
|
||||
port = _at.read_int();
|
||||
recv_len = _at.read_int();
|
||||
int hexlen = _at.read_hex_string((char*)buffer, size);
|
||||
int hexlen = _at.read_hex_string((char *)buffer, size);
|
||||
// remaining length
|
||||
_at.skip_param();
|
||||
_at.resp_stop();
|
||||
|
|
|
@ -24,8 +24,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BC95_CellularStack : public AT_CellularStack
|
||||
{
|
||||
class QUECTEL_BC95_CellularStack : public AT_CellularStack {
|
||||
public:
|
||||
QUECTEL_BC95_CellularStack(ATHandler &atHandler, int cid, nsapi_ip_stack_t stack_type);
|
||||
virtual ~QUECTEL_BC95_CellularStack();
|
||||
|
@ -35,7 +34,7 @@ protected: // NetworkStack
|
|||
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
|
||||
|
||||
|
@ -48,10 +47,10 @@ protected: // AT_CellularStack
|
|||
virtual nsapi_error_t create_socket_impl(CellularSocket *socket);
|
||||
|
||||
virtual nsapi_size_or_error_t socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size);
|
||||
const void *data, nsapi_size_t size);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
// URC handlers
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
|
||||
#include "AT_CellularDevice.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BG96 : public AT_CellularDevice
|
||||
{
|
||||
class QUECTEL_BG96 : public AT_CellularDevice {
|
||||
public:
|
||||
|
||||
QUECTEL_BG96(events::EventQueue &queue);
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BG96_CellularNetwork : public AT_CellularNetwork
|
||||
{
|
||||
class QUECTEL_BG96_CellularNetwork : public AT_CellularNetwork {
|
||||
public:
|
||||
QUECTEL_BG96_CellularNetwork(ATHandler &atHandler);
|
||||
virtual ~QUECTEL_BG96_CellularNetwork();
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
|
||||
#include "AT_CellularPower.h"
|
||||
|
||||
namespace mbed
|
||||
{
|
||||
namespace mbed {
|
||||
|
||||
class QUECTEL_BG96_CellularPower : public AT_CellularPower
|
||||
{
|
||||
class QUECTEL_BG96_CellularPower : public AT_CellularPower {
|
||||
public:
|
||||
QUECTEL_BG96_CellularPower(ATHandler &atHandler);
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ nsapi_error_t QUECTEL_BG96_CellularStack::socket_accept(void *server, void **soc
|
|||
|
||||
void QUECTEL_BG96_CellularStack::urc_qiurc()
|
||||
{
|
||||
int sock_id=0;
|
||||
int sock_id = 0;
|
||||
|
||||
_at.lock();
|
||||
(void) _at.skip_param();
|
||||
sock_id = _at.read_int();
|
||||
sock_id = _at.read_int();
|
||||
_at.unlock();
|
||||
|
||||
for (int i = 0; i < get_max_socket_count(); i++) {
|
||||
|
@ -178,7 +178,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc
|
|||
}
|
||||
|
||||
nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSocket *socket, const SocketAddress &address,
|
||||
const void *data, nsapi_size_t size)
|
||||
const void *data, nsapi_size_t size)
|
||||
{
|
||||
int sent_len = 0;
|
||||
int sent_len_before = 0;
|
||||
|
@ -203,7 +203,7 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
|
|||
_at.cmd_stop();
|
||||
|
||||
_at.resp_start(">");
|
||||
_at.write_bytes((uint8_t*)data, size);
|
||||
_at.write_bytes((uint8_t *)data, size);
|
||||
_at.resp_start();
|
||||
_at.set_stop_tag("\r\n");
|
||||
_at.resp_stop();
|
||||
|
@ -227,9 +227,9 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc
|
|||
}
|
||||
|
||||
nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_recvfrom_impl(CellularSocket *socket, SocketAddress *address,
|
||||
void *buffer, nsapi_size_t size)
|
||||
void *buffer, nsapi_size_t size)
|
||||
{
|
||||
nsapi_size_or_error_t recv_len=0;
|
||||
nsapi_size_or_error_t recv_len = 0;
|
||||
int port;
|
||||
char ip_address[NSAPI_IP_SIZE + 1];
|
||||
|
||||
|
@ -242,7 +242,7 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_recvfrom_impl(CellularS
|
|||
_at.read_string(ip_address, sizeof(ip_address));
|
||||
port = _at.read_int();
|
||||
if (recv_len > 0) {
|
||||
_at.read_bytes((uint8_t*)buffer, recv_len);
|
||||
_at.read_bytes((uint8_t *)buffer, recv_len);
|
||||
}
|
||||
_at.resp_stop();
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue