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

Persistent storage #15

Open
Avilla83 opened this issue Feb 14, 2020 · 11 comments
Open

Persistent storage #15

Avilla83 opened this issue Feb 14, 2020 · 11 comments

Comments

@Avilla83
Copy link

Hi,

I added storage capability to all sensors and devices.
I know for sure that AdaFruitPWM8 is not stored completely and still needs some development.

Currently I tested only the ServoMotor class I added but it would be nice to have further tesing.
I am also checking how much memory is needed to serialize/deserialize the json for a correct memory allocation.

Would you like to collaborate or better integrate it in the main repository (maybe in a separate branch)?

I could start to send pull requests as soon as I implement something if you think it would be a good way to proceed.

@mistergreen
Copy link
Owner

Did you use the json library for storage or some other method?
Yeah, I could start another branch to test thing.

@Avilla83
Copy link
Author

Avilla83 commented Feb 14, 2020

Did you use the json library for storage or some other method?

Yes, I used ArduinoJson library to store.
I use a define to store internally to the ESP32 memory or externally to the SD card.

Yeah, I could start another branch to test thing.

It would be helpfull especially for devices I don't have. I have changes for storage on a separate branch. I suspect it contains also the device I added to control the servo motor.
If you create the branch I send you the pull request.

@mistergreen
Copy link
Owner

Ok, I've created a 'serialize device settings' branch.

@urkrossi
Copy link

urkrossi commented Jun 3, 2020

Hello I have great interest in their aquarium control.
But I have to say that I am not a programmer.

I have tested the controller on a "Node MCU32" and "ESP32 Wrover" board, unfortunately I have problems saving the configuration on the SPIFFS or SD card memory.
When I add devices and save a OneWire thermometer, for example, it only works until the system is restarted. The configuration is not loaded after the restart.

When I write the devices.json in the following format to memory.
>
[
{
"numDevices": 1,
"pin": 4,
"classType": "OneWireSensor",
"deviceName": "Thermometer",
"imageName": "thermo.jpg",
"deviceColor": "70B829",
"deviceState": false,
"suspendTime": false,
"deviceId": 1,
"min": 10,
"max": 50,
"unit": ""
}
]
>

Will I receive the following log output:

>
Connected to wifi
IP Address: 192.168.1.180
Loading Devices
Found devices: 1
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x4000127a PS : 0x00060630 A0 : 0x800d82fa A1 : 0x3ffb1ed0
A2 : 0x3f401d46 A3 : 0x00000000 A4 : 0x0000000a A5 : 0x0000005d
A6 : 0x00000000 A7 : 0x3ffc2b80 A8 : 0x00000053 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x3f401e29 A12 : 0x0000000a A13 : 0x00000001
A14 : 0x3f401e92 A15 : 0xff000000 SAR : 0x00000010 EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000000 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Backtrace: 0x4000127a:0x3ffb1ed0 0x400d82f7:0x3ffb1ee0 0x400d85a7:0x3ffb1f40 0x400e1fbf:0x3ffb1fb0 0x4008930d:0x3ffb1fd0
Rebooting
>

Am I doing something wrong or is there an error in the code?
Can you help me.

@mistergreen
Copy link
Owner

hey, try posting your problem over here. I'm not sure what the issue is.
https://github.com/Avilla83/WAAC

@Avilla83
Copy link
Author

Avilla83 commented Jun 4, 2020

Hi urkrossi,

I need to anticipate that the devices store and load is still in debug so I do not guarantee that it works 100%. Anyway the devices.json file is supposed to be written by the app and not manually. Could you try to delete it and let the firmware handle it?

I am in the process of implementing the hardware so soon I will probably debug it.

@urkrossi
Copy link

urkrossi commented Jun 4, 2020 via email

@Avilla83
Copy link
Author

Hi urkrossi,

I checked in the code and I didn't remember a simple fact: only the servo motor and the relay are completely stored and loaded!
All the sensors are composed of a generic sensor class and a specific sensor class.
All the devices (except relays and servo motor) are stored as generic sensors and this is not enough to allocate them. So what is missing are the serializationa and deserialization methods in the specific one wire sensor class.

Said so there are some bugs in the relay too so now I am focusing on debugging the restore process with a simple relay. If I find some time I may add the one wire sensor too.

It would be good if you have a chance to test the code too, so we have a double check on my changes. I will let you know as soon as I have something working.

Regards

@Avilla83
Copy link
Author

Hi urkrossi,
I just made a commit in my branch configuration_storage, here the content:

Added One Wire store and load - partially tested
Fix for relay event handling not being properly triggered
Fix for configuration store not saving ip related info when configuration saved
Fix for servo motor pin not being properly set on servo library
Devices store fix, document was not cleared and so all devices were added to the old ones
configuration_storage

The OneWireSensor class should be correctly saved and loaded but unfortunately I don't have a sensor of this type for a complete testing. If you can test please report the results.

I will test the events handling changes for Relay since they were not working in the previous code.

Regards

@urkrossi
Copy link

Hello Avilla83,

this sounds good, I can test here with the help of DS18b20 One Wire sensors whether the configurations are saved and loaded again after restart.
Can they provide me with the customized files for testing?

Greeting

@Avilla83
Copy link
Author

Avilla83 commented Jul 1, 2020

Hi ukrossi,

I am not sure what you mean for customized files, do you mean the devices configuration?
If so I am using the ESP internal memory so it is not easy for me to extract files from there.
What you can do is to add a one wire sensor, set the pin and see the result. All the other configurations are needed in case you want to control another device with the temperature value.

In the meanwhile my DS18B20 sensor arrived so I have been able to test it and it seems to work correctly.

I suggest you also to download from my stream since I uploaded some fixes there about devices persistent storage (incase you are using it).

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants