IRNAS / pira-smart-firmware

Firmware for PiRa Smart device
GNU General Public License v3.0
0 stars 1 forks source link

Implement configuration through serial #3

Open SloMusti opened 6 years ago

SloMusti commented 6 years ago

Implement setting the time and other parameter through serial, the simplest option would be to use the same format as for receiving:

t:<epoch in uint32_t> for setting date/time p:<on time in uint32_t> for setting on time s:<off time in uint32_t> for setting off time c:<command in uint8_t> for sending commands, for example 0x00 - no command,

SloMusti commented 6 years ago

Additionally needed: r:<reboot duration in uint32_t> for setting reboot duration wait w:<next wakeup in unit32_t> for setting when the system should be waken up next

The logic operates such: Pira smart wakes up the Pi after off period has expired or after the next wakeup time has expired. THe off-period is a safeguard, pi should schedule the next wakeup earlier then that in most cases

gorankecman commented 6 years ago

Configuration through UART has been implemented. Following commands are available: t:<uint32_t> - time in epoch format, set date/time p:<uint32_t>- configure ON time (safeguard) s:<uint32_t> - configure OFF time (safeguard) r:<uint32_t> - reboot wait period w:<uint32_t> - period for next wakeup c:<uint32_t> - other commands - implemented, but NOT USED currently

Branch: develop SHA1: c1271981cf112c769761df7969538948f40b1e90

@SloMusti please test after hex file has been provided.

gorankecman commented 6 years ago

@SloMusti maybe we need some return information if commands are received successfully? Effect of the commands can be observed only through operation or by reading some parameters through BLE.

Do we also need wakeup period and reboot period as separate commands through BLE? I will implement command interface through strings, but maybe separate commands would be useful also?

SloMusti commented 6 years ago

@gorankecman, is the data sent from pirasmart to rpi in the format as well, I believe we are sending data back as string, so this should be unified to common format.

SloMusti commented 6 years ago

@gorankecman reporting needs to be configured for this to be tested

gorankecman commented 6 years ago

Following commands are sent from Pira Smart device to UART every second: t:<uint32_t><LF> Time in epoch format, seconds o:<uint32_t><LF> General status value -> time left until next sleep - 'o' stands for overview since 'p' and 's' are occupied b:<uint32_t><LF> Battery level in ADC units p:<uint32_t><LF> On time threshold value s:<uint32_t><LF> Off time threshold value r:<uint32_t><LF> Reboot period duration w:<uint32_t><LF> Next wakeup period duration a:<uint32_t><LF> RPi status pin value

Following commands can be received and parsed through UART (all commands are 7B long): t:<uint32_t><LF> For setting date/time p:<uint32_t><LF> For setting ON time threshold s:<uint32_t><LF> For setting OFF time threshold r:<uint32_t><LF> For setting reboot duration w:<uint32_t><LF> For setting when the system should be waken up next c:<uint32_t><LF> - Reaction still not implemented! - NOT USED