microsoft / jacdac

Device and service catalogs for Jacdac.
https://aka.ms/jacdac
Creative Commons Attribution 4.0 International
66 stars 25 forks source link

Dash board does not update if a device "re-enumerates" #300

Closed jamesadevine closed 3 years ago

jamesadevine commented 3 years ago

Describe the bug When viewing the dashboard, if a device changes the service it is advertising, the dashboard does not update the digital twin. It continues to display the previous service digital twin on the dashboard. A page refresh causes it to re-detect the services on the device and display the correct digital twin.

To Reproduce Too hard to create a repro with hardware; do not have enough devices to ship. It might be easier to emulate a jacdac device in typescript to repro this bug.

1) go to dashboard 2) enumerate as a device e.g. potentiometer. 2) reset the device and enumerate a different service e.g. button 3) note the dashboard does not change

Note, if the device is unplugged for 10 seconds so the dashboard detects that the device has been unplugged, the dashboard will reflect the new service when the device is re-connected.

Screenshots

Screenshot 2021-03-23 at 22 33 30 Screenshot 2021-03-23 at 22 33 55

mmoskal commented 3 years ago

pxt-jacdac just removes the device object and adds it back when the reset counter goes back. Maybe this is what we should do in device.ts:338 instead of emitting RESTART events?

pelikhan commented 3 years ago

It's probably a matter of not tracking the change event in react, it should auto update.

I need this for the role manager switching anyway (proxy device sends empty list of services).

pelikhan commented 3 years ago

@jamesadevine what kind of scenario do you have in mind here?

jamesadevine commented 3 years ago

@pelikhan I'll demo to you later on our call, but the basic premise is that some modules may dynamically present different services based upon what is connected to them. A good example might be michal's click -> jacdac module. Potentially, the firmware might be able to detect multiple different click modules and re-enumerate itself at run time depending on which click module is connected.

For my specific example, the XAC input module, users may connect three different types of input: digital button, analog trigger (potentiometer), and x/y joysticks. When the module detects a different input has been connected, the module resets itself and begins advertising the corresponding service. I expected the dashboard to dynamically update in this case, but I guess I should send a reset event?

pelikhan commented 3 years ago

No we should be able to handle this in React.

pelikhan commented 3 years ago

Potentially, the firmware might be able to detect multiple different click modules and re-enumerate itself at run time depending on which click module is connected.

Is this plug and play though? Potentially, you'd want to do this before starting the jacdac stack.

jamesadevine commented 3 years ago

I do. The XAC input module detects the new configuration, and reboot the device. On start up it detects the input and enumerates the correct service.

It's meta plug and play

jamesadevine commented 3 years ago

https://github.com/microsoft/jacdac-msr-modules/blob/main/targets/jm-XAC-input-34-1.0A/profile/xac.c#L80

pelikhan commented 3 years ago

i see let me get a test for that

jamesadevine commented 3 years ago

Awesome, thanks @pelikhan :smile:

pelikhan commented 3 years ago

dynamicservices

pelikhan commented 3 years ago

So another scenario would be that a device has a power service, which only enables services when it's on (anyway it's my test)

jamesadevine commented 3 years ago

User reports that the sim still does not update if a device dynamically changes its services.

pelikhan commented 3 years ago

This should be fixed now. Reopen if it does not work again.