Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Replacement for 2493] EUS: Save the post data in a file on the filesystem #2810

Merged
merged 17 commits into from
Jul 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion app/modules/enduser_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,20 @@ static int enduser_setup_write_file_with_extra_configuration_data(char *form_bod
return 1;
}

// write all key pairs as KEY="VALUE"\n
// write all key pairs as KEY="VALUE"\n into a Lua table, example:
// local p = {}
// p.wifi_ssid="ssid"
// p.wifi_password="password"
// p.device_name="foo-node"
// return p
vfs_write(p_file, "local p = {}\n", 13);
marcelstoer marked this conversation as resolved.
Show resolved Hide resolved
int idx = 0;
for( idx = 0; idx < kp->keypairs_nb*2; idx=idx+2){
char* to_write = kp->keypairs[idx];
size_t length = c_strlen(to_write);

vfs_write(p_file, "p.", 2);

vfs_write(p_file, to_write, length);

vfs_write(p_file, "=\"", 2);
Expand All @@ -771,6 +779,7 @@ static int enduser_setup_write_file_with_extra_configuration_data(char *form_bod

vfs_write(p_file, "\"\n", 2);
}
vfs_write(p_file, "return p\n", 9);

vfs_close(p_file);
enduser_setup_free_keypairs(kp);
Expand Down
16 changes: 9 additions & 7 deletions docs/modules/enduser-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,22 @@ Then the `eus_params.lua` file will contain the following:

```lua
-- those wifi_* are the base parameters that are saved anyway
wifi_ssid="ssid"
wifi_password="password"
local p = {}
p.wifi_ssid="ssid"
p.wifi_password="password"
-- your own parameters:
timeout_delay="xxx"
device_name="yyy"
p.timeout_delay="xxx"
p.device_name="yyy"
return p
```

### How to use the eus_params.lua file

Simply include the file by using the `dofile` function:
```lua
dofile('eus_params.lua')
-- now use the parameters as a global var
print("Wifi device_name: " .. device_name)
p = dofile('eus_params.lua')
-- now use the parameters in the Lua table
print("Wifi device_name: " .. p.device_name)
```

### HTTP endpoints:
Expand Down