Skip to content

the code actuator of virtual-device #385

@hjlarry

Description

@hjlarry

Hi guys, I found the code in lesson 3(senors-and-actuators) not work in my browser.

I tried both in win10 and macOS, and both old version or new version of counterfit.

The situation is when you open your chrome dev tools and lookup the websocket messages, it always 2 and 3, no other messages like actuators data or connection data send to the browser. So the led on/off is not change.

I try to modify the source code of counterfit like following, then it works.

@socketio.event
def set_and_send_connected(connected:bool = True) -> None:
    global is_connected
    is_connected = connected
    emit('device_connect', {'connected' : is_connected}, namespace='/', broadcast=True)

I am not familiar with websocket, I don't know why, but I hope this can help other guys.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions