diff --git a/openapi/owanalytics.yaml b/openapi/owanalytics.yaml index b6907bd..a5fad97 100644 --- a/openapi/owanalytics.yaml +++ b/openapi/owanalytics.yaml @@ -452,7 +452,13 @@ paths: schema: type: boolean required: false - + - in: query + description: list of boards for a given venue + name: forVenue + schema: + type: string + format: uuid + required: false responses: 200: description: Return a list of boards diff --git a/src/RESTAPI/RESTAPI_board_list_handler.cpp b/src/RESTAPI/RESTAPI_board_list_handler.cpp index d546494..ddf6981 100644 --- a/src/RESTAPI/RESTAPI_board_list_handler.cpp +++ b/src/RESTAPI/RESTAPI_board_list_handler.cpp @@ -8,6 +8,25 @@ namespace OpenWifi { void RESTAPI_board_list_handler::DoGet() { + auto forVenue = GetParameter("forVenue",""); + + if(!forVenue.empty()) { + std::vector Boards; + auto F = [&](const AnalyticsObjects::BoardInfo &B) -> bool { + if(!B.venueList.empty()) { + for(const auto &venue:B.venueList) { + if(venue.id == forVenue) { + Boards.emplace_back(B); + break; + } + } + } + return true; + }; + DB_.Iterate(F); + return ReturnObject("boards",Boards); + } + return ListHandler("boards", DB_, *this); } diff --git a/src/StatFunc.h b/src/StatFunc.h index 959c55e..ff3393e 100644 --- a/src/StatFunc.h +++ b/src/StatFunc.h @@ -11,13 +11,13 @@ namespace OpenWifi { class RelativeCounter { public: explicit RelativeCounter(uint64_t iv) { - inited = iv; + inited = true; LastValue = iv; } RelativeCounter() = default; - inline uint64_t set(uint64_t v) { + [[nodiscard]] inline uint64_t set(uint64_t v) { if(!inited) { inited=true; LastValue=v; diff --git a/stats_sample/bridge2_config.json b/stats_sample/bridge2_config.json new file mode 100644 index 0000000..138575a --- /dev/null +++ b/stats_sample/bridge2_config.json @@ -0,0 +1,154 @@ +{ + "globals": { + "wireless-multimedia": { + "profile": "rfc8325" + } + }, + "interfaces": [ + { + "ethernet": [ + { + "select-ports": [ + "WAN*", + "LAN*" + ] + } + ], + "ipv4": { + "addressing": "dynamic" + }, + "ipv6": { + "addressing": "dynamic" + }, + "name": "BowenNetwork", + "role": "upstream", + "services": [ + "ssh", + "lldp", + "mdns" + ], + "ssids": [ + { + "bss-mode": "mesh", + "encryption": { + "ieee80211w": "optional", + "key": "snoopy_mesh", + "proto": "psk2" + }, + "name": "BowenMesh", + "services": [ + "statistics" + ], + "wifi-bands": [ + "5G" + ] + }, + { + "bss-mode": "ap", + "encryption": { + "ieee80211w": "optional", + "key": "snoopy99", + "proto": "psk2" + }, + "name": "petunia", + "roaming": { + "generate-psk": true, + "message-exchange": "ds" + }, + "services": [ + "wifi-steering" + ], + "wifi-bands": [ + "2G", + "5G" + ] + } + ], + "tunnel": { + "proto": "mesh" + }, + "vlan": { + "id": 100 + } + } + ], + "metrics": { + "dhcp-snooping": { + "filters": [ + "ack", + "discover", + "offer", + "request", + "solicit", + "reply", + "renew" + ] + }, + "health": { + "interval": 60 + }, + "statistics": { + "interval": 60, + "types": [ + "ssids", + "lldp", + "clients" + ] + }, + "wifi-frames": { + "filters": [ + "probe", + "auth", + "assoc", + "disassoc", + "deauth", + "local-deauth", + "inactive-deauth", + "key-mismatch", + "beacon-report", + "radar-detected" + ] + } + }, + "radios": [ + { + "band": "5G", + "bandwidth": 20, + "channel": 36, + "channel-mode": "VHT", + "channel-width": 80, + "country": "CA", + "tx-power": 10 + }, + { + "band": "2G", + "bandwidth": 20, + "channel-mode": "VHT", + "channel-width": 40, + "country": "CA", + "tx-power": 23 + } + ], + "services": { + "lldp": { + "describe": "uCentral", + "location": "universe" + }, + "mdns": { + "enable": true + }, + "ssh": { + "port": 22 + }, + "wifi-steering": { + "assoc-steering": true, + "load-kick-threshold": 90, + "mode": "local", + "network": "upstream", + "required-probe-snr": -80, + "required-roam-snr": -80, + "required-snr": -85 + } + }, + "uuid": 1645464648 +} diff --git a/test_scripts/curl/cli b/test_scripts/curl/cli index f816a14..fe6176c 100755 --- a/test_scripts/curl/cli +++ b/test_scripts/curl/cli @@ -236,6 +236,13 @@ listboards() { jq < ${result_file} } +boardsforvenue() { + curl ${FLAGS} -X GET "https://${OWANALYTICS}/api/v1/boards?forVenue=$1" \ + -H "accept: application/json" \ + -H "Authorization: Bearer ${token}" > ${result_file} + jq < ${result_file} +} + boarddevices() { curl ${FLAGS} -X GET "https://${OWANALYTICS}/api/v1/board/$1/devices" \ -H "accept: application/json" \ @@ -257,6 +264,7 @@ case "$1" in "systeminfo") login; systeminfo ; logout;; "boarddevices") login; boarddevices $2 ; logout ;; "deleteboard") login; deleteboard $2; logout ;; + "boardsforvenue") login; boardsforvenue $2; logout;; *) help ;; esac