Skip to content

Commit e5247c6

Browse files
author
brentru
committed
cleanup old time code
1 parent 2382fe1 commit e5247c6

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

adafruit_gc_iot_core.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,6 @@
4545
__version__ = "0.0.0-auto.0"
4646
__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_Cloud_IOT_Core.git"
4747

48-
TIME_SERVICE = (
49-
"https://io.adafruit.com/api/v2/%s/integrations/time/strftime?x-aio-key=%s"
50-
)
51-
52-
# our strftime is %Y-%m-%d %H:%M:%S.%L %j %u %z %Z see http://strftime.net/ for decoding details
53-
# See https://apidock.com/ruby/DateTime/strftime for full options
54-
TIME_SERVICE_STRFTIME = (
55-
"&fmt=%25Y-%25m-%25d+%25H%3A%25M%3A%25S.%25L+%25j+%25u+%25z+%25Z"
56-
)
57-
5848
class MQTT_API_ERROR(Exception):
5949
"""Exception raised on MQTT API return-code errors."""
6050
# pylint: disable=unnecessary-pass
@@ -64,6 +54,7 @@ class MQTT_API:
6454
"""Client for interacting with Google's Cloud Core MQTT API.
6555
6656
:param MiniMQTT mqtt_client: MiniMQTT Client object.
57+
6758
"""
6859

6960
# pylint: disable=protected-access
@@ -196,6 +187,7 @@ def loop(self):
196187
def loop_blocking(self):
197188
"""Begins a blocking loop to process messages from
198189
IoT Core. Code below a call to this method will NOT run.
190+
199191
"""
200192
self._client.loop_forever()
201193

@@ -204,6 +196,7 @@ def subscribe(self, topic, subfolder=None, qos=1):
204196
:param str topic: Required MQTT topic. Defaults to events.
205197
:param str subfolder: Optional MQTT topic subfolder. Defaults to None.
206198
:param int qos: Quality of Service level for the message.
199+
207200
"""
208201
if subfolder is not None:
209202
mqtt_topic = "/devices/{}/{}/{}".format(self.device_id, topic, subfolder)
@@ -216,19 +209,22 @@ def subscribe_to_subfolder(self, topic, subfolder, qos=1):
216209
:param str topic: Required MQTT topic.
217210
:param str subfolder: Optional MQTT topic subfolder. Defaults to None.
218211
:param int qos: Quality of Service level for the message.
212+
219213
"""
220214
self.subscribe(topic, subfolder, qos)
221215

222216
def subscribe_to_config(self, qos=1):
223217
"""Subscribes to a Google Cloud IoT device's configuration
224218
topic.
225219
:param int qos: Quality of Service level for the message.
220+
226221
"""
227222
self.subscribe("config", qos=qos)
228223

229224
def subscribe_to_all_commands(self, qos=1):
230225
"""Subscribes to a device's "commands/#" topic.
231226
:param int qos: Quality of Service level for the message.
227+
232228
"""
233229
self.subscribe("commands/#", qos=qos)
234230

@@ -243,6 +239,7 @@ def publish(self, payload, topic="events", subfolder=None, qos=0):
243239
:param str topic: Required MQTT topic. Defaults to events.
244240
:param str subfolder: Optional MQTT topic subfolder. Defaults to None.
245241
:param int qos: Quality of Service level for the message.
242+
246243
"""
247244
if subfolder is not None:
248245
mqtt_topic = "/devices/{}/{}/{}".format(self.device_id, topic, subfolder)
@@ -259,6 +256,7 @@ def publish_state(self, payload):
259256
sent by this method should be information about the device itself (such as number of
260257
crashes, battery level, or device health). This method is unidirectional,
261258
it communicates Device-to-Cloud only.
259+
262260
"""
263261
self._client.publish(payload, "state")
264262

@@ -318,12 +316,12 @@ def generate_jwt(self, ttl=43200, algo="RS256"):
318316
319317
jwt = CloudCore.generate_jwt()
320318
print("Generated JWT: ", jwt)
319+
321320
"""
322321
if self._logger:
323322
self._logger.debug("Generating JWT...")
324323
ntp = NTP.NTP(self._esp)
325324
ntp.set_time()
326-
#self._get_local_time()
327325
claims = {
328326
# The time that the token was issued at
329327
"iat": time.time(),

examples/gc_iot_core_simpletest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ def message(client, topic, msg):
8080
print("Message from {}: {}".format(topic, msg))
8181

8282
# Connect to WiFi
83-
print("connecting to WiFi...")
83+
print("Connecting to WiFi...")
8484
wifi.connect()
8585
print("Connected!")
8686

8787
# Initialize Google Cloud IoT Core interface
88-
google_iot = Cloud_Core(esp, secrets, log=False)
88+
google_iot = Cloud_Core(esp, secrets)
8989

9090
# Optional JSON-Web-Token (JWT) Generation
9191
# print("Generating JWT...")

0 commit comments

Comments
 (0)