Closed LZHenry closed 1 year ago
hello, I recommend enabling debug messages on the broker. This will allow you to understand who and how connects to the broker. It is also interesting what the device writes. As I understand it, it does not connect to the broker?
Thanks for the answer. Still confused on the basics. I put DEBUG print statements in the code... nothing prints.
I expected the demo code to see the TASMOTA transmit for connection... nothing prints. I expect the same from a HomeSEER request... but nothing.
are there more examples of how to trigger a print when a message is received???
Thanks
Enable debug in arduino ide -> https://www.mischianti.org/wp-content/uploads/2020/09/ArduinoIDE-esp32-log-levels.jpg PlatformIO -> https://github.com/terrorsl/sMQTTBroker/issues/12 if you want to see publish message:
class MyBroker:public sMQTTBroker
{
public:
bool onEvent(sMQTTEvent *event) override
{
switch(event->Type())
{
case NewClient_sMQTTEventType:
{
sMQTTNewClientEvent *e=(sMQTTNewClientEvent*)event;
e->Login();
e->Password();
}
break;
case LostConnect_sMQTTEventType:
WiFi.reconnect();
break;
case Public_sMQTTEventType:
sMQTTPublicClientEvent *e;
break;
case UnSubscribe_sMQTTEventType:
case Subscribe_sMQTTEventType:
{
sMQTTSubUnSubClientEvent *e=(sMQTTNewClientEvent*)event;
}
break;
}
return true;
}
};
Ah! that debug... Thanks... working on it with my Visual Studio.
Very STUPID user error... as typical. Fixed. Connected. On to normal testing. Will still need a lot of learning now. Thank you. But while I have you, how many MQTT connections are possible? allowed? LZH
YES Broker is talking to device and HomeSEER. Thank you, but still a bit lost. If it is easy for you, I want to print to serial window.... IP Address of device attaching Topic arriving Number of Clients Attached
Thanks... LZH
Very STUPID user error... as typical. Fixed. Connected. On to normal testing. Will still need a lot of learning now. Thank you.
But while I have you, how many MQTT connections are possible? allowed? LZH
smqttbroker doesn't limit, this limit hardware and framework.
YES Broker is talking to device and HomeSEER. Thank you, but still a bit lost. If it is easy for you, I want to print to serial window....
IP Address of device attaching
Topic arriving
Number of Clients Attached
Thanks... LZH
On connection event you may know all about client. Also broker know number attached client, see sMqttBroker.h
OK.. the LAST time this year I will bother you. Not needed from you, but I have invested hours and this should be EASY for you to explain... Please.
Again, the BROKER works, I just want to better understand the operation. I am old and the class structures do not fit well into my head.
Here are the calls in the code that do not work; can you advise/fix???? Thanks.
**case NewClient_sMQTTEventType:**
{
sMQTTNewClientEvent *e = (sMQTTNewClientEvent*)event;
//! receive topic name by index
// This prints garbage
std::string zTopicName = getRetaiedTopicName(1); // BAD HARDCODED this is wrong #!!
Serial.printf(" .....................>>>>>>>Topic is %s\n\n", (zTopicName));
// This prints garbage
std::string dddf;
dddf = e->Login();
Serial.printf(" login %s ",dddf );
dddf = e->Password();
Serial.printf(" Password %s \n", dddf);
// YES this prints possibly a count
Serial.printf("........... zTopicCount = %5d \n", (getRetainedTopicCount())); // YES OK
std::string have function c_str() return char's ending 0. You need send it to printf.
Thank you thank you thank you.. NOW can see all the messages arriving.
Found everything I need to see. Will work some more and possibly send you an updated DEMO file.
Thanks... LZH
Stale issue message
Obviously I thought I knew more than I actually do. You would be kind to point me to some documents/answers?
Existing working system is HomeSeer 3 --> ESP8266 Broker --> TASMOTA device Substituting the sMQTT BROKER Can not get your ESP32 BROKER to connect to either end.
HS3 is obviously sending requests to sMQTT.... I seem to get nothing at the BROKER TASMOTA device is sending requests to sMQTT... code detect nothing. I assume there are some basics that I do not understand???? Thanks for reading... LZH
CODE FOLLOWS BELOW
define IDSTRING "V 1 DEC 30 2022 CV_BROKER_ESP32TEST_Vxx "
include
const char zssid = "xxx"; // The SSID (name) of the Wi-Fi network you want to connect to const char zpassword = "xxx"; // The password of the Wi-Fi network
// This code is LOCAL BROKER talking to DEVICE/CLIENTs and HS3 IPAddress LOCAL_BROKER_IP(10, 0, 0, 111); IPAddress Zgateway(10, 0, 0, 1); // set gateway to match your network IPAddress Zsubnet(255, 255, 255, 0); // set subnet mask to match your network
const unsigned short mqttPort = 1883;
class MyBroker :public sMQTTBroker { public: bool onEvent(sMQTTEvent *event) override { Serial.println("GOT EVENT zzzz "); //
};
MyBroker broker; unsigned long Time; unsigned long freeRam;
void setup() { Serial.begin(115200); delay(333); // wait for port to settle Serial.println(" "); // //**** Serial.println(IDSTRING); //........................... //****
};
// lll void loop() { broker.update(); // your magic code
};