Skip to content

Commit df0f3e4

Browse files
committed
Use tabs for everything
1 parent d89c9ee commit df0f3e4

File tree

4 files changed

+96
-96
lines changed

4 files changed

+96
-96
lines changed

projects/dashboard/index.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@ const client = new ModbusRTU();
44
const toUint16 = (string) => new Uint16Array(new TextEncoder('utf-8').encode(string));
55

66
const wifiCredentials = {
7-
ssid: 'YOURSSID',
8-
password: 'YOURPASSWORD'
7+
ssid: 'YOURSSID',
8+
password: 'YOURPASSWORD'
99
};
1010

1111
client.connectRTUBuffered(
12-
'/dev/tty.usbserial-1410',
13-
{
14-
baudRate: 9600
15-
}
12+
'/dev/tty.usbserial-1410',
13+
{
14+
baudRate: 9600
15+
}
1616
).then( async () => {
17-
client.setID(1);
17+
client.setID(1);
1818

19-
await client.writeRegisters(30, toUint16(wifiCredentials.ssid))
20-
.then(() => {
21-
return client.readHoldingRegisters(30, 20)
22-
.then(val => {
23-
console.log( 'got', val.buffer.toString() )
24-
});
25-
});
26-
27-
await client.writeRegisters(10, toUint16(wifiCredentials.password))
28-
.then(() => {
29-
return client.readHoldingRegisters(10, 20)
30-
.then(val => {
31-
console.log( 'got', val.buffer.toString() )
32-
});
33-
});
19+
await client.writeRegisters(30, toUint16(wifiCredentials.ssid))
20+
.then(() => {
21+
return client.readHoldingRegisters(30, 20)
22+
.then(val => {
23+
console.log( 'got', val.buffer.toString() )
24+
});
25+
});
26+
27+
await client.writeRegisters(10, toUint16(wifiCredentials.password))
28+
.then(() => {
29+
return client.readHoldingRegisters(10, 20)
30+
.then(val => {
31+
console.log( 'got', val.buffer.toString() )
32+
});
33+
});
3434

35-
return client.writeCoil(10, true).then( r => console.log(r) );
36-
} ).catch( err => console.error( err ) );
35+
return client.writeCoil(10, true).then( r => console.log(r) );
36+
} ).catch( err => console.error( err ) );

projects/dashboard/server.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
const modbus = require('modbus-stream');
22

33
modbus.serial.connect(
4-
'/dev/tty.usbserial-1420',
5-
{
6-
debug: true
7-
},
8-
(err, connection) => {
9-
if (err) throw err;
10-
}
4+
'/dev/tty.usbserial-1420',
5+
{
6+
debug: true
7+
},
8+
(err, connection) => {
9+
if (err) throw err;
10+
}
1111
);

projects/era-node/software/modbus-node/src/main.cpp

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@
99
*/
1010

1111
#ifdef ESP8266
12-
#include <ESP8266WiFi.h>
12+
#include <ESP8266WiFi.h>
1313
#else // ESP32
14-
#include <WiFi.h>
14+
#include <WiFi.h>
1515
#endif
1616

1717
#define MODBUSRTU_DEBUG
@@ -38,81 +38,81 @@ SoftwareSerial SoftSerial(D1, D2); // RX, TX
3838
ModbusRTU mb;
3939

4040
uint16_t cbSetHregWifiSsid(TRegister* reg, uint16_t val) {
41-
Serial.print("Write. Reg RAW#: ");
42-
Serial.print(reg->address.address);
43-
Serial.print(" Old: ");
44-
Serial.print(reg->value);
45-
Serial.print(" New: ");
46-
Serial.println(val);
47-
48-
return val;
41+
Serial.print("Write. Reg RAW#: ");
42+
Serial.print(reg->address.address);
43+
Serial.print(" Old: ");
44+
Serial.print(reg->value);
45+
Serial.print(" New: ");
46+
Serial.println(val);
47+
48+
return val;
4949
}
5050

5151
uint16_t cbSetCoilWifiConnect(TRegister* reg, uint16_t val) {
52-
char ssid_from_reg[REG_STR_LEN];
53-
char password_from_reg[REG_STR_LEN];
52+
char ssid_from_reg[REG_STR_LEN];
53+
char password_from_reg[REG_STR_LEN];
5454

55-
for (uint8_t i = 0; i < REG_STR_LEN; i++) {
56-
ssid_from_reg[i] = mb.Hreg(REG_WIFI_SSID + i);
57-
password_from_reg[i] = mb.Hreg(REG_WIFI_PASSWORD + i);
58-
}
55+
for (uint8_t i = 0; i < REG_STR_LEN; i++) {
56+
ssid_from_reg[i] = mb.Hreg(REG_WIFI_SSID + i);
57+
password_from_reg[i] = mb.Hreg(REG_WIFI_PASSWORD + i);
58+
}
5959

6060
Serial.printf( "Connecting to SSID '%s' with password '%s'", ssid_from_reg, password_from_reg );
6161

62-
if (COIL_BOOL(val)) {
63-
Serial.println("Would attempt to connect");
64-
65-
WiFi.begin(String(ssid_from_reg), String(password_from_reg));
66-
67-
while (WiFi.status() != WL_CONNECTED) {
68-
delay(500);
69-
Serial.print(".");
70-
}
71-
72-
Serial.println("WiFi connected");
73-
Serial.println("IP address: ");
74-
Serial.println(WiFi.localIP());
75-
} else if ( WiFi.isConnected() ) {
76-
Serial.println("Would attempt to disconnect");
77-
WiFi.disconnect();
78-
}
79-
80-
return val;
62+
if (COIL_BOOL(val)) {
63+
Serial.println("Would attempt to connect");
64+
65+
WiFi.begin(String(ssid_from_reg), String(password_from_reg));
66+
67+
while (WiFi.status() != WL_CONNECTED) {
68+
delay(500);
69+
Serial.print(".");
70+
}
71+
72+
Serial.println("WiFi connected");
73+
Serial.println("IP address: ");
74+
Serial.println(WiFi.localIP());
75+
} else if ( WiFi.isConnected() ) {
76+
Serial.println("Would attempt to disconnect");
77+
WiFi.disconnect();
78+
}
79+
80+
return val;
8181
}
8282

8383
uint8_t frame[] = "What?";
8484
uint8_t frame_len = 6;
8585

8686
void setup() {
87-
// Serial for debugging.
88-
Serial.begin(9600, SERIAL_8N1);
87+
// Serial for debugging.
88+
Serial.begin(9600, SERIAL_8N1);
8989

90-
// Setup the Serial for RS485 communication.
91-
SoftSerial.begin(9600);
90+
// Setup the Serial for RS485 communication.
91+
SoftSerial.begin(9600);
9292

93-
mb.begin(&SoftSerial, D0);
93+
mb.begin(&SoftSerial, D0);
9494

95-
mb.slave(SLAVE_ID);
95+
mb.slave(SLAVE_ID);
9696

97-
// Register: WiFi SSID
98-
mb.addHreg(REG_WIFI_SSID, 0, REG_STR_LEN);
99-
mb.onSetHreg(REG_WIFI_SSID, cbSetHregWifiSsid, REG_STR_LEN);
97+
// Register: WiFi SSID
98+
mb.addHreg(REG_WIFI_SSID, 0, REG_STR_LEN);
99+
mb.onSetHreg(REG_WIFI_SSID, cbSetHregWifiSsid, REG_STR_LEN);
100100

101-
// Register: WiFi passphrase.
102-
mb.addHreg(REG_WIFI_PASSWORD, 0, REG_STR_LEN);
101+
// Register: WiFi passphrase.
102+
mb.addHreg(REG_WIFI_PASSWORD, 0, REG_STR_LEN);
103103

104-
// WiFi connect coil.
105-
mb.addCoil(COIL_WIFI_CONNECT, false);
106-
mb.onSetCoil(COIL_WIFI_CONNECT, cbSetCoilWifiConnect);
104+
// WiFi connect coil.
105+
mb.addCoil(COIL_WIFI_CONNECT, false);
106+
mb.onSetCoil(COIL_WIFI_CONNECT, cbSetCoilWifiConnect);
107107
}
108108

109109
void loop() {
110-
mb.task();
111-
112-
if ((millis() - lastDebounceTime) > debounceDelay) {
113-
Serial.println("Bouncing");
114-
mb.rawSend(0, frame, frame_len);
115-
Serial.println("Wrote");
116-
lastDebounceTime = millis();
117-
}
118-
}
110+
mb.task();
111+
112+
if ((millis() - lastDebounceTime) > debounceDelay) {
113+
Serial.println("Bouncing");
114+
mb.rawSend(0, frame, frame_len);
115+
Serial.println("Wrote");
116+
lastDebounceTime = millis();
117+
}
118+
}

projects/era-node/software/mysensors-node/src/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@ void setup() {
1818
}
1919

2020
void presentation() {
21-
// Send the sketch version information to the gateway and Controller
22-
sendSketchInfo("Motion Sensor", "1.0");
21+
// Send the sketch version information to the gateway and Controller
22+
sendSketchInfo("Motion Sensor", "1.0");
2323

24-
// Register all sensors to gw (they will be created as child devices)
25-
present(CHILD_ID, S_MOTION);
24+
// Register all sensors to gw (they will be created as child devices)
25+
present(CHILD_ID, S_MOTION);
2626
}
2727

2828
void loop() {
29-
send(msg.set(state ? "1" : "0"));
30-
state = state ? false : true;
31-
delay(5000);
29+
send(msg.set(state ? "1" : "0"));
30+
state = state ? false : true;
31+
delay(5000);
3232
}
3333

0 commit comments

Comments
 (0)