Skip to content

Commit

Permalink
rebase LwM2M pingInterval update to main (#1064)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomqin93 authored Dec 3, 2024
1 parent 8510408 commit 539475c
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/gateway/lwm2m/gatewaylwm2m.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ const (
ConfigmapInstructionsStr = "instructions"
ObjectIdStr = "ObjectId"
DataTypeStr = "DataType"

pingIntervalSec = 10
)

type Gateway struct {
client *lwm2mclient.Client
k8sClient *rest.RESTClient
edgeDevice *v1alpha1.EdgeDevice

pingIntervalSec int64
}

func New() (*Gateway, error) {
Expand Down Expand Up @@ -68,6 +68,8 @@ func New() (*Gateway, error) {
return nil, err
}

gateway.pingIntervalSec = edgedevice.Spec.GatewaySettings.LwM2MSetting.PingIntervalSec

return gateway, nil
}

Expand Down Expand Up @@ -160,8 +162,8 @@ func (g *Gateway) Start() error {
return err
}

// Ping the client every 10 seconds
t := time.NewTicker(time.Second * pingIntervalSec)
// Ping the client every pingIntervalSec seconds, by default 30 seconds
t := time.NewTicker(time.Second * time.Duration(g.pingIntervalSec))
for range t.C {
if err := g.client.Ping(); err != nil {
logger.Errorf("Error pinging client: %v", err)
Expand Down
3 changes: 3 additions & 0 deletions pkg/k8s/api/v1alpha1/edgedevice_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ type LwM2MSetting struct {
CipherSuites []CipherSuite `json:"cipherSuites,omitempty"`
PSKIdentity *string `json:"pskIdentity,omitempty"`
PSKKey *string `json:"pskKey,omitempty"`

// +kubebuilder:default=30
PingIntervalSec int64 `json:"pingIntervalSec,omitempty"`
}

type CipherSuite string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down Expand Up @@ -95,6 +99,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down
8 changes: 8 additions & 0 deletions pkg/k8s/crd/install/config_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down Expand Up @@ -94,6 +98,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down
8 changes: 8 additions & 0 deletions pkg/k8s/crd/install/config_default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down Expand Up @@ -101,6 +105,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down
8 changes: 8 additions & 0 deletions pkg/k8s/crd/install/shifu_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down Expand Up @@ -101,6 +105,10 @@ spec:
type: string
endpointName:
type: string
pingIntervalSec:
default: 30
format: int64
type: integer
pskIdentity:
type: string
pskKey:
Expand Down

0 comments on commit 539475c

Please sign in to comment.