I am working on an IoT application to connect with Google Firebase. The mbed-http library seem to be broken by recent mbed-os upgrades (latest version to work is 5.11). I have tried both mbed CLI and online compiler of which ended by compiler errors. I have tracked to a conclusion that the modification of the connect() method of TCPSocket and also TLSSocket classes is the root cause as seen from the following compiler errors.
./mbed-http/source/http_request.h: In member function ‘virtual nsapi_error_t HttpRequest::connect_socket(char*, uint16_t)’:
./mbed-http/source/http_request.h:96:57: error: no matching function for call to ‘TCPSocket::connect(char*&, uint16_t&)’
96 | return ((TCPSocket*)_socket)->connect(host, port);
| ^
In file included from ./mbed-os/features/netsocket/nsapi.h:41,
from ./mbed-os/mbed.h:26,
from .\source\main-http.cpp:5:
./mbed-os/features/netsocket/TCPSocket.h:81:19: note: candidate: ‘virtual nsapi_error_t TCPSocket::connect(const SocketAddress&)’
81 | nsapi_error_t connect(const SocketAddress &address) override;
| ^~~~~~~
./mbed-os/features/netsocket/TCPSocket.h:81:19: note: candidate expects 1 argument, 2 provided
Since the mbed-http library does not turn official even mentioned by mbed blogs, anyone may suggest a better solution for HTTP request/response code. At present, the official TCPSocket and TLSSocket seem to be an outdated approach.
Thank you very much. Just saw your post after spent the whole day to fix the broken mbed-http library. BTW, the following are for HTTP version if anyone may need.
remove an incompatible constructor method in mbed-http/source/http_request.h
remove code in mbed-http/source/http_request_base.h to exclude obsoleted string-based Socket API
// Line 75:
if (_socket && _we_created_socket) {
delete _socket;
}
// Line 246
if (_we_created_socket) {
nsapi_error_t connection_result = connect_socket(_parsed_url->host(), _parsed_url->port());
if (connection_result != NSAPI_ERROR_OK) {
return connection_result;
}
}
// Line 326
if (_we_created_socket) {
// Close the socket
_socket->close();
}
// Line 343
bool _we_created_socket;