Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions adafruit_minimqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import struct
import time
from random import randint
import microcontroller
from micropython import const
import adafruit_logging as logging

Expand Down Expand Up @@ -126,8 +125,8 @@ def __init__(self, socket, broker, port=None, username=None,
self.client_id = client_id
else:
# assign a unique client_id
self.client_id = 'cpy{0}{1}'.format(microcontroller.cpu.uid[randint(0, 15)],
randint(0, 9))
self.client_id = 'cpy{0}{1}'.format(randint(0, int(time.monotonic()*100)%1000),
randint(0, 99))
# generated client_id's enforce spec.'s length rules
if len(self.client_id) > 23 or not self.client_id:
raise ValueError('MQTT Client ID must be between 1 and 23 bytes')
Expand Down