teensy

The Teensy client is coded in the C++ language, following the Teensy-template previously given (here [lien!!!]

It has 6 main methods usable in the last section, the main is the following :

extern "C" int main(void)

The 6 functions are the main types of frames without the ping_respond (because ping are from the client to the server so we won’t need to ever respond to a ping). They are defined in mqtt_frames.cpp.

In all these methods, most of the content is hardcoded (we keep the QoS fix, as for some other small parameters). The inputs for each method are:

connect(const char *client_id)

publish(const char *topic, const char *message)

subscribe(const char *topic)

unsubscribe(const char *topic)

ping(void)

disconnect(void)

To understand in more details how the whole thing works, you can directly refer to the code, it is rather well commented.
It has to be noticed that


        pinMode(SHDN_PWR, HIGH);

        digitalWrite(SHDN_PWR, HIGH);

are used for the C6 lab in particular: these two lines are here to turn on the Wi-Fi module and to initiate the communication with it. If you are using a different setup, you will probably have to replace that with something else.

In the main (main.cpp),

        Serial.begin(BAUDRATE);

        Serial1.begin(BAUDRATE);

        pinMode(SHDN_PWR, HIGH);

        digitalWrite(SHDN_PWR, HIGH);

has to be here for the communication to work. And if you want to use the serial monitor, you will also have to keep

        while (1) {

               while (Serial1.available() > 0)

                       Serial.write(Serial1.read());

                while (Serial.available() > 0)

                       Serial1.write(Serial.read());

        }


Otherwise, the rest can be freely modified, used for dealing with some particular information and so on …

Back

Teensy client
Tagged on:                                 

One thought on “Teensy client

Leave a Reply