diff --git a/UNITTESTS/stubs/ATHandler_stub.cpp b/UNITTESTS/stubs/ATHandler_stub.cpp index 1b1aebfe67..f64a55ca4a 100644 --- a/UNITTESTS/stubs/ATHandler_stub.cpp +++ b/UNITTESTS/stubs/ATHandler_stub.cpp @@ -431,23 +431,26 @@ void ATHandler::flush() } -nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char* cmd_chr, char *resp_buf, size_t buf_size, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *resp_buf, + size_t buf_size, const char *format, ...) { read_string(resp_buf, buf_size); return ATHandler_stub::nsapi_error_value; } -nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char* cmd_chr, int &resp, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char *cmd_chr, int &resp, + const char *format, ...) { resp = read_int(); return ATHandler_stub::nsapi_error_value; } -void ATHandler::cmd_start_stop(const char *cmd, const char* cmd_chr, const char* format, ...) +void ATHandler::cmd_start_stop(const char *cmd, const char *cmd_chr, const char *format, ...) { } -nsapi_error_t ATHandler::at_cmd_discard(const char *cmd, const char* cmd_chr, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_discard(const char *cmd, const char *cmd_chr, + const char *format, ...) { return ATHandler_stub::nsapi_error_value; } diff --git a/features/cellular/framework/AT/ATHandler.cpp b/features/cellular/framework/AT/ATHandler.cpp index 30792197bf..98421a8f37 100644 --- a/features/cellular/framework/AT/ATHandler.cpp +++ b/features/cellular/framework/AT/ATHandler.cpp @@ -1142,17 +1142,17 @@ void ATHandler::cmd_start(const char *cmd) _cmd_start = true; } -void ATHandler::handle_args(const char* format, va_list list) +void ATHandler::handle_args(const char *format, va_list list) { while (*format != '\0') { if (*format == 'd') { int i = va_arg(list, int); write_int(i); } else if (*format == 's') { - char * str = (char *)va_arg(list, char*); + char *str = (char *)va_arg(list, char *); write_string(str); } else if (*format == 'b') { - uint8_t *bytes = va_arg(list, uint8_t*); + uint8_t *bytes = va_arg(list, uint8_t *); int size = va_arg(list, int); write_bytes(bytes, size); } @@ -1164,7 +1164,7 @@ void ATHandler::handle_start(const char *cmd, const char *cmd_chr) { int len = 0; memcpy(_cmd_buffer, "AT", 2); - len +=2; + len += 2; memcpy(_cmd_buffer + len, cmd, strlen(cmd)); len += strlen(cmd); @@ -1176,7 +1176,7 @@ void ATHandler::handle_start(const char *cmd, const char *cmd_chr) cmd_start(_cmd_buffer); } -void ATHandler::cmd_start_stop(const char *cmd, const char* cmd_chr, const char* format, ...) +void ATHandler::cmd_start_stop(const char *cmd, const char *cmd_chr, const char *format, ...) { handle_start(cmd, cmd_chr); @@ -1188,7 +1188,7 @@ void ATHandler::cmd_start_stop(const char *cmd, const char* cmd_chr, const char* cmd_stop(); } -nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char* cmd_chr, char *resp_buf, size_t buf_size, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char *cmd_chr, char *resp_buf, size_t buf_size, const char *format, ...) { lock(); @@ -1203,7 +1203,7 @@ nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char* cmd_chr, char * memcpy(_cmd_buffer, cmd, strlen(cmd)); _cmd_buffer[strlen(cmd)] = ':'; - _cmd_buffer[strlen(cmd)+1] = '\0'; + _cmd_buffer[strlen(cmd) + 1] = '\0'; resp_start(_cmd_buffer); read_string(resp_buf, buf_size); @@ -1211,7 +1211,7 @@ nsapi_error_t ATHandler::at_cmd_str(const char *cmd, const char* cmd_chr, char * return unlock_return_error(); } -nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char* cmd_chr, int &resp, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char *cmd_chr, int &resp, const char *format, ...) { lock(); @@ -1227,7 +1227,7 @@ nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char* cmd_chr, int &r size_t len = strlen(cmd); memcpy(temp, cmd, len); temp[len] = ':'; - temp[len+1] = '\0'; + temp[len + 1] = '\0'; resp_start(temp); resp = read_int(); @@ -1235,7 +1235,7 @@ nsapi_error_t ATHandler::at_cmd_int(const char *cmd, const char* cmd_chr, int &r return unlock_return_error(); } -nsapi_error_t ATHandler::at_cmd_discard(const char *cmd, const char* cmd_chr, const char* format, ...) +nsapi_error_t ATHandler::at_cmd_discard(const char *cmd, const char *cmd_chr, const char *format, ...) { lock(); diff --git a/features/cellular/framework/AT/ATHandler.h b/features/cellular/framework/AT/ATHandler.h index a913d4626c..f8c6d176bd 100644 --- a/features/cellular/framework/AT/ATHandler.h +++ b/features/cellular/framework/AT/ATHandler.h @@ -271,7 +271,7 @@ public: * @param format Format string for variadic arguments to be added to AT command; No separator needed. * Use %d for integer, %s for string and %b for byte string (requires 2 arguments: string and length) */ - void cmd_start_stop(const char *cmd, const char* cmd_chr, const char* format = "", ...); + void cmd_start_stop(const char *cmd, const char *cmd_chr, const char *format = "", ...); /** * @brief at_cmd_str Send an AT command and read 1 line string response. Locks and unlocks ATHandler for operation @@ -283,7 +283,7 @@ public: * Use %d for integer, %s for string and %b for byte string (requires 2 arguments: string and length) * @return @return last error that happened when parsing AT responses */ - nsapi_error_t at_cmd_str(const char *cmd, const char* cmd_chr, char *resp_buf, size_t resp_buf_size, const char* format = "", ...); + nsapi_error_t at_cmd_str(const char *cmd, const char *cmd_chr, char *resp_buf, size_t resp_buf_size, const char *format = "", ...); /** * @brief at_cmd_int Send an AT command and read 1 line integer response. Locks and unlocks ATHandler for operation @@ -294,7 +294,7 @@ public: * Use %d for integer, %s for string and %b for byte string (requires 2 arguments: string and length) * @return @return last error that happened when parsing AT responses */ - nsapi_error_t at_cmd_int(const char *cmd, const char* cmd_chr, int &resp, const char* format = "", ...); + nsapi_error_t at_cmd_int(const char *cmd, const char *cmd_chr, int &resp, const char *format = "", ...); /** * @brief at_cmd_discard Send an AT command and read and discard a response. Locks and unlocks ATHandler for operation @@ -305,7 +305,7 @@ public: * Use %d for integer, %s for string and %b for byte string (requires 2 arguments: string and length) * @return @return last error that happened when parsing AT responses */ - nsapi_error_t at_cmd_discard(const char *cmd, const char* cmd_chr, const char* format = "", ...); + nsapi_error_t at_cmd_discard(const char *cmd, const char *cmd_chr, const char *format = "", ...); public: @@ -550,7 +550,7 @@ private: private: //Handles the arguments from given variadic list - void handle_args(const char* format, va_list list); + void handle_args(const char *format, va_list list); //Starts an AT command based on given parameters void handle_start(const char *cmd, const char *cmd_chr); diff --git a/features/cellular/framework/AT/AT_CellularContext.cpp b/features/cellular/framework/AT/AT_CellularContext.cpp index bbde116434..afaae7b04e 100644 --- a/features/cellular/framework/AT/AT_CellularContext.cpp +++ b/features/cellular/framework/AT/AT_CellularContext.cpp @@ -757,7 +757,6 @@ nsapi_error_t AT_CellularContext::get_rate_control( CellularContext::RateControlUplinkTimeUnit &timeUnit, int &uplinkRate) { _at.lock(); - _at.cmd_start_stop("+CGAPNRC", "=", "%d", _cid); _at.resp_start("+CGAPNRC:"); diff --git a/features/cellular/framework/AT/AT_CellularSMS.cpp b/features/cellular/framework/AT/AT_CellularSMS.cpp index b07ec96ac0..dd30b4dd2e 100644 --- a/features/cellular/framework/AT/AT_CellularSMS.cpp +++ b/features/cellular/framework/AT/AT_CellularSMS.cpp @@ -394,7 +394,8 @@ char *AT_CellularSMS::create_pdu(const char *phone_number, const char *message, 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 : + int single_sms_max_length = _use_8bit_encoding ? + SMS_MAX_SIZE_8BIT_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; @@ -432,7 +433,8 @@ nsapi_size_or_error_t AT_CellularSMS::send_sms(const char *phone_number, const c // supports uncompressed 8 bit data and GSM 7 bit default alphabet data. Current implementation uses only // 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 : + int concatenated_sms_length = _use_8bit_encoding ? + SMS_MAX_8BIT_CONCATENATED_SINGLE_SMS_SIZE : SMS_MAX_GSM7_CONCATENATED_SINGLE_SMS_SIZE; if (msg_len <= single_sms_max_length) { @@ -523,7 +525,6 @@ void AT_CellularSMS::set_sms_callback(Callback func) nsapi_error_t AT_CellularSMS::set_cpms(const char *memr, const char *memw, const char *mems) { - return _at.at_cmd_discard("+CPMS", "=", "%s%s%s", memr, memw, mems); } diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularContext.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularContext.cpp index dd71f8a309..ba0a90f4e1 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularContext.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularContext.cpp @@ -71,7 +71,7 @@ nsapi_error_t QUECTEL_BG96_CellularContext::do_user_authentication() { if (_pwd && _uname) { if (_at.at_cmd_discard("+QICSGP", "=", "%d%d%s%s%s%d", _cid, 1, - _apn, _uname, _pwd, _authentication_type) != NSAPI_ERROR_OK) { + _apn, _uname, _pwd, _authentication_type) != NSAPI_ERROR_OK) { return NSAPI_ERROR_AUTH_FAILURE; } } diff --git a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp index df41226385..19cd832dcf 100644 --- a/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp +++ b/features/cellular/framework/targets/QUECTEL/BG96/QUECTEL_BG96_CellularStack.cpp @@ -56,7 +56,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::socket_connect(nsapi_socket_t handle, _at.lock(); if (socket->proto == NSAPI_TCP) { _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d%d%d", _cid, request_connect_id, "TCP", - address.get_ip_address(), address.get_port(), socket->localAddress.get_port(), 0); + address.get_ip_address(), address.get_port(), socket->localAddress.get_port(), 0); handle_open_socket_response(modem_connect_id, err); @@ -69,7 +69,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::socket_connect(nsapi_socket_t handle, _at.at_cmd_discard("+QICLOSE", "=", "%d", modem_connect_id); _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d%d%d", _cid, request_connect_id, "TCP", - address.get_ip_address(), address.get_port(), socket->localAddress.get_port(), 0); + address.get_ip_address(), address.get_port(), socket->localAddress.get_port(), 0); handle_open_socket_response(modem_connect_id, err); } @@ -166,8 +166,8 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc if (socket->proto == NSAPI_UDP && !socket->connected) { _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d%d%d", _cid, request_connect_id, "UDP SERVICE", - (_stack_type == IPV4_STACK) ? "127.0.0.1" : "0:0:0:0:0:0:0:1", - remote_port, socket->localAddress.get_port(), 0); + (_stack_type == IPV4_STACK) ? "127.0.0.1" : "0:0:0:0:0:0:0:1", + remote_port, socket->localAddress.get_port(), 0); handle_open_socket_response(modem_connect_id, err); @@ -179,14 +179,14 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc socket_close_impl(modem_connect_id); _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d%d%d", _cid, request_connect_id, "UDP SERVICE", - (_stack_type == IPV4_STACK) ? "127.0.0.1" : "0:0:0:0:0:0:0:1", - remote_port, socket->localAddress.get_port(), 0); + (_stack_type == IPV4_STACK) ? "127.0.0.1" : "0:0:0:0:0:0:0:1", + remote_port, socket->localAddress.get_port(), 0); handle_open_socket_response(modem_connect_id, err); } } else if (socket->proto == NSAPI_UDP && socket->connected) { _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d", _cid, request_connect_id, "UDP", - socket->remoteAddress.get_ip_address(), socket->remoteAddress.get_port()); + socket->remoteAddress.get_ip_address(), socket->remoteAddress.get_port()); handle_open_socket_response(modem_connect_id, err); @@ -198,7 +198,7 @@ nsapi_error_t QUECTEL_BG96_CellularStack::create_socket_impl(CellularSocket *soc socket_close_impl(modem_connect_id); _at.at_cmd_discard("+QIOPEN", "=", "%d%d%s%s%d", _cid, request_connect_id, "UDP", - socket->remoteAddress.get_ip_address(), socket->remoteAddress.get_port()); + socket->remoteAddress.get_ip_address(), socket->remoteAddress.get_port()); handle_open_socket_response(modem_connect_id, err); } @@ -235,7 +235,7 @@ nsapi_size_or_error_t QUECTEL_BG96_CellularStack::socket_sendto_impl(CellularSoc // Send if (socket->proto == NSAPI_UDP) { _at.cmd_start_stop("+QISEND", "=", "%d%d%s%d", socket->id, size, - address.get_ip_address(), address.get_port()); + address.get_ip_address(), address.get_port()); } else { _at.cmd_start_stop("+QISEND", "=", "%d%d", socket->id, size); }