Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
z2m
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Go
z2m
Commits
65b331eb
"...git@gitlab.imt-atlantique.fr:iota-imt/goshimmer.git" did not exist on "8bd01e4012f85568e43d29172b960b21642888d9"
Commit
65b331eb
authored
5 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Z2MDevice.Send() now publish .. no-more publish in xaal.go ;)
parent
f7b3ef59
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
xaal.go
+3
-9
3 additions, 9 deletions
xaal.go
z2m.go
+9
-0
9 additions, 0 deletions
z2m.go
with
12 additions
and
9 deletions
xaal.go
+
3
−
9
View file @
65b331eb
...
@@ -147,17 +147,14 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
...
@@ -147,17 +147,14 @@ func (dev *PowerRelay) update(payload map[string]interface{}) {
power
:=
dev
.
GetAttribute
(
"power"
)
power
:=
dev
.
GetAttribute
(
"power"
)
if
value
==
"ON"
{
if
value
==
"ON"
{
power
.
SetValue
(
true
)
power
.
SetValue
(
true
)
}
else
{
}
else
if
value
==
"OFF"
{
power
.
SetValue
(
false
)
power
.
SetValue
(
false
)
}
}
}
}
func
(
dev
*
PowerRelay
)
setState
(
value
string
)
{
func
(
dev
*
PowerRelay
)
setState
(
value
string
)
{
// TODO: put this in Z2MDevice
topic
:=
dev
.
Z2MDevice
.
SetTopic
()
client
:=
GetGW
()
.
client
body
:=
`{"state": "`
+
value
+
`"}`
body
:=
`{"state": "`
+
value
+
`"}`
client
.
Publish
(
topic
,
0
,
false
,
body
)
dev
.
Z2MDevice
.
Send
(
body
)
}
}
func
(
dev
*
PowerRelay
)
On
(
xaal
.
MessageBody
)
*
xaal
.
MessageBody
{
func
(
dev
*
PowerRelay
)
On
(
xaal
.
MessageBody
)
*
xaal
.
MessageBody
{
...
@@ -198,11 +195,8 @@ func (dev *Lamp) update(payload map[string]interface{}) {
...
@@ -198,11 +195,8 @@ func (dev *Lamp) update(payload map[string]interface{}) {
}
}
func
(
dev
*
Lamp
)
setState
(
value
string
)
{
func
(
dev
*
Lamp
)
setState
(
value
string
)
{
// TODO: put this in Z2MDevice
topic
:=
dev
.
Z2MDevice
.
SetTopic
()
client
:=
GetGW
()
.
client
body
:=
`{"state": "`
+
value
+
`"}`
body
:=
`{"state": "`
+
value
+
`"}`
client
.
Publish
(
topic
,
0
,
false
,
body
)
dev
.
Z2MDevice
.
Send
(
body
)
}
}
func
(
dev
*
Lamp
)
On
(
xaal
.
MessageBody
)
*
xaal
.
MessageBody
{
func
(
dev
*
Lamp
)
On
(
xaal
.
MessageBody
)
*
xaal
.
MessageBody
{
...
...
This diff is collapsed.
Click to expand it.
z2m.go
+
9
−
0
View file @
65b331eb
...
@@ -74,6 +74,15 @@ func (zDev *Z2MDevice) SetTopic() string {
...
@@ -74,6 +74,15 @@ func (zDev *Z2MDevice) SetTopic() string {
return
zDev
.
GetTopic
()
+
"/set"
return
zDev
.
GetTopic
()
+
"/set"
}
}
func
(
zDev
*
Z2MDevice
)
Send
(
payload
interface
{})
{
topic
:=
zDev
.
SetTopic
()
slog
.
Debug
(
"Sending"
,
"topic"
,
topic
,
"payload"
,
payload
)
client
:=
GetGW
()
.
client
if
token
:=
client
.
Publish
(
topic
,
0
,
false
,
payload
);
token
.
Wait
()
&&
token
.
Error
()
!=
nil
{
slog
.
Error
(
"Error sending"
,
":"
,
token
.
Error
())
}
}
func
(
l
AccessLevel
)
String
()
string
{
func
(
l
AccessLevel
)
String
()
string
{
return
[
...
]
string
{
"--"
,
"R"
,
"W"
,
"RW"
,
"Err"
,
"RN"
,
"Err"
,
"RWN"
}[
l
]
return
[
...
]
string
{
"--"
,
"R"
,
"W"
,
"RW"
,
"Err"
,
"RN"
,
"Err"
,
"RWN"
}[
l
]
// return fmt.Sprintf("%d", l)
// return fmt.Sprintf("%d", l)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment