mirror of https://github.com/ARMmbed/mbed-os.git
Picked Ari's changed to reduce stack size. Removed device info printing from state machine.
parent
d1f2e91e93
commit
231458dc36
|
|
@ -181,22 +181,6 @@ bool CellularConnectionFSM::open_sim()
|
|||
return state == CellularSIM::SimStateReady;
|
||||
}
|
||||
|
||||
void CellularConnectionFSM::print_device_info()
|
||||
{
|
||||
CellularInformation *info = _cellularDevice->open_information(_serial);
|
||||
char device_info_buf[2048]; // may be up to 2048 according to 3GPP
|
||||
|
||||
if (info->get_manufacturer(device_info_buf, sizeof(device_info_buf)) == NSAPI_ERROR_OK) {
|
||||
tr_info("Cellular device manufacturer: %s", device_info_buf);
|
||||
}
|
||||
if (info->get_model(device_info_buf, sizeof(device_info_buf)) == NSAPI_ERROR_OK) {
|
||||
tr_info("Cellular device model: %s", device_info_buf);
|
||||
}
|
||||
if (info->get_revision(device_info_buf, sizeof(device_info_buf)) == NSAPI_ERROR_OK) {
|
||||
tr_info("Cellular device revision: %s", device_info_buf);
|
||||
}
|
||||
}
|
||||
|
||||
bool CellularConnectionFSM::set_network_registration(char *plmn)
|
||||
{
|
||||
if (_network->set_registration(plmn) != NSAPI_ERROR_OK) {
|
||||
|
|
@ -401,7 +385,6 @@ void CellularConnectionFSM::state_device_ready()
|
|||
return;
|
||||
}
|
||||
|
||||
print_device_info();
|
||||
enter_to_state(STATE_SIM_PIN);
|
||||
} else {
|
||||
retry_state_or_fail();
|
||||
|
|
@ -532,7 +515,7 @@ nsapi_error_t CellularConnectionFSM::start_dispatch()
|
|||
{
|
||||
MBED_ASSERT(!_queue_thread);
|
||||
|
||||
_queue_thread = new rtos::Thread;
|
||||
_queue_thread = new rtos::Thread(osPriorityNormal, 1024);
|
||||
if (!_queue_thread) {
|
||||
stop();
|
||||
return NSAPI_ERROR_NO_MEMORY;
|
||||
|
|
@ -573,15 +556,7 @@ void CellularConnectionFSM::network_callback(nsapi_event_t ev, intptr_t ptr)
|
|||
continue_from_state(STATE_ATTACHING_NETWORK);
|
||||
}
|
||||
}
|
||||
} /*else if (ev == NSAPI_EVENT_CONNECTION_STATUS_CHANGE) {
|
||||
if (ptr == NSAPI_STATUS_GLOBAL_UP) {
|
||||
// we are connected
|
||||
if (_state == STATE_CONNECTING_NETWORK) {
|
||||
_queue.cancel(_eventID);
|
||||
continue_from_state(STATE_CONNECTED);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
if (_event_status_cb) {
|
||||
_event_status_cb(ev, ptr);
|
||||
|
|
|
|||
|
|
@ -169,7 +169,6 @@ private:
|
|||
NetworkStack *get_stack();
|
||||
|
||||
private:
|
||||
void print_device_info();
|
||||
void report_failure(const char* msg);
|
||||
void event();
|
||||
|
||||
|
|
|
|||
|
|
@ -275,8 +275,8 @@ nsapi_error_t AT_CellularNetwork::open_data_channel()
|
|||
tr_warn("Failed to CONNECT");
|
||||
}
|
||||
/* Initialize PPP
|
||||
* mbed_ppp_init() is a blocking call, it will block until
|
||||
* connected, or timeout after 30 seconds*/
|
||||
* If blocking: mbed_ppp_init() is a blocking call, it will block until
|
||||
connected, or timeout after 30 seconds*/
|
||||
err = nsapi_ppp_connect(_at.get_file_handle(), callback(this, &AT_CellularNetwork::ppp_status_cb), _uname, _pwd, _ip_stack_type);
|
||||
#else
|
||||
// do check for stack to validate that we have support for stack
|
||||
|
|
|
|||
|
|
@ -139,15 +139,15 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
|
|||
{
|
||||
int sent_len = 0;
|
||||
|
||||
char hexstr[BC95_MAX_PACKET_SIZE*2 + 1] = {0};
|
||||
char_str_to_hex_str((const char*)data, size, hexstr);
|
||||
char *hexstr = new char[BC95_MAX_PACKET_SIZE*2];
|
||||
int hexlen = char_str_to_hex_str((const char*)data, size, hexstr);
|
||||
|
||||
_at.cmd_start("AT+NSOST=");
|
||||
_at.write_int(socket->id);
|
||||
_at.write_string(address.get_ip_address(), false);
|
||||
_at.write_int(address.get_port());
|
||||
_at.write_int(size);
|
||||
_at.write_string(hexstr, false);
|
||||
_at.write_bytes((uint8_t*)hexstr, hexlen);
|
||||
_at.cmd_stop();
|
||||
_at.resp_start();
|
||||
// skip socket id
|
||||
|
|
@ -155,6 +155,8 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_sendto_impl(CellularSoc
|
|||
sent_len = _at.read_int();
|
||||
_at.resp_stop();
|
||||
|
||||
delete hexstr;
|
||||
|
||||
if (_at.get_last_error() == NSAPI_ERROR_OK) {
|
||||
return sent_len;
|
||||
}
|
||||
|
|
@ -168,7 +170,7 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
|
|||
nsapi_size_or_error_t recv_len=0;
|
||||
int port;
|
||||
char ip_address[NSAPI_IP_SIZE];
|
||||
char hexstr[BC95_MAX_PACKET_SIZE*2 + 1];
|
||||
char *hexstr = new char[BC95_MAX_PACKET_SIZE*2+1];
|
||||
|
||||
_at.cmd_start("AT+NSORF=");
|
||||
_at.write_int(socket->id);
|
||||
|
|
@ -180,12 +182,13 @@ 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();
|
||||
_at.read_string(hexstr, sizeof(hexstr));
|
||||
int hexlen = _at.read_string(hexstr, BC95_MAX_PACKET_SIZE*2+1);
|
||||
// remaining length
|
||||
_at.skip_param();
|
||||
_at.resp_stop();
|
||||
|
||||
if (!recv_len || (recv_len == -1) || (_at.get_last_error() != NSAPI_ERROR_OK)) {
|
||||
delete hexstr;
|
||||
return NSAPI_ERROR_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
|
|
@ -194,9 +197,10 @@ nsapi_size_or_error_t QUECTEL_BC95_CellularStack::socket_recvfrom_impl(CellularS
|
|||
address->set_port(port);
|
||||
}
|
||||
|
||||
if (recv_len > 0) {
|
||||
hex_str_to_char_str((const char*) hexstr, recv_len*2, (char*)buffer);
|
||||
if (hexlen > 0) {
|
||||
hex_str_to_char_str((const char*) hexstr, hexlen, (char*)buffer);
|
||||
}
|
||||
|
||||
delete hexstr;
|
||||
return recv_len;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue