diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..ecf6aac --- /dev/null +++ b/.editorconfig @@ -0,0 +1,12 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +end_of_line = lf +insert_final_newline = true +charset = utf-8 + +[*.{c,h,cpp}] +indent_style = spaces +indent_size = 4 diff --git a/spejsiot/Endpoint.cpp b/spejsiot/Endpoint.cpp index 5ea533d..110ccd9 100644 --- a/spejsiot/Endpoint.cpp +++ b/spejsiot/Endpoint.cpp @@ -8,7 +8,7 @@ void Endpoint::bind(String _key, SpejsNode* _parent) { void Endpoint::notify(String value) { /*if(parent) - parent->notify(this, value);*/ + parent->notify(this, value);*/ } template void ValueEndpoint::updateValue(T newValue) { @@ -65,12 +65,12 @@ void DHTEndpoint::bind(String _key, SpejsNode* _parent) { void DHTEndpoint::sample() { TempAndHumidity th; if(sensor.readTempAndHumidity(th)) - { + { updateValue(th.temp); - } - else - { - Serial.print("Failed to read from DHT: "); - Serial.print(sensor.getLastError()); - } + } + else + { + Serial.print("Failed to read from DHT: "); + Serial.print(sensor.getLastError()); + } } diff --git a/spejsiot/Endpoint.h b/spejsiot/Endpoint.h index c33710d..b61bce1 100644 --- a/spejsiot/Endpoint.h +++ b/spejsiot/Endpoint.h @@ -48,11 +48,11 @@ private: bool currentValue; public: - OutputEndpoint(int _pin, bool _inverted = false) : - Endpoint("output"), pin(_pin), inverted(_inverted), currentValue(inverted) { - pinMode(pin, OUTPUT); - digitalWrite(pin, currentValue); - } + OutputEndpoint(int _pin, bool _inverted = false) : Endpoint("output"), + pin(_pin), inverted(_inverted), currentValue(inverted) { + pinMode(pin, OUTPUT); + digitalWrite(pin, currentValue); + } EndpointResult onValue(String key, String value); void fillValue(JsonObject& obj); diff --git a/spejsiot/SpejsNode.cpp b/spejsiot/SpejsNode.cpp index 1ac51f0..b1737b3 100644 --- a/spejsiot/SpejsNode.cpp +++ b/spejsiot/SpejsNode.cpp @@ -21,12 +21,11 @@ void SpejsNode::init() { WifiStation.config(WIFI_SSID, WIFI_PWD); WifiStation.waitConnection( - ConnectionDelegate(&SpejsNode::onConnected, this), - 20, *[] { - Serial.println("Connection failed"); + ConnectionDelegate(&SpejsNode::onConnected, this), 20, *[] { + Serial.println("Connection failed"); }); - registerEndpoint("control", new ControlEndpoint()); + registerEndpoint("control", new ControlEndpoint()); } void SpejsNode::keepAliveHandler() { @@ -50,7 +49,7 @@ void SpejsNode::keepAliveHandler() { void SpejsNode::httpIndex(HttpRequest &request, HttpResponse &response) { - response.sendString("This is spejsiot device, take a look at: https://wiki.hackerspace.pl/projects:spejsiot"); + response.sendString("This is spejsiot device, take a look at: https://wiki.hackerspace.pl/projects:spejsiot"); } void SpejsNode::buildMetadata(JsonObjectStream* stream) @@ -180,8 +179,8 @@ bool SpejsNode::notify(String key, String value) { } void SpejsNode::registerEndpoint(String key, Endpoint* endpoint) { - endpoints[key] = endpoint; - endpoint->bind(key, this); + endpoints[key] = endpoint; + endpoint->bind(key, this); } void SpejsNode::mqttCallback(String origtopic, String value) { diff --git a/spejsiot/SpejsNode.h b/spejsiot/SpejsNode.h index 9491480..4e5588f 100644 --- a/spejsiot/SpejsNode.h +++ b/spejsiot/SpejsNode.h @@ -30,8 +30,7 @@ protected: public: SpejsNode(String _deviceType) : mqtt(MQTT_BROKER, MQTT_PORT, MqttStringSubscriptionCallback(&SpejsNode::mqttCallback, this)), - deviceType(_deviceType) - {}; + deviceType(_deviceType) {}; void init(); diff --git a/switch/app/application.cpp b/switch/app/application.cpp index 14af955..2af0e4b 100644 --- a/switch/app/application.cpp +++ b/switch/app/application.cpp @@ -3,6 +3,6 @@ SpejsNode node("switch"); void init() { - node.init(); - node.registerEndpoint("relay", new OutputEndpoint(5)); + node.init(); + node.registerEndpoint("relay", new OutputEndpoint(5)); }