New project code named: teensquitto

Status
Not open for further replies.
although it works, it seems very slow.. hmm, alright, i forgot i increased the UART buffer when i started the project, been updating teensyduino since, i moved the buffers from 64 to 256 and priority 0, mqtt is running :)


Code:
DEC:   AA 55 A2 A2 39 1 
DEC:   AA 55 A2 A2 1 3 
DEC:   AA 55 A2 A2 10 3 
DEC:   AA 55 A2 A2 4 1 
DEC:   AA 55 38 38 7 1 
DEC:   AA 55 38 38 10 1 
DEC:   AA 55 38 38 8 1 
DEC:   AA 55 38 38 12 1 
DEC:   AA 55 38 38 14 1 
DEC:   AA 55 38 38 3 1 
*** WiFi Status 6: WL_DISCONNECTED ***
*** MQTT disconnected ***
*** WiFi Status 3: WL_CONNECTED ***
DEC:   AA 55 38 38 6 0 1A 
Packet ID: 26
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 1B 
Packet ID: 27
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 1C 
Packet ID: 28
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 1D 
Packet ID: 29
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 1E 
Packet ID: 30
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 1F 
Packet ID: 31
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 20 
Packet ID: 32
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 21 
Packet ID: 33
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 22 
Packet ID: 34
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 23 
Packet ID: 35
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 24 
Packet ID: 36
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 25 
Packet ID: 37
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 26 
Packet ID: 38
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 27 
Packet ID: 39
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 28 
Packet ID: 40
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 29 
Packet ID: 41
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 2A 
Packet ID: 42
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 2B 
Packet ID: 43
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 2C 
Packet ID: 44
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 2D 
Packet ID: 45
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 2E

as usual, ignore the DEC data, thats debug... Publish received and PacketID are callbacks printed
 
heres a UDP broadcast i did from packetsender, on T3.6 console callback:
Code:
retain: 0 len: 11 index: 0 total: 11


[COLOR="#0000FF"][B]UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)[/B][/COLOR]
DEC:   AA 55 CE CE 5 0 0 0 14 
DEC:   AA 55 38 38 6 0 83 
Packet ID: 131
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


DEC:   AA 55 38 38 6 0 84
 
Pressing reset on ESP shows the Teensy lambda callback re-initialize the ESP
Code:
*** WiFi Status 6: WL_DISCONNECTED ***
*** MQTT disconnected ***
DEC:   AA 55 A2 A2 10 3 
*** WiFi Status 3: WL_CONNECTED ***
DEC:   AA 55 A2 A2 4 1 
DEC:   AA 55 38 38 7 1 
DEC:   AA 55 38 38 10 1 
DEC:   AA 55 38 38 8 1 
DEC:   AA 55 38 38 12 1 
DEC:   AA 55 38 38 14 1 
DEC:   AA 55 38 38 3 1 
DEC:   AA 55 CE CE 1 1 
ESP detected.
ESP was restarted.
DEC:   AA 55 38 38 6 0 0 
*** MQTT connected ***
DEC:   AA 55 38 38 0 0 1 
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 1 len: 11 index: 0 total: 11

As you see, start stages of acknowledgements for the commands sent to setup the ESP (wifi user/passs, websockets, udp lambda,mqtt credentials, etc)
Then the running operation of mqtt callback.

Looks working to me, especially with UDP working as well :)

heres the ESP end debug using a uart adaptor:
Code:
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
CE CE 5 0 0 0 14 C0 A8 2 7A D0 CE 47 6F 74 20 31 34 20 62 79 74 65 73 20 6F 66 20 64 61 74 61 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
CE CE 5 0 0 0 14 C0 A8 2 7A D0 CE 47 6F 74 20 31 34 20 62 79 74 65 73 20 6F 66 20 64 61 74 61 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
CE CE 5 0 0 0 14 C0 A8 2 7A D0 CE 47 6F 74 20 31 34 20 62 79 74 65 73 20 6F 66 20 64 61 74 61 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1

thats an mqtt packet sent by master every 2 seconds, and the callback goes from ESP to Teensy handler and printed out to console...
 
Updating the core / libraries for ESP shouldnt affect Teensquitto, that was the intention of this library. In order to break things, they'd have to change function methods, which, would not make alot of users happy :)
But this is the way to get true 3rd party transparency with stock core/library upgradablity

last time i tested teensquitto was with a T3.5 was february, other than the uart buffer increase, it should continue working :)
 
Tony... I am sure it is something I am doing that not quite right and trying to figure out why its not working now . it should just like you showed - had it working before no problem now --- arggh....... have to check wiring again.
 
Should I put the H/CPP on github? with debug disabled (you can enable it manually), the ESP requires a complete sketch folder

heres it is without debug:
Code:
Packet ID: 105
UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 106
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 107
UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 108
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 109
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 110
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 111
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 112
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 113
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 114
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 115
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 116
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 117
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 118
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 119
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 120
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 121
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 122
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 123
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 124
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 125
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 126
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 127
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 128
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 129
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 130
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 131
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 132
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 133
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 134
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 135
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: hello Mike! :)
Packet ID: 136
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 137
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 138
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 
That would be a good idea. This way other people can give it a try since we are talking about it. Also, will SPI_MSTransfer still work with this - I saw you had a spi_MST_controller identified.

EDIT: What driving me nuts most of all is that I had all this working before SPI_MSTransfer...... Now that I am back to it I forgot everything - had udp, mqtt and async scan working like a charm and now this. So I know it has to be something I am doing wrong but guess I am too tired now.
 
Yes, SPI_MST works with it. I posted it a few posts back #54

https://forum.pjrc.com/threads/4883...ed-teensquitto?p=169763&viewfull=1#post169763

Hey Mike, your in the UDP data :)
Code:
UDP Packet Type: Broadcast, From: 192.168.2.122:53454, To: 255.255.255.255:1234, Length: 14, Data: [COLOR="#0000FF"][B]hello Mike! [/B][/COLOR]:)
Development files are up on github with debug disabled, no examples yet, no documents yet either obviously
They are the working ones I'm using to test out mqtt and udp in my setup

edit, I uploaded the original concept demo, the one im currently using for mqtt & udp, just so the commands and stuff are there for reference
its a concept demo in the examples folder

see, Mike, I set it up fast for you:D

teensquitto.jpg
 
Last edited:
Thanks wise guy - I actually had a couple of demos working (at least the wifiscan examples still work) - mqtt and udp was working nice and even had the demo attached to a 9250 and the Teensy visualizer. Now I have to figure out what wrong...... 99% sure my router is blocking the ports.

EDIT: spi_mst works even with the all the changes :) slave works on the 8266?
 
No, and I wont bother with ESP either in terms of SPI. The ESP requires a command byte before the data byte and I don't really want to transform the entire master and slave code to adapt to an abomination like that, that and it's not very stable either.
If the ESP32 or particle have a better interface in terms of standard SPI api for slave mode, I could add that support for teensy and take advantage of their resources, but not the spi on esp8266, its not worth the hastle :)

wow i started teensquitto in january and developed till february and its been sitting in the closet since, good to see it still works :)
 
Morning again. Anyway got the 2 versions of wifi scan example (regular and async) but still can't seem to get udp to stream or read from packet sender. Something blocking I think but I can't think of what..... Anyway if you get a chance and you still have your set up done can you give this a try....
wow i started teensquitto in january and developed till february and its been sitting in the closet since,
yeah been side tracked with SPI_MSTransfer, Circular Buffer and uNavAHRS. :) Me too. :)



Code:
#include <teensquitto.h>
#include <IPAddress.h>
#include <string>

teensquitto UdpS = teensquitto("WiFiUdp", &Serial1);
teensquitto wifi = teensquitto("WiFi", &Serial1);

    IPAddress ip(192, 168, 1, 162);
    IPAddress gate(192, 168, 1, 1);
    IPAddress sub(255, 255, 255, 0);
    const char* ssid = "................................";
    const char* password = "................................";

    //WiFiUDP Udp;
    unsigned int localUdpPort = 4210;  // local port to listen on
    unsigned int localUdpPortS = 3333;  // local port to listen on
    char incomingPacket[255];  // buffer for incoming packets
    char  replyPacket[] = "Hi there! Got the message :-)";  // a reply string to send back
    char  replyPacekt1[] = "Loop de Loop :-)";

    void setup()
    {
      Serial.begin(115200);
      Serial1.begin(2000000);
      Serial2.begin(2000000);
      Serial.println();
      Serial.printf("Connecting to %s ", ssid);


  ESP.onDetect([]() {
    wifi.mode(WIFI_STA);
    wifi.begin(ssid, password);
    wifi.waitForConnectResult();
    wifi.config(ip, gate, sub);
    if (  udp.listen(localUdpPort) ) {
      udp.onPacket([](AsyncUDPPacket packet) {
        Serial.print("UDP Packet Type: ");
        Serial.print(packet.isBroadcast() ? "Broadcast" : packet.isMulticast() ? "Multicast" : "Unicast");
        Serial.print(", From: ");
        Serial.print(packet.remoteIP());
        Serial.print(":");
        Serial.print(packet.remotePort());
        Serial.print(", To: ");
        Serial.print(packet.localIP());
        Serial.print(":");
        Serial.print(packet.localPort());
        Serial.print(", Length: ");
        Serial.print(packet.length());
        Serial.print(", Data: ");
        Serial.write(packet.data(), packet.length());
        Serial.println();
        // reply to the client
        packet.printf("Got %u bytes of data", packet.length());
      });
    }
  }); // end of onDetect callback
  
  UdpS.begin(localUdpPortS);
  //Serial.printf("Now listening at IP %s, UDP port %d\n", WiFi.localIP().toString().c_str(), localUdpPortS);

}

void loop()
{
      
    UdpS.beginPacket(UdpS.remoteIP(), UdpS.remotePort());
    UdpS.print(replyPacekt1);
    UdpS.endPacket();
    wifi.events();
    delay(50);
      
     wifi.events();
}

void serialEvent1() {
  wifi.events();
}

void serialEvent2() {
 if ( Serial2.available() ){
  String str1;
  str1 = Serial2.readString();
  Serial.println("Serial2 Event: "); Serial.println(str1);  
  Serial.write(Serial2.read());
  }
  wifi.events();
}
 
"not asyncudp " ok confused now - think I was following your example - will have to go look up asyncudp :) and how to do that. But don't go too nuts. I just loaded the UDP example from the repository directly on the 8266 using the latest and greatest core and doesn't work either, either - it connects fine but when I go send a packet from packet sender nothing either so its some setting on my machine.

:(

EDIT: Just looked thought I was or did I reference the wrong one?
 
Run this once, not in a loop
Code:
          udp.onPacket([](AsyncUDPPacket packet) {
            Serial.print("UDP Packet Type: ");
            Serial.print(packet.isBroadcast() ? "Broadcast" : packet.isMulticast() ? "Multicast" : "Unicast");
            Serial.print(", From: ");
            Serial.print(packet.remoteIP());
            Serial.print(":");
            Serial.print(packet.remotePort());
            Serial.print(", To: ");
            Serial.print(packet.localIP());
            Serial.print(":");
            Serial.print(packet.localPort());
            Serial.print(", Length: ");
            Serial.print(packet.length());
            Serial.print(", Data: ");
            Serial.write(packet.data(), packet.length());
            Serial.println();
            // reply to the client
            packet.printf("Got %u bytes of data", packet.length());
          });

then you'll start receiving packets in the AsyncUDP handler (which is also the same one above)
The lambda is both an activator and callback in one

It's in the original AsyncUDP example on the ESP8266 as well, I try to make it look/act identical :)

i tested both multicast and unicast with it and it was running
 
Just a heads up - tried compiling with the latest version of the 8266 core and it breaks things. Getting invalid conversions now and a bunch of other errors with teensquitto on the ESP. Also tried to run the ESPAsyncUDP standalone example and it dumps the stack... Putting it back to an older version now for testing.

I have this currently in the setup - so remove the IF? Think its needed isn't it?
Code:
  ESP.onDetect([]() {
    wifi.mode(WIFI_STA);
    wifi.begin(ssid, password);
    wifi.waitForConnectResult();
    wifi.config(ip, gate, sub);
    if (  udp.listen(localUdpPort) ) {
      udp.onPacket([](AsyncUDPPacket packet) {
        Serial.print("UDP Packet Type: ");
        Serial.print(packet.isBroadcast() ? "Broadcast" : packet.isMulticast() ? "Multicast" : "Unicast");
        Serial.print(", From: ");
        Serial.print(packet.remoteIP());
        Serial.print(":");
        Serial.print(packet.remotePort());
        Serial.print(", To: ");
        Serial.print(packet.localIP());
        Serial.print(":");
        Serial.print(packet.localPort());
        Serial.print(", Length: ");
        Serial.print(packet.length());
        Serial.print(", Data: ");
        Serial.write(packet.data(), packet.length());
        Serial.println();
        // reply to the client
        packet.printf("Got %u bytes of data", packet.length());
      });
    }
  }); // end of onDetect callback
 
Downloaded the latest 8266 core from GitHub and received numerous errors around the same two lines that repeated in the cases. I did a conversion but not sure its working:
Code:
1.  Serial1.write(datar, sizeof(datar));     to    Serial1.write((const uint8_t*)datar, sizeof((const uint8_t*)datar));

and

2. Serial1.write(datar, data_pos);    to    Serial1.write((const uint8_t*)datar, data_pos);
 
the errors are over simple conversions? wow hehehe

im updating the esp8266 core now

thats a weird error
Code:
C:\Program Files (x86)\Arduino\hardware\esp8266com\esp8266\cores\esp8266/HardwareSerial.h:156:12: error:   initializing argument 1 of 'virtual size_t HardwareSerial::write(const uint8_t*, size_t)' [-fpermissive]

     size_t write(const uint8_t *buffer, size_t size)

Code:
exit status 1
invalid conversion from 'char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

Did they actually drop the write buffer from accepting char* arrays and only use uint8_t ?.. hmm

EDIT, yup, I changed char to uint8_t and that line didnt cause error anymore.
So re-edit the sketch or edit the core, fun fun

I did a mass replace:
char datar[ ----> uint8_t datar[

Next, because of that edit, we're getting unabigous errors like
WiFi.hostname(buf); (because needs char)
so changed to WiFi.hostname((char*)buf);

still looking..
ESP compilations are sloooooooooooooooower than uploading lol.. it's like i have to go drink coffee to wait till it crashes at the next error
haha

EDIT, IT COMPILESS!!!!

To me, I think they dropped char support for the Serial write class !!!
 
Last edited:
Mike, try this? It compiles with the latest core, but like I said, the code doesnt break unless they remove a used method/overload from the core (which they did with char buffer sending support :p )

And it looks like they removed the overload method for buffered char writes to serial it seems :)

Code:
[ATTACH]13862._xfImport[/ATTACH]

it's in their Stream.h file only for uint8_t*, no more char*
Code:
// Public Methods //////////////////////////////////////////////////////////////

/* default implementation: may be overridden */
size_t Print::write(const uint8_t *buffer, size_t size) {

works with the latest core:
Code:
38 38 12 5 4 45 53 50 30 32 74 6F 6E 79 
38 38 14 C0 A8 2 7A 7 5B 
38 38 3 
EA EA 23 
EA EA 24 
EA EA 12 
EA EA 20 4 6 74 6F 6E 79 74 65 65 6E 73 79 
EA EA 4 
EA EA 9 0 0 13 88 
CE CE 1 4 D2 
CE CE 7 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64 
MQTT Connection: 1
38 38 6 C B 2 1 0 0 0 0 0 0 0 74 65 65 6E 73 71 75 69 74 74 6F 2F 68 65 6C 6C 6F 20 77 6F 72 6C 64

AsyncUDP works with the new core, however, marvin's MQTT library doesn't work with new core, then again I have marvin's february copy :p, gonna go update his library and reflash the ESP, brb
 
Last edited:
Updated async MQTT in library from github copy and guess what happened when i restarted ESP?

Teensy 3.5 console printout:
Code:
*** WiFi Status 6: WL_DISCONNECTED ***
*** MQTT disconnected ***
*** WiFi Status 3: WL_CONNECTED ***
ESP detected.
ESP was restarted.
*** MQTT connected ***
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 1 len: 11 index: 0 total: 11


UDP Packet Type: Unicast, From: 192.168.2.122:64754, To: 192.168.2.168:1234, Length: 14, Data: hello Mike! :)
Packet ID: 2
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 3
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 4
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 5
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 6
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


UDP Packet Type: Unicast, From: 192.168.2.122:64754, To: 192.168.2.168:1234, Length: 14, Data: hello Mike! :)
Packet ID: 7
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11


Packet ID: 8
****************************
Publish received.
 topic: teensquitto/ payload: hello world
 qos: 2 dup: 0
 retain: 0 len: 11 index: 0 total: 11

MQTT WORKS!

See thats what I'm talking about.... transparency updates :D hahahaha

So to summarize, new core introduced new bugs to mqtt, which were fixed during the downtime of teensquitto over few months, the core also stopped char* buffer writes to serial which crippled teensquitto as most buffers were char based. So buffers had to be changed to uint8_t, library mqtt updated, and core github version updated to fix all the issues so far :)

EDIT, just removed STL's vector support from teensquitto. Circular_Buffer is in charge! :)

EDIT, here you go!

Code:
[ATTACH]13863._xfImport[/ATTACH]
 
Last edited:
I updated github copies as well, going to Circular_Buffer was easy as it used the same calls as vector, "push_back()", "size()", "front()", etc :)
The bonus is you couldn't get a size() from a vector wrapped in a C++ dequeue container, so had to use stl's "for count : vector" to count originally to update count of data
With Circular_Buffer, I replaced that for loop counter for size to a simple "length_front()" method in Circular_Buffer, so simple. :)
 
Whats the link to marvins library - can't find it?

By the way just tried compiling and getting this error again:
error: invalid conversion from 'char*' to 'const uint8_t* {aka const unsigned char*}' [-fpermissive]

Serial1.write(datar, sizeof(datar)); return; // don't send ACK, response given instead.

On - never mind - just saw you updated the sketch when I went to GitHub. Not thinking today - just got back from the dentist argh :)
 
Status
Not open for further replies.
Back
Top