-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lwm2m without security update * modify lwm2m without security completedly * add sleep command in azure-pipelines * push for go test * fix space in azure-pipelines * push for go test * update script * update shell script to python script * back to shell * back to shell * back to shell * update azure-pipelines * update shell
- Loading branch information
1 parent
68559a6
commit cb458e6
Showing
7 changed files
with
213 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# Default value to write to the mock device | ||
writeData=88.8 | ||
|
||
# Get the pod name of deviceshifu | ||
pod_name=$(kubectl get pods -n deviceshifu -l app=deviceshifu-lwm2m-deployment -o jsonpath='{.items[0].metadata.name}') | ||
|
||
if [ -z "$pod_name" ]; then | ||
echo "No deviceshifu-lwm2m pod found. Exiting..." | ||
exit 1 | ||
fi | ||
|
||
# Function to retrieve value from the LwM2M server | ||
get_value() { | ||
kubectl exec -n deviceshifu nginx -- curl --connect-timeout 5 deviceshifu-lwm2m.deviceshifu.svc.cluster.local/float_value | ||
} | ||
|
||
# Attempt to get the value with retries | ||
for i in {1..5}; do | ||
out=$(get_value) | ||
|
||
# Remove any whitespace and newline characters | ||
out=$(echo "$out" | tr -d '\r\n') | ||
|
||
# Output the status | ||
echo "Received value: $out" | ||
|
||
# Check if the server response indicates an error | ||
if [[ $out != "Error on reading object" ]]; then | ||
break | ||
fi | ||
|
||
echo "Device is unhealthy. Attempting to reconnect... ($i/5)" | ||
sleep 3 | ||
done | ||
|
||
if [[ $out == "Error on reading object" ]]; then | ||
echo "Device is still unhealthy after 5 attempts. Exiting..." | ||
kubectl logs -n deviceshifu $pod_name | ||
exit 1 | ||
fi | ||
|
||
# Use deviceshifu to write data to the mock device with retry settings | ||
kubectl exec -n deviceshifu nginx -- curl --retry 5 --retry-delay 3 --max-time 15 --connect-timeout 5 -X PUT deviceshifu-lwm2m.deviceshifu.svc.cluster.local/float_value -d $writeData | ||
|
||
# Retrieve the value again after writing to verify if it was successful | ||
out=$(get_value) | ||
|
||
# Remove any whitespace and newline characters | ||
out=$(echo "$out" | tr -d '\r\n') | ||
|
||
# Check if the modification was successful | ||
if awk "BEGIN {exit !($out == $writeData)}"; then | ||
echo "Modification successful" | ||
exit 0 | ||
else | ||
echo "Modification failed, expected: $writeData, got: $out" | ||
exit 1 | ||
fi |
21 changes: 21 additions & 0 deletions
21
examples/lwM2MDeviceshifuWithoutSecurity/lwM2M/lwm2m-deviceshifu-configmap.yaml
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,21 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: deviceshifu-lwm2m | ||
namespace: deviceshifu | ||
data: | ||
driverProperties: | | ||
driverSku: LwM2M Device | ||
driverImage: lwm2m-device:v0.0.1 | ||
leshanConfig: | | ||
serverUrl: coap://leshan-service.deviceshifu.svc.cluster.local:5683 | ||
instructions: | | ||
instructions: | ||
float_value: | ||
protocolPropertyList: | ||
ObjectId: /3442/0/130 | ||
EnableObserve: false | ||
reset: | ||
protocolPropertyList: | ||
ObjectId: /3303/0/5605 | ||
EnableObserve: false |
38 changes: 38 additions & 0 deletions
38
examples/lwM2MDeviceshifuWithoutSecurity/lwM2M/lwm2m-deviceshifu-deployment.yaml
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,38 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
labels: | ||
app: deviceshifu-lwm2m-deployment | ||
name: deviceshifu-lwm2m-deployment | ||
namespace: deviceshifu | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: deviceshifu-lwm2m-deployment | ||
template: | ||
metadata: | ||
labels: | ||
app: deviceshifu-lwm2m-deployment | ||
spec: | ||
containers: | ||
- image: edgehub/deviceshifu-http-lwm2m:nightly | ||
name: deviceshifu-lwm2m | ||
ports: | ||
- containerPort: 8080 | ||
volumeMounts: | ||
- name: deviceshifu-config | ||
mountPath: "/etc/edgedevice/config" | ||
readOnly: true | ||
env: | ||
- name: EDGEDEVICE_NAME | ||
value: "edgedevice-lwm2m" | ||
- name: EDGEDEVICE_NAMESPACE | ||
value: "devices" | ||
- name: LOG_LEVEL | ||
value: debug | ||
volumes: | ||
- name: deviceshifu-config | ||
configMap: | ||
name: deviceshifu-lwm2m | ||
serviceAccountName: edgedevice-sa |
22 changes: 22 additions & 0 deletions
22
examples/lwM2MDeviceshifuWithoutSecurity/lwM2M/lwm2m-deviceshifu-service.yaml
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,22 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
labels: | ||
app: deviceshifu-lwm2m-deployment | ||
name: deviceshifu-lwm2m | ||
namespace: deviceshifu | ||
spec: | ||
ports: | ||
- name: deviceshifu | ||
port: 80 | ||
protocol: TCP | ||
nodePort: 30080 | ||
targetPort: 8080 | ||
- name: lwm2mserver-coap | ||
port: 5683 | ||
protocol: UDP | ||
nodePort: 30000 | ||
targetPort: 5683 | ||
selector: | ||
app: deviceshifu-lwm2m-deployment | ||
type: NodePort |
13 changes: 13 additions & 0 deletions
13
examples/lwM2MDeviceshifuWithoutSecurity/lwM2M/lwm2m-edgedevice.yaml
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,13 @@ | ||
apiVersion: shifu.edgenesis.io/v1alpha1 | ||
kind: EdgeDevice | ||
metadata: | ||
name: edgedevice-lwm2m | ||
namespace: devices | ||
spec: | ||
sku: "LwM2M Device" | ||
connection: Ethernet | ||
protocol: LwM2M | ||
protocolSettings: | ||
LwM2MSetting: | ||
endpointName: leshan-client | ||
securityMode: None |
22 changes: 22 additions & 0 deletions
22
examples/lwM2MDeviceshifuWithoutSecurity/mockdevice/lwm2m-mock.yaml
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,22 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: leshan-client | ||
namespace: deviceshifu | ||
labels: | ||
app: leshan-client | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: leshan-client | ||
template: | ||
metadata: | ||
labels: | ||
app: leshan-client | ||
spec: | ||
containers: | ||
- name: leshan-client | ||
image: edgenesis/lwm2m-demo-leshan-client:nightly | ||
command: ["java", "-jar", "leshan-client-demo-2.0.0-SNAPSHOT-jar-with-dependencies.jar", "-u", "coap://deviceshifu-lwm2m.deviceshifu.svc.cluster.local:5683", "-n", "leshan-client"] | ||
restartPolicy: Always |