Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ String NODATA = "NODATA";
tpp_LoRa LoRa;


void logToParticle(String message, String deviceNum, String payload, String SNRhub1) {
void logToParticle(String message, String deviceNum, String payload, String SNRhub1, String RSSIHub1) {
// create a JSON string to send to the cloud
String data = "message=" + message
+ "|deviceNum=" + deviceNum + "|payload=" + payload
+ "|SNRhub1=" + String(SNRhub1);
+ "|SNRhub1=" + String(SNRhub1) + "|RSSIHub1=" + String(RSSIHub1);

Serial.println("cloudLogging:" + data);
long rtn = Particle.publish("LoRaHubLogging", data, PRIVATE);
Expand Down Expand Up @@ -126,7 +126,7 @@ void loop() {

// log the data to the cloud
Serial.println("sent message: " + messageSent);
logToParticle(logMessage, LoRa.deviceNum, LoRa.payload, LoRa.SNR);
logToParticle(logMessage, LoRa.deviceNum, LoRa.payload, LoRa.SNR, LoRa.RSSI);

digitalWrite(D7, LOW);
Serial.println("Waiting for messages");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,28 @@ bool tpp_LoRa::initDevice(int deviceAddress) {
if(sendCommand("AT+NETWORKID=" + String(LoRaNETWORK_NUM)) != 0) {
debugPrintln("Network ID not set");
error = true;

} else {
debugPrintln("Network number set");

// Set the device number based on button state
if(sendCommand("AT+ADDRESS=" + String(deviceAddress)) != 0) {
} else if(sendCommand("AT+ADDRESS=" + String(deviceAddress)) != 0) {
debugPrintln("Device number not set");
error = true;

} else {
debugPrintln("Device number set");

// set the parameters for the LoRa module
if(sendCommand("AT+PARAMETER=" + String(LoRaSPREADING_FACTOR) + ","
} else if(sendCommand("AT+PARAMETER=" + String(LoRaSPREADING_FACTOR) + ","
+ String(LoRaBANDWIDTH) + "," + String(LoRaCODING_RATE) + "," + String(LoRaPREAMBLE)) != 0) {
debugPrintln("Parameters not set");
error = true;
} else {
debugPrintln("Parameters set");
}
}
debugPrintln("Parameters not set");
error = true;
} else if (sendCommand("AT+MODE=0") != 0) {
debugPrintln("Tranciever mode not set");
error = true;
} else if (sendCommand("AT+BAND=915000000") != 0) {
debugPrintln("Band not set");
error = true;
} else if (sendCommand("AT+CRFOP=22") != 0) {
debugPrintln("Power not set");
error = true;
} else {
debugPrintln("LoRo module is initialized");
}
}

thisDeviceNetworkID = deviceAddress;

return error;

Expand All @@ -101,7 +100,11 @@ bool tpp_LoRa::readSettings() {
debugPrintln("Reading back the settings");

bool error = false;
if(sendCommand("AT+NETWORKID?") != 0) {

if(sendCommand("AT+CRFOP=22?") != 0) {
debugPrintln("error reading radio power");
error = true;
} else if (sendCommand("AT+NETWORKID?") != 0) {
debugPrintln("error reading network id");
error = true;
} else if(sendCommand("AT+ADDRESS?") != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define LoRaSPREADING_FACTOR 9 // default 9; 7 - 11 larger is better for range
// SF7to SF9 at 125kHz, SF7 to SF10 at 250kHz, and SF7 to SF11 at 500kHz
#define LoRaBANDWIDTH 7 // default 7; 7:125kHz, 8:250kHz, 9:500kHz lower is better for range
#define LoRaCODING_RATE 1 // default 1; 1 is faster; [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LoRaCODING_RATE 4 // default 1; 1 is faster; [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LoRaPREAMBLE 24 // 12 max unless network number is 18;

// class for the LoRa module
Expand Down Expand Up @@ -59,6 +59,7 @@ class tpp_LoRa
int transmitMessage(String devAddress, String message);

int receivedMessageState = 0; // 0 = no message, 1 = message received, -1 = error
String thisDeviceNetworkID = "";
String parameters = "";
String receivedData = "";
String loraStatus = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,28 @@ bool tpp_LoRa::initDevice(int deviceAddress) {
if(sendCommand("AT+NETWORKID=" + String(LoRaNETWORK_NUM)) != 0) {
debugPrintln("Network ID not set");
error = true;

} else {
debugPrintln("Network number set");

// Set the device number based on button state
if(sendCommand("AT+ADDRESS=" + String(deviceAddress)) != 0) {
} else if(sendCommand("AT+ADDRESS=" + String(deviceAddress)) != 0) {
debugPrintln("Device number not set");
error = true;

} else {
debugPrintln("Device number set");

// set the parameters for the LoRa module
if(sendCommand("AT+PARAMETER=" + String(LoRaSPREADING_FACTOR) + ","
} else if(sendCommand("AT+PARAMETER=" + String(LoRaSPREADING_FACTOR) + ","
+ String(LoRaBANDWIDTH) + "," + String(LoRaCODING_RATE) + "," + String(LoRaPREAMBLE)) != 0) {
debugPrintln("Parameters not set");
error = true;
} else {
debugPrintln("Parameters set");
}
}
debugPrintln("Parameters not set");
error = true;
} else if (sendCommand("AT+MODE=0") != 0) {
debugPrintln("Tranciever mode not set");
error = true;
} else if (sendCommand("AT+BAND=915000000") != 0) {
debugPrintln("Band not set");
error = true;
} else if (sendCommand("AT+CRFOP=22") != 0) {
debugPrintln("Power not set");
error = true;
} else {
debugPrintln("LoRo module is initialized");
}
}

thisDeviceNetworkID = deviceAddress;

return error;

Expand All @@ -101,7 +100,11 @@ bool tpp_LoRa::readSettings() {
debugPrintln("Reading back the settings");

bool error = false;
if(sendCommand("AT+NETWORKID?") != 0) {

if(sendCommand("AT+CRFOP=22?") != 0) {
debugPrintln("error reading radio power");
error = true;
} else if (sendCommand("AT+NETWORKID?") != 0) {
debugPrintln("error reading network id");
error = true;
} else if(sendCommand("AT+ADDRESS?") != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#define LoRaSPREADING_FACTOR 9 // default 9; 7 - 11 larger is better for range
// SF7to SF9 at 125kHz, SF7 to SF10 at 250kHz, and SF7 to SF11 at 500kHz
#define LoRaBANDWIDTH 7 // default 7; 7:125kHz, 8:250kHz, 9:500kHz lower is better for range
#define LoRaCODING_RATE 1 // default 1; 1 is faster; [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LoRaCODING_RATE 4 // default 1; 1 is faster; [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
#define LoRaPREAMBLE 24 // 12 max unless network number is 18;

// class for the LoRa module
Expand Down Expand Up @@ -59,6 +59,7 @@ class tpp_LoRa
int transmitMessage(String devAddress, String message);

int receivedMessageState = 0; // 0 = no message, 1 = message received, -1 = error
String thisDeviceNetworkID = "";
String parameters = "";
String receivedData = "";
String loraStatus = "";
Expand Down