Skip to content

Commit d65e4ed

Browse files
Code formatting
1 parent a45a17a commit d65e4ed

File tree

5 files changed

+36
-34
lines changed

5 files changed

+36
-34
lines changed

include/constants.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,43 @@
1-
//Uncomment below line if it is the gateway.Otherwise keep it commented out.
2-
// #define GATEWAY
1+
// Uncomment below line if it is the gateway.Otherwise keep it commented out.
2+
// #define GATEWAY
33

4-
//Lora transceiver module and sensor pins
5-
#define CS 5
6-
#define DIO0 GPIO_NUM_2 // Dont define just with numbers, use GPIO_NUM_X
4+
// Lora transceiver module and sensor pins
5+
#define CS 5
6+
#define DIO0 GPIO_NUM_2 // Dont define just with numbers, use GPIO_NUM_X
77
#define SENSOR_INPUT GPIO_NUM_4 // Dont define just with numbers, use GPIO_NUM_X
8-
#define SENSORSWITCH 32 // Switching the Sensor on and off.
8+
#define SENSORSWITCH 32 // Switching the Sensor on and off.
99

10-
//general parameters
10+
// general parameters
1111
#ifdef GATEWAY
12-
#define LISTENING_INT_LOW 5000 // in milliseconds
12+
#define LISTENING_INT_LOW 5000 // in milliseconds
1313
#define LISTENING_INT_HIGH 6000 // in milliseconds
1414
#else
15-
#define LISTENING_INT_LOW 2000 // in milliseconds
15+
#define LISTENING_INT_LOW 2000 // in milliseconds
1616
#define LISTENING_INT_HIGH 5000 // in milliseconds
1717
#endif
1818
#define TEMP_CHECK_INTERVAL 0.5 // in minutes
19-
#define WAITBEFORERESEND 10 // in seconds
20-
#define RESETINTERVAL 15 // in minutes
19+
#define WAITBEFORERESEND 10 // in seconds
20+
#define RESETINTERVAL 15 // in minutes
2121

2222
#ifdef GATEWAY
23-
//gsm
24-
#define GPRS_APN "dialogbb" // Access Point Name
23+
// gsm
24+
#define GPRS_APN "dialogbb" // Access Point Name
2525
#define SMS_NUMBER "+13137621438" // Phone number to send SMS
2626

27-
//mqtt
27+
// mqtt
2828
#define MQTT_SERVER "test.mosquitto.org"
2929
#define MQTT_PORT 1883
3030
#define MQTT_DEVICE_ID "firesense_hazards"
3131
#define DATA_RECEPTION_TOPIC "firesense_hazards/reciever"
3232
#define DATA_SENDING_TOPIC "firesense_hazards/sender"
3333

3434
#define TINY_GSM_MODEM_SIM900 // Modem is SIM900
35-
#define SerialMon Serial // Define Serial monitor
36-
#define SerialAT Serial2 // Define Serial for AT commands
35+
#define SerialMon Serial // Define Serial monitor
36+
#define SerialAT Serial2 // Define Serial for AT commands
3737
// #define DUMP_AT_COMMANDS // Dump AT commands to Serial for debugging.
38-
#define TINY_GSM_DEBUG SerialMon // Debug stream
39-
#define GSM_PIN "" // SIM card PIN (leave empty if not defined)
40-
#define TINY_GSM_USE_GPRS true // Use GPRS for internet connection
41-
#define MAX_GSM_CONNECTION_REATTEMPTS 3 // Maximum number of reattempts to connect to GSM network. then will send another sms saying the system is down.
38+
#define TINY_GSM_DEBUG SerialMon // Debug stream
39+
#define GSM_PIN "" // SIM card PIN (leave empty if not defined)
40+
#define TINY_GSM_USE_GPRS true // Use GPRS for internet connection
41+
#define MAX_GSM_CONNECTION_REATTEMPTS 3 // Maximum number of reattempts to connect to GSM network. then will send another sms saying the system is down.
4242
#define MAX_MQTT_CONNECTION_REATTEMPTS 3 // Maximum number of reattempts to connect to MQTT server. then will send another sms saying the system is down.
4343
#endif

include/functions.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <Arduino.h>
22
#include <constants.h>
3-
//utils
3+
// utils
44
void setupSerial();
55
void initLora();
66
String generateRandomID();
@@ -17,14 +17,14 @@ String listenForPackets(unsigned long lowerbound, unsigned long upperbound);
1717
#ifdef GATEWAY
1818
void sendSystemMessage(String message);
1919
#else
20-
void sendPacket( String message);
20+
void sendPacket(String message);
2121

2222
// Program
2323
void systemReset(uint64_t resetInterval); // Reset the system after a certain time.
2424
#endif
2525

2626
#ifdef GATEWAY
27-
//gsm and mqtt
27+
// gsm and mqtt
2828
bool GsmAndMqttSetup();
2929
bool GsmConnect();
3030
boolean mqttConnect();

src/gsm_and_mqtt.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ bool GsmAndMqttSetup()
9090
SerialMon.println("Network connected succesfully!");
9191
return true;
9292
}
93-
else{
93+
else
94+
{
9495
SerialMon.println("Network connection failed!");
9596
return false;
9697
}
9798
}
9899

99-
bool GsmConnect(){
100-
#if TINY_GSM_USE_GPRS
100+
bool GsmConnect()
101+
{
102+
#if TINY_GSM_USE_GPRS
101103
// GPRS connection parameters are usually set after network registration
102104
SerialMon.print(F("Connecting to :"));
103105
SerialMon.print(GPRS_APN);
@@ -123,7 +125,7 @@ bool GsmConnect(){
123125

124126
void sendMqttMessage(String Payload)
125127
{
126-
if (mqtt.publish(DATA_SENDING_TOPIC, (("Fire Hazard : " + Payload).c_str())),2)
128+
if (mqtt.publish(DATA_SENDING_TOPIC, (("Fire Hazard : " + Payload).c_str())), 2)
127129
{
128130
Serial.println("Message sent to MQTT Broker");
129131
}

src/lora.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ String listenForPackets(unsigned long lowerbound, unsigned long upperbound)
2424
{
2525
return LoRaData;
2626
}
27-
#ifndef GATEWAY
27+
#ifndef GATEWAY
2828
else if (LoRaData == "IMMEDIATE_RESET")
2929
{
3030
systemReset(RESETINTERVAL); // Reset the system immediately
3131
}
32-
#endif
32+
#endif
3333
}
3434
}
3535
Serial.println("No any valid packet received");

src/utlis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#include <constants.h>
33
#include <LoRa.h>
44
#include <Preferences.h>
5-
#include <nvs_flash.h> // Include the NVS flash library for manual NVS initialization
6-
5+
#include <nvs_flash.h> // Include the NVS flash library for manual NVS initialization
76

87
void setupSerial()
98
{ // Function to setup serial communication
@@ -34,13 +33,14 @@ void initLora()
3433
// Function to check Preferences for deviceID and generate if not found
3534
String getDeviceID()
3635
{
37-
// Initialize the NVS (Non-Volatile Storage) system (Usually this should be handled by the preferences.h, but there was a error and hence done manually.)
38-
if (nvs_flash_init() == ESP_ERR_NVS_NO_FREE_PAGES || nvs_flash_init() == ESP_ERR_NVS_NEW_VERSION_FOUND) {
36+
// Initialize the NVS (Non-Volatile Storage) system (Usually this should be handled by the preferences.h, but there was a error and hence done manually.)
37+
if (nvs_flash_init() == ESP_ERR_NVS_NO_FREE_PAGES || nvs_flash_init() == ESP_ERR_NVS_NEW_VERSION_FOUND)
38+
{
3939
// If NVS partition was truncated or a new version was found, erase it and try again
4040
nvs_flash_erase();
4141
nvs_flash_init();
4242
}
43-
Preferences preferences; // Create a Preferences object
43+
Preferences preferences; // Create a Preferences object
4444
preferences.begin("device_info", false); // Start preferences in read-write mode
4545
String device_Identifier = preferences.getString("deviceID", "NULL");
4646

0 commit comments

Comments
 (0)