Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Add main class for Firething and example. #234

Merged
merged 7 commits into from
Dec 9, 2016

Conversation

ed7coyne
Copy link
Collaborator

@ed7coyne ed7coyne commented Dec 3, 2016

Removed transcriber example as it is used here.

root.printTo(*output);
}

void Config::ReadFromJson(const char* string) {
Copy link
Contributor

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

Copy link
Collaborator Author

@ed7coyne ed7coyne Dec 5, 2016

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)) {
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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();
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

@ed7coyne
Copy link
Collaborator Author

ed7coyne commented Dec 9, 2016

Merging to start iterating on this.

@ed7coyne ed7coyne merged commit 2e2a87d into FirebaseExtended:master Dec 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants