Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
node-software
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bachelor-project
node-software
Commits
ec413aa8
Commit
ec413aa8
authored
2 years ago
by
Strasser, Andreas
Browse files
Options
Downloads
Patches
Plain Diff
reimplemented ntp time sync
parent
2d3f7bf5
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/driver/nbiot.be
+43
-3
43 additions, 3 deletions
src/driver/nbiot.be
with
43 additions
and
3 deletions
src/driver/nbiot.be
+
43
−
3
View file @
ec413aa8
...
@@ -74,8 +74,6 @@ class NBIoTCOAPRequest : NBIoTRequest
...
@@ -74,8 +74,6 @@ class NBIoTCOAPRequest : NBIoTRequest
end
end
class NBIoTNTPRequest : NBIoTRequest
class NBIoTNTPRequest : NBIoTRequest
def init(callback)
def init(callback)
super(self).init(NBIoTRequestType.NTP, callback)
super(self).init(NBIoTRequestType.NTP, callback)
end
end
...
@@ -269,6 +267,46 @@ class NBIoTResetProcedure : NBIoTProcedure
...
@@ -269,6 +267,46 @@ class NBIoTResetProcedure : NBIoTProcedure
end
end
end
end
class NBIoTNTPProcedure : NBIoTProcedure
var cmd_ntp
def init(ser)
super(self).init(ser)
self.cmd_ntp = NBIoTCommand('AT+QNTP=1,\"0.at.pool.ntp.org\"\r\n', '+QNTP: 0', 10)
end
def set_system_time(rsp)
var rsp_args = string.split(rsp, '\"')
var timestamp = nil
for rsp_arg : rsp_args
timestamp = tasmota.strptime(rsp_arg, "%y/%m/%d,%H:%M:%S")
if timestamp != nil
break
end
end
tasmota.cmd('time ' + str(timestamp['epoch'] + 3600)) # UTC + 1
end
def execute()
if self.cmd_in_process == nil
self.cmd_in_process = self.cmd_ntp
end
var rsp = self.fetch_read_rsp_if_contains_expected_rsp_or_send('+QNTP: 0', 'AT+QNTP=1,\"0.at.pool.ntp.org\"\r\n')
if rsp != nil
self.set_system_time(rsp)
self.done = true
end
self.aborted = self.retries_exceeded()
end
end
# ------------------------------------------------------- #
# ------------------------------------------------------- #
# Driver State #
# Driver State #
# ------------------------------------------------------- #
# ------------------------------------------------------- #
...
@@ -344,6 +382,8 @@ class NBIoTDriver
...
@@ -344,6 +382,8 @@ class NBIoTDriver
if request.request_type == NBIoTRequestType.DEBUG
if request.request_type == NBIoTRequestType.DEBUG
procedure = NBIoTDebugProcedure(self.ser, request)
procedure = NBIoTDebugProcedure(self.ser, request)
elif request.request_type == NBIoTRequestType.NTP
procedure = NBIoTNTPProcedure(self.ser)
elif
elif
tasmota.log(string.format('NBT: Request with type %i not supported, discarding request', request.request_type), 2)
tasmota.log(string.format('NBT: Request with type %i not supported, discarding request', request.request_type), 2)
end
end
...
@@ -358,7 +398,7 @@ class NBIoTDriver
...
@@ -358,7 +398,7 @@ class NBIoTDriver
if self.procedure.is_aborted()
if self.procedure.is_aborted()
var cmd = string.replace(self.procedure.cmd_in_process.cmd, '\r\n', '')
var cmd = string.replace(self.procedure.cmd_in_process.cmd, '\r\n', '')
tasmota.log(string.format('NBT: Exceeded retries at command %s, discarding request', cmd, 2)
tasmota.log(string.format('NBT: Exceeded retries at command %s, discarding request', cmd
)
, 2)
end
end
self.finish_procedure(self.procedure.is_done())
self.finish_procedure(self.procedure.is_done())
...
...
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