You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
呓喵酱 e6e074e369
Update LICENSE
4 years ago
.gitignore ok 5 years ago
LICENSE Update LICENSE 4 years ago
README.md Update README.md 4 years ago
lora-mqtt.h udp to char 5 years ago
lora-mqtt.ino udp to char 5 years ago
lora-socket.h udp to char 5 years ago
stringVec.h ok 5 years ago
vector.h ok 5 years ago
zh.md Update zh.md 4 years ago

README.md

LoRa-mqtt

FOSSA Status size

Use MQTT in LoRa communication..

简体中文

Usage - with Callback Functions


#define LORA_SOCKET_IP "1.0.0.1" //need to be unique

#include "lora-mqtt.h"

LoRaMQTT mqtt;

void setup(){
    mqtt.ini(); //initalization
    mqtt.onReceived(doIfRec); //register callback functions which will be executed when received message
    mqtt.subscribe("Subject"); //subscribe MQTT subject
}

void doIfRec(String subject, String content){
    //When received message this function will be executed.
    
    mqtt.publish("Subject", "Content"); //publish a mqtt message
}

void loop(){
    //No delay() could be used in loop()
    mqtt.core(); //Mqtt service core
}

Usage - with If in loop()


#define LORA_SOCKET_IP "1.0.0.1" //need to be unique

#include "lora-mqtt.h"

LoRaMQTT mqtt;

void setup(){
    mqtt.ini(); //initalization
    mqtt.subscribe("Subject"); //subscribe MQTT subject
}

void loop(){
    //When received message this function will be executed.
    
    if(mqtt.isNewMsg()){
        String subject, content;
        mqtt.getNewMsg(subject, content);
        Serial.println(subject, content);
    }
    
    mqtt.core(); //Mqtt service core
}