Google IoT Controlled Publish Period Crashing

I’m attempting to use Zerynth with ESP32 (Heltec WiFi Kit 32) to connect to Google Cloud Platform. I’m OK with GCP and have a fairly good understanding of connecting to IoT Core, having done several Arduino-based projects with a variety of different hardware platforms.

I’m using your Controlled Publish Period example, which looks fairly straightforward. Setup is OK, WiFi connection is OK (I get an IP address), however, it’s crashing at the command:

device.mqtt.connect()

Console output as follows (you’ll see some of the print statements I put in to track down where the crash happens):

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:2

load:0x3fff0018,len:4

load:0x3fff001c,len:3648

ho 0 tail 12 room 4

load:0x40078000,len:9928

ho 0 tail 12 room 4

load:0x40080400,len:5788

entry 0x400806c0

E (41) boot: OTA: -1/-1 -1/-1 -1/-4

E (42) boot: Invalid ota, returning default vm 0

E (42) boot: Starting vm 0

starting wifi

importing wifi driver

auto initialise

Establishing Link…

Linked!

My IP is: 192.168.1.162

get device credentials

connect to mqtt broker

[Thread 1 exited with exception ValueError @[0099:005C:009A:000F:009C:0011:010A:0063]](javascript:window.except(’@[0099:005C:009A:000F:009C:0011:010A:0063]’,‘Thread%201%20exited%20with%20exception%20ValueError%20’))

E (17530) wifi: esp_wifi_connect 952 wifi not start

ets Jun 8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)

….

When I click the link, it takes me to the iot.py library:

return self._jwt_fn(json.dumps(token), self.private_key)

Interestingly, I noticed something about the private key. In the project directory the private key stored in privat.hex.key (generated from GCP shell & converted to hex) looks like this:

73:3b:a0:60:0f:9b:aa:9e:9c:06:c8:3c:40:b7:7e:

70:7b:c2:0b:75:29:c5:2e:77:ef:fe:02:0d:66:4f:

ee:0e

However, when I open the private.hex.key file in Zerynth Studio it looks completely different:

37 33 3a 33 62 3a 61 30 3a 36 30 3a 30 66 3a 39 62 3a 61 61 3a 39 65 3a 39 63 3a 30 36 3a 63 38 3a 33 63 3a 34 30 3a 62 37 3a 37 65 3a 37 30 3a 37 62 3a 63 32 3a 30 62 3a 37 35 3a 32 39 3a 63 35 3a 32 65 3a 37 37 3a 65 66 3a 66 65 3a 30 32

3a 30 64 3a 36 36 3a 34 66 3a 65 65 3a 30 65

It’s a bit weird, and as the crash in iot.py refers to the private key, I’m wondering if this is the source of the problem?

Any ideas would be welcome, thanks :blush: