Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "heltec.h"
- #define BAND 915E6 //you can set band here directly,e.g. 868E6,915E6
- String packet ="";
- String packSize = "--";
- void setup() {
- Heltec.begin(true /*DisplayEnable Enable*/, true /*Heltec.LoRa Disable*/, true /*Serial Enable*/, true /*PABOOST Enable*/, BAND /*long BAND*/);
- }
- void loop() {
- //receive
- int packetSize = LoRa.parsePacket();
- if (packetSize) {
- while (LoRa.available()) {
- if (packetSize) { cbk(packetSize); }
- }
- Serial.print("Recevied ");
- Serial.print(packet);
- Serial.print(" with RSSI ");
- Serial.println(LoRa.packetRssi());
- sendack();
- }}
- void sendack(){
- Serial.print("Sending packet ");
- Serial.println(packet);
- LoRa.beginPacket();
- LoRa.setTxPower(14,RF_PACONFIG_PASELECT_PABOOST);
- LoRa.print(packet);
- LoRa.endPacket();
- }
- void cbk(int packetSize) {
- packet ="";
- packSize = String(packetSize,DEC);
- for (int i = 0; i < packetSize; i++) { packet += (char) LoRa.read(); }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement