More or less consistent .editorconfig
parent
21750d32d7
commit
81306827ad
|
@ -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
|
|
@ -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 <class T> void ValueEndpoint<T>::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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -30,8 +30,7 @@ protected:
|
|||
public:
|
||||
SpejsNode(String _deviceType) :
|
||||
mqtt(MQTT_BROKER, MQTT_PORT, MqttStringSubscriptionCallback(&SpejsNode::mqttCallback, this)),
|
||||
deviceType(_deviceType)
|
||||
{};
|
||||
deviceType(_deviceType) {};
|
||||
|
||||
void init();
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue