-
Notifications
You must be signed in to change notification settings - Fork 49
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
discovery node improvements - bacnet points, cli, integration test #1029
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
fb7a1ef
wip to fix schema
8e278ae
wip adding a run script
1382f2e
add simplified run script
636ca73
minor refator and read object list
4aaccba
add points discovery
0ee0f3a
logging
6850c59
fix point name
f34985e
update bacnet
900f29e
bacnet integration test and bacnet fixes
9efa342
bacnet error handling
f3944ac
fix missing key
d118dd1
test for past generation
5984591
fix incorrect formatting of bacnet results
fc2cb49
wi
28ee7e3
fix github actions test
39af26d
better logging and disable firmware
fdc0333
fix test_local with test selection
0617613
stash
0b6ced7
minor fixes
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
venv/* | ||
venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,93 @@ | ||
#!/bin/bash -e | ||
set -x | ||
|
||
ROOT_DIR=$(realpath $(dirname $0)/../..) | ||
function error { | ||
echo $* | ||
false | ||
} | ||
|
||
cd $ROOT_DIR | ||
ROOT_DIR=$(realpath $(dirname $0)/..) | ||
|
||
sudo venv/bin/python3 discoverynode/src/main.py | ||
BASE_CONFIG=$(realpath $ROOT_DIR/etc/base_config.json) | ||
TMP_CONFIG="/tmp/discoverynode_config.json" | ||
|
||
if [[ $# -ne 3 ]]; then | ||
error Usage: $0 SITE_MODEL TARGET DEVICE_ID | ||
fi | ||
|
||
site_model=$1 | ||
target=$2 | ||
device_id=$3 | ||
|
||
if ! [[ -f $site_model/cloud_iot_config.json ]]; then | ||
error "$site_model/cloud_iot_config.json does not exist" | ||
fi | ||
|
||
if ! [[ -f $site_model/devices/$device_id/rsa_private.pem ]]; then | ||
echo $site_model/devices/$device_id/rsa_private.pem not found | ||
error note - only RS256 keys supported | ||
fi | ||
|
||
cp $BASE_CONFIG $TMP_CONFIG | ||
|
||
if [[ -z $SUDO_USER ]]; then | ||
# reset owner of tmp config to the user to avoid file permission issues when next running not as root | ||
chown $SUDO_USER:$SUDO_USER $TMP_CONFIG | ||
fi | ||
|
||
registry_id=$(cat $site_model/cloud_iot_config.json | jq -r '.registry_id') | ||
region=$(cat $site_model/cloud_iot_config.json | jq -r '.cloud_region') | ||
|
||
provider=$(cut -d'/' -f3 <<< $target) | ||
project=$(cut -d'/' -f4 <<< $target) | ||
namespace=$(cut -d'/' -f5 <<< $target) | ||
substitutions= | ||
|
||
if [[ $provider == gbos ]]; then | ||
|
||
if [[ -n $namespace ]]; then | ||
actual_registry=$registry_id~$namespace | ||
else | ||
actual_registry=$registry_id | ||
fi | ||
|
||
substitutions=$(cat <<EOF | ||
.mqtt.host|="mqtt.bos.goog" | | ||
.mqtt.port|=8883 | | ||
.mqtt.region|="$region" | | ||
.mqtt.project_id|="$project" | | ||
.mqtt.authentication_mechanism|="jwt_gcp" | | ||
.mqtt.registry_id|="$actual_registry" | | ||
.mqtt.key_file|="$site_model/devices/$device_id/rsa_private.pem" | | ||
.mqtt.algorithm|="RS256" | | ||
.mqtt.device_id|="$device_id" | ||
EOF | ||
) | ||
|
||
elif [[ $provider == mqtt ]]; then | ||
if [[ $project != localhost ]]; then | ||
error only localhost supported | ||
fi | ||
|
||
substitutions=$(cat <<EOF | ||
.mqtt.host|="localhost" | | ||
.mqtt.port|=8883 | | ||
.mqtt.region|="$region" | | ||
.mqtt.project_id|="$project" | | ||
.mqtt.authentication_mechanism|="udmi_local" | | ||
.mqtt.registry_id|="$registry_id" | | ||
.mqtt.key_file|="$site_model/devices/$device_id/rsa_private.pem" | | ||
.mqtt.ca_file|="$site_model/reflector/ca.crt" | | ||
.mqtt.cert_file|="$site_model/devices/$device_id/rsa_private.crt" | | ||
.mqtt.algorithm|="RS256" | | ||
.mqtt.device_id|="$device_id" | ||
EOF | ||
) | ||
else | ||
echo error | ||
exit | ||
fi | ||
|
||
|
||
cat $TMP_CONFIG | jq -r "$substitutions" | sponge $TMP_CONFIG | ||
$ROOT_DIR/venv/bin/python3 $ROOT_DIR/src/main.py --config_file=$TMP_CONFIG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/bash -e | ||
ROOT_DIR=$(realpath $(dirname $0)/..) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"mqtt": { | ||
}, | ||
"udmi": { | ||
"discovery": { | ||
"ipv4": "false", | ||
"ether": false, | ||
"bacnet": false | ||
} | ||
}, | ||
"bacnet": { | ||
"ip": "192.168.11.251" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
number generator for what?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For testing. At the moment, I'm forced to have some "vendor" discovery because that's what sequencer uses, and it makes testing a whole lot easier, e.g. run "vendor" discovery for ten seconds, should receive ten events [1,2,3,4,5,6,7,8,9,10], etc.