Closed trickyau closed 1 year ago
I managed to compile with TinyGSM, but I cannot test it.
How to make it work?
platform.h
add NETWORK_CONTROLLER_GSM, conditionally define GSM Modem and #include <TinyGsmClient.h>
using NetClient = TinyGsmClient;
fetchRemoteIp
from utility.cpp
, return IPAddress()
if GSM is used. Unfortunately,TinyGSM uses a string instead of IPAddress.#if NETWORK_CONTROLLER == NETWORK_CONTROLLER_GSM
WebSocketClient(const NetClient &client) { m_client = client; }
#endif
Finally you can use it this way:
TinyGsm modem(SerialAT);
WebSocketClient client(TinyGsmClient{modem});
Sorry if this is a stupid question, but where exactly should overloaded constructor be placed?
If I place it it before or after default lines I get an compile error expecting 0 arguments, 1 provided.
WebSocketClient() = default; ~WebSocketClient() = default;
I would add it between the default constructor and the destructor. https://github.com/skaarj1989/mWebSockets/blob/eeeb71f06048b4a0807113df5fc302d044be5368/src/WebSocketClient.h#L19
I'm probably doing something wrong on my end, but I have place overload between L18 and L19 I still run into same issue.
WebSocketClient.h:19:3: note: candidate: 'net::WebSocketClient::WebSocketClient()' WebSocketClient.h:19:3: note: candidate expects 0 arguments, 1 provided
I'm also seeing this which I assume is probably related to the above.
error: no matching function for call to 'net::WebSocketClient::WebSocketClient(TinyGsmClient)' WebSocketClient client(TinyGsmClient{modem});
Try the GSM branch.
Slight improvement with that branch but still running into following. WiFI compiles fine, GSM does not.
c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.cpp: In member function 'void net::WebSocket::_send(uint8_t, bool, bool, const char*, uint16_t)':
c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.cpp:271:36: error: invalid conversion from 'char*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive]
bytesWritten += m_client.write(maskingKey, 4);
^~~~~~~~~~
In file included from c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmClientSIM7600.h:25,
from c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmClient.h:55,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\platform.h:72,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\utility.h:3,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.h:5,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.cpp:1:
c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmTCP.tpp:110:33: note: initializing argument 1 of 'size_t TinyGsmTCP<modemType, muxCount>::GsmClient::write(const uint8_t*, size_t) [with modemType = TinyGsmSim7600; unsigned char muxCount = 10; size_t = unsigned int; uint8_t = unsigned char]'
size_t write(const uint8_t* buf, size_t size) override {
~~~~~~~~~~~~~~~^~~
c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.cpp:282:24: error: invalid conversion from 'const char*' to 'const uint8_t*' {aka 'const unsigned char*'} [-fpermissive]
m_client.write(reinterpret_cast<const char *>(data), length);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmClientSIM7600.h:25,
from c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmClient.h:55,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\platform.h:72,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\utility.h:3,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.h:5,
from c:\Users\tricky\Documents\Arduino\libraries\mWebSockets\src\WebSocket.cpp:1:
c:\Users\tricky\Documents\Arduino\libraries\TinyGSM\src/TinyGsmTCP.tpp:110:33: note: initializing argument 1 of 'size_t TinyGsmTCP<modemType, muxCount>::GsmClient::write(const uint8_t*, size_t) [with modemType = TinyGsmSim7600; unsigned char muxCount = 10; size_t = unsigned int; uint8_t = unsigned char]'
size_t write(const uint8_t* buf, size_t size) override {
~~~~~~~~~~~~~~~^~~
Can you give more information about your environment? IDE, compiler, c++ version, etc.?
I'm using plan old Arduino IDE version 2.1.1. Not sure if I makes any difference but TinyGSM is 0.11.7.
In my environment these errors are just warnings.
Just apply reinterpret_cast<const uint8_t *>(...);
That did allow me to compile and run my code, I did however have to change handshake request to be sent as one, rather than multiple lines.
My only remaining issue, after handshake there is 0 bytes written to the connection which server assumes client has disconnected and drops the connection..
AFAIK, After the handshake, a server cannot "assume" a client connection status (the only thing it can do is send a ping frame). Are you sure that the server accepted the client handshake? What kind of server do you have?
The server is something I wrote in php years ago and runs a bunch of my personal projects fine..
Unfortunately.. detecting timed out streams in php is a pain, if I get feof or 0 bytes from fread I assume client is timed out and close the connection which has worked fine over the years until now.
Could you please check this one?
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Any idea if it's possible to use TinyGSM library with this library?