larjohn / rpi-scratch3-mqtt

A Scratch 3.0 extension that communicates with your RPi via mqtt (mosquitto protocol)
5 stars 1 forks source link

can not connect to websockets #1

Open shownb opened 4 years ago

shownb commented 4 years ago

I set up like this: I edit scratch-gui/src/lib/libraries/extensions/index.jsx like that:

    {
        name: 'rpi',
        extensionId: 'rpi',
        extensionURL: 'http://192.168.1.11/ext.js',
        iconURL: ws3IconURL,
        description: 'for rpi',
        featured: true
    },

but can not connect to websocket console show that

[Log] vm – "warn" – "Primitive rejected promise: " – DataCloneError: The object can not be cloned. — shared-dispatch.js:137 (lib.min.js, line 233846) DataCloneError: The object can not be cloned. — shared-dispatch.js:137

larjohn commented 4 years ago

This is supposed to connect to a python script that will communicate via mqtt with rpi. The python script can run anywhere, including your pi.

shownb commented 4 years ago

I created a similar project like that. instead of rpi,i use a esp32 chip with Micropython. my aim is that my children can control the esp32 through Scratch3. now very thing works almost perfect.

I use it in that way: https://sheeptester.github.io/scratch-gui/?url=http://shownb.github.io/esp/rpi.js

only the Scratch.BlockType.HAT can not work

larjohn commented 4 years ago

I am also interested in esp32 for scratch - this is going to help me as well :) Keep in mind that the BlockType.HAT does work if you build the Scratch VM with the extension included instead of side loading it as a .js file. This had been a known issue since the pre-release days but I don't know if it has been somehow addressed in the meantime.

shownb commented 4 years ago

yes, it works when I build it in a Scratch VM. and it won't work through the remote url import only in the scratch gui . your raspberrypi.js is for gui,not for vm ,so I just think that you have solved the problem. now I know that it is a issue in scratch gui.😊

and the idea of your hello-pie is very good. I have learned a lot of it.