Skip to content

Commit 4ef5c3e

Browse files
authored
Merge pull request #19 from jerryneedell/jerryn_clientid
revise generation of client ID
2 parents 4e6b6fa + e58e907 commit 4ef5c3e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

adafruit_minimqtt.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import struct
4343
import time
4444
from random import randint
45-
import microcontroller
4645
from micropython import const
4746
import adafruit_logging as logging
4847

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

0 commit comments

Comments
 (0)