-
Notifications
You must be signed in to change notification settings - Fork 493
Add main class for Firething and example. #234
Conversation
root.printTo(*output); | ||
} | ||
|
||
void Config::ReadFromJson(const char* string) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC when you pass a const string to ArduinoJson it will duplicate and copy the string in the Buffer memory:
https://github.com/bblanchon/ArduinoJson/blob/master/include/ArduinoJson/JsonBuffer.hpp#L87
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great catch, missed that one. Switched it over, I haven't actually tested the updated configuration as I am WFH today but I will test it before merging.
} | ||
SetPinModes(config); | ||
|
||
if (digitalRead(config.pins.config_mode_button) || !ConnectToWiFi(config)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will that only work if you leave config_mode pressed since boot?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct you would need to hold the config button on boot to force it into config mode. Or if it can't connect to your wifi network it will go into config mode.
We start the portal either way so if we have some discoverability running and the network supports it you should be able to configure over wifi always.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here "config mode" only really means running its own wifi network.
root["path"] = config_.path.c_str(); | ||
root["wifi_ssid"] = config_.wifi_ssid.c_str(); | ||
root["wifi_key"] = config_.wifi_key.c_str(); | ||
auto client = server_.client(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we also write 200 OK
to the client and some headers to be a valid HTTP response?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do, it is in the "size" callback below (117). We need the size in order to correctly set the content length header. The way this ends up is not ideal from a readability standpoint but we can't get the size before building the json object and we don't need the size for writing to a file. So we could add another level of abstraction and introduce a ConfigSerializer object that you can prime with the config, get the size, then write to a file. Or do this callback inverted flow dance here. The other object doesn't actually sound that bad now that I think it through but I am not sure it is worth changing right now.
Merging to start iterating on this. |
Removed transcriber example as it is used here.