libremesh / lime-packages

LibreMesh packages configuring OpenWrt for wireless mesh networking
https://libremesh.org/
GNU Affero General Public License v3.0
281 stars 96 forks source link

Adds shared-state rpcd data,error output format and shared-state-async rpcd reimplementation #1103

Closed javierbrk closed 7 months ago

javierbrk commented 7 months ago

Ubus interface for shared state

current implementations of rpcd for shared-state are inconsistent this new implementation adds a consistent format across the three implementations (shared-state, shared-state-async, shared-state-multiwriter ) In every case calls to shared state get or sync will return a json object wit this format

{"data":{},"error":0}

Also this new implementation for shared-state-async uses a shell script to simplify the implementation

Ubus interface for shared state async

ubus -S call shared-state-async get '{"data_type": "bat-hosts"}'

{
  "data": {
    "02:29:0f:a5:1e:d1": "LiMe_a51ed1_eth1_2_29",
    "02:58:47:a5:1e:d1": "LiMe_a51ed1_wlan0_mesh_29",
    "02:95:39:a5:1e:d1": "LiMe_a51ed1_eth0_29",
    "02:ab:46:a5:1e:d1": "LiMe_a51ed1_wlan1_mesh_29",
    "02:bb:ed:a5:1e:d1": "LiMe_a51ed1_eth1_29",
    "02:cc:4e:a5:1e:d1": "LiMe_a51ed1_wlan2_mesh_29",
    "02:db:d6:a5:1e:d1": "LiMe_a51ed1_eth0_1_29",
    "06:ef:f4:3d:4d:75": "LiMe_a51ed1_bat0",
    "a8:40:41:1c:85:16": "LiMe_a51ed1_wlan1_ap",
    "a8:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_ap",
    "a8:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_ap",
    "a8:40:41:1f:73:aa": "LiMe_a51ed1_eth0_1_17",
    "a8:40:41:1f:73:ab": "LiMe_a51ed1_eth1_17",
    "aa:40:41:1c:85:16": "LiMe_a51ed1_wlan1_apname",
    "aa:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_apname",
    "aa:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_apname",
    "ae:40:41:1c:85:16": "LiMe_a51ed1_wlan1_mesh",
    "ae:40:41:1c:85:c3": "LiMe_a51ed1_wlan2_mesh",
    "ae:40:41:1f:73:a8": "LiMe_a51ed1_wlan0_mesh"
  },
  "error": 0
}

ubus -S call shared-state-async get '{"data_type": "bat-hosss"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts"}'

{"data":{},"error":146}

ubus -S call shared-state-async sync '{"data_type": "bat-hosss"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hostss", "peers_ip":"10.13.30.20"}'

{"data":{},"error":208}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"10.13.30.20"}'

{"data":{},"error":148}

ubus -S call shared-state-async sync '{"data_type": "bat-hosts", "peers_ip":"127.0.0.1"}'

{"data":{},"error":0}

Ubus interface for shared state and shared state Multiwriter

Get the list of available methods using:

ubus -v list shared-state

Get wifi links information:

ubus -S call shared-state getFromSharedState '{"data_type": "wifi_links_info" }'

Write information that is common to every all the network:

ubus -S call shared-state insertIntoSharedStateMultiWriter '{"data_type": "ref_state_wifi_links", "json": {"primero":{"bleachTTL":27}}}'

Get the information in the same node:

ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links"}'

{"data":{"primero":{"bleachTTL":27}},"error":0}

Get the info in another node, before getting the information the others need to sync on the same topic. This has to be done before reading and data types usually do it in a cron job.

shared-state-multiwriter sync ref_state_wifi_links

ubus -S call shared-state getFromSharedStateMultiWriter '{"data_type": "ref_state_wifi_links" }'

ilario commented 7 months ago

This looks good :D

Do you think we should include it in the next release candidate once it is merged?

Do you plan to move all this to OpenWrt repositories at some point?

selankon commented 7 months ago

Do you think we should include it in the next release candidate once it is merged?

imo should be included! This makes the shared state calls more consistent...

But, it will break the compatibility with older versions. Are this packages already included on the actual version?

Do you plan to move all this to OpenWrt repositories at some point?

I think shared state not exists on the OWRT repos no?

ilario commented 7 months ago

Do you think we should include it in the next release candidate once it is merged?

imo should be included! This makes the shared state calls more consistent...

But, it will break the compatibility with older versions. Are this packages already included on the actual version?

Compatibility? Currently we have the latest stable release 2020.4 based on OpenWrt 19.07 and including LibreMesh code from more than one year ago. Most importantly, it has the legacy non-async shared-state. So the compatibility with this one I feel is not going to be preserved anyway, no?

Do you plan to move all this to OpenWrt repositories at some point?

I think shared state not exists on the OWRT repos no?

Shared state does not exist on OpenWrt repository, correct. But it should be there. It should not be here. In case there is any shared-state developer willing to manage the migration, maybe some people from OpenWrt could help...? @aparcar

G10h4ck commented 7 months ago

@ilario shared-state developers and it is pretty tied to libre-mesh stuff altought it might be used indipendently, at this stage of development, moving it to openwrt repository could be premature IMHO, but once shared-state-async is more stable and completely substitute shared-state Lua, it might be good to move it in openwrt-packages

javierbrk commented 7 months ago

Shared State rpcd/ubus interface is used only by lime app so they go together. The last release of limeapp is not using this interface. @selankon can confirm. So this is not required in the candidate release.