Comments (1)
The problem was that http client instance was not being passed a valid reference to the gsmClient
instance
What didn't work:
I think this is because gsmClient i was using not initialized with a modem properly.
// main.cpp
TinyGsm modem = cellFunctions.modem;
TinyGsmClient gsmClient = cellFunctions.gsmClient;
// cellFunctions.h
class CellFunctions
{
public:
CellFunctions(HardwareSerial &serialGsmRef, HardwareSerial &SerialATRef, StreamDebugger &debugger);
.
.
.
TinyGsm modem; // instance of TinyGsm modem class
TinyGsmClient gsmClient; // instance of the TinyGsm client class to use with mqtt
};
// getMQTTEndpoint.cpp
bool MQTTEndpoint::getMQTTEndpoint(Client &client)
{
char final_url[256];
sprintf(final_url, "http://%s/api/firmware/%s/", domain, apiKey);
bool endpoint_found = false;
while (!endpoint_found)
{
HttpClient http(client, domain, 80);
http.setTimeout(10000);
int err = http.get(final_url);
if (err != 0)
{
Logger.logMessage(LOG_LEVEL_ERROR, "HTTP GET not successful");
}
err = http.responseStatusCode();
Logger.logMessage(LOG_LEVEL_DEBUG, "The HTTP Response code is: %d", err);
if (err >= 300 || err < 200)
{
Logger.logMessage(LOG_LEVEL_ERROR, "Failed to get MQTT Endpoint due to bad HTTP response code");
delay(30000);
continue;
}
String payload = http.readString();
What did work
//main.cpp
TinyGsm modem = cellFunctions.modem;
TinyGsmClient gsmClient(modem); // here i actually pass the modem to the gsmClient before using the client to call getMQTTEndpoint
from tinygsm.
Related Issues (20)
- M5Stack M5ScoreS3 and Module Com.X LTE (SIM7600G) HOT 1
- M5CoreS3 & COM.X LTE example ALLFUNTIONS error with send sms HOT 1
- Compatibility with Simcom's SIM A7672S 4G + 2G LTE Development Board
- Find IMEI using my serial number. iPad Air 5th Gen.
- Empty stream after call waitResponse()
- Can't connect to MQTT broker from time to time HOT 1
- NTPServerSync() always returns error status 62 or 63 in SIM 7070G HOT 1
- Stable connections + GSM USSD Codes
- TinyGSM GsmClient disconnects after multipart/form-data is sent
- [ Question ] ESP32 ### unhandled: HOT 5
- TinyGSM function (modem.gprsConnect(...)) reset Wemos D1 mini (ESP8266) - Soft WDT reset problem
- Is TINY_GSM_MODEM_SIM7600 not supporting wifi connection? HOT 1
- STM32G0BQRE compilation issue with TinyGSM
- SSL support to SIM7600 HOT 1
- SIM7000A Not being detected
- Missing error handling and drops return code from waitResponse, etc.
- Device detected but soft WDT reset HOT 1
- How to run a webserver through GPRS using ESP32
- NTPServerSync() fails to return the appropriate status upon success for SIM7000G
- getGsmLocation(...) latitude and longitude values are in reversed order.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tinygsm.