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.
呓喵酱 dd31efc7f8
Update README.md
4 years ago
.gitignore before test 5 years ago
LICENSE Initial commit 5 years ago
README.md Update README.md 4 years ago
lora-socket.h udp to char 5 years ago
lora-socket.ino 栈有大问题,明天解决 5 years ago
stringVec.h test ok 5 years ago
vector.h before test 5 years ago
zh.md Create zh.md 4 years ago

README.md

LoRa-socket

size

简体中文

Usage - with Callback Functions


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

#include "lora-socket.h"

LoRaSocket socket;

void setup(){
    socket.ini(); //initalization
    socket.onReceived(doIfRec); //Register a callback function, which is triggered when a new message is received
}

void doIfRec(String message, String fromIP, String toIP, String msgType){
    //Execute the this function when a new message is received
    
    socket.udp("Hi"); //Broadcast using udp
    socket.udp("Hi xx", "1.0.0.2"); //Use udp to send messages to 1.0.0.2
    socket.tcp("Hi xxx", "1.0.0.2");  //Use tcp to send messages reliably to 1.0.0.2
}

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


Usage - with If in loop()


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

#include "lora-socket.h"

LoRaSocket socket;

void setup(){
    socket.ini(); //initalization
}

void loop(){
    //No delay() could be used in loop()
    if(socket.isNewMsg()){ //Determine whether there is new message
        Serial.println(socket.getNewMsg()); //Print out new messages directly [Method 1]
        
        String message, fromIP, toIP, msgType;
        socket.getNewMsg(message, fromIP, toIP, msgType); //Get content and information by reference [Method 2]
    }
    
    socket.core(); //Socket service core
}