implement iot-solar example
adria0 opened this issue · comments
- actix/tokio/no_std interop
- compressed feed database
- architecture PoC
- kv database
- muxrpc server
- feed sync
- command processor
- solar api
- command line
iot-solar
allows to use ssb to interface with solar mini/microgrids allowing to have a secure way to control them.
The general context is
-
AYO, BAAKO, CHIKE, DESTA and EKENE (*1) are the members of a small community powered by solar energy.
-
Each member have its own laptop, so there's no central servers to make backups, and they want to manage all the solar energy stuff and keep a track of all things done there.
-
For this, the community creates an special SSB network only to manage the microgrids. The community uses SSB to communicate and share things as usual:
- discuss about what needs to be done
- votings
- share manuals, schemas, etc...
- anotate operation on solar panels
-
but also wants some extra functionality
- allow grid to be operated remotely, via admin feed subscription
commands the device will process - allow grid to to generate feed about its status, by generating a message each day about its performance
- allow grid to be operated remotely, via admin feed subscription
-
iot-solar, is the bot that is installed in the microgrid allowing interaction
command line
iot-solar setup
- creates an identity and setups the database
iot-solar admin add @id
- adds a friend (can send commands)
iot-solar admin remove @id
- removes a friend (cannot send commands)
iot-solar report filename.txt
- generates a post with the report
iot-solar action action.txt
- generates a post with the action (self-consumed)
config.toml
netid = # networkid to use
actionpath = # executable to call when an action is triggered via special admin feed
storage
KV database
- current admins
filesystem
- own feed
- admin feeds
api (actix)
POST
/api/admin/add/
@id
POST
/api/admin/rm/
@id
POST
/api/admin/report
in body is the report content
POST
/api/admin/action
in body is the action content
app architecture draft
http
+------+ + +------------+
|cmd +-+http+--+ | +-->+ssb rpc(ro) +---+
+------+ | | | +------------+ |
v v | |
+------+ +----+-+---+ | +------------+ |
|tokio +-+->+actix +---+-->+solar api | |
+------+ | +----------+ +-----+------+ |
| | |
| +----------+ | |
| |command +<-+msg chan<-+---+ |
+->+processor | | |
| |loop +---------+ | |
| +----+-----+ | | |
| ^ term ch | | |
| +----+-----+ +---v---+ | |
+->+SIGTERMhnd| |storage| | |
| +----+-----+ |KV + fs+<---------+
| | term ch +-------+ |
| +----v-----+ ^ |
+->+feed sync +---------+-------+
| +----------+
+->+peer disc |
+----+-----+
|
v
ssbrpc/bot/lan