lancaster-university / microbit-dal

http://lancaster-university.github.io/microbit-docs
Other
254 stars 130 forks source link

Reset in pairing mode not available for radio programs #392

Open pelikhan opened 6 years ago

pelikhan commented 6 years ago

This event is ignored when BLE is turned off.

MicroBitEvent evt(MICROBIT_ID_PARTIAL_FLASHING, MICROBIT_RESET );
pelikhan commented 6 years ago

@jaustin @finneyj @microbit-sam this feature only works with a bluetooth program., can we get it always on?

jaustin commented 6 years ago

Looks like at the moment this is only getting handled in the PartialFlashingService but could potentially be registered in uBit https://github.com/lancaster-university/microbit/blob/master/source/MicroBit.cpp#L201

@microbit-sam what if we added a handler in uBit only if we're not also bringing up BLE? Looks like it relies on a StorageObject in BleManager at the moment hence the dependency but we do also have that in uBit. It might be a bit of duplication but we could possibly factor it out to a static method that takes a stroageobject in BLEManager?

microbit-sam commented 6 years ago

ack, will implement tomorrow

pelikhan commented 6 years ago

PR in MakeCode: https://github.com/Microsoft/pxt-microbit/pull/1329

pelikhan commented 6 years ago

@microbit-sam ping

microbit-sam commented 6 years ago

Sorry for the delay @pelikhan

I've moved it into uBit, however the existing event listener is listening for when other listeners are created. We can moved the reset into pairing mode code into this listener, but it means that the event required will be:

MicroBitEvent(MICROBIT_ID_MESSAGE_BUS_LISTENER, MICROBIT_ID_RESET_INTO_PAIRING);

Which is probably a bad/confusing idea.. and it doesn't look possible to specify multiple event sources

@finneyj is this a bad idea?

finneyj commented 6 years ago

@microbit-sam you should be able to use a full wildcard and register the uBit listener as (MICROBIT_ID_ANY, MICROBIT_EVT_ANY), but then all the events in the micro:bit's universe would get piped through that function. ..

This is a processing / RAM usage tradeoff I guess... and the micro:bit is relatively processor rich.

microbit-sam commented 6 years ago

Cool, once the PRs submitted against microbit and microbit-dal are reviewed and merged you will be able to trigger a reset into pairing mode with a MicroBitEvent (The event source currently doesn't matter, but may be useful to know the source in the future)

Example: MicroBitEvent evt(MICROBIT_ID_PARTIAL_FLASHING, MICROBIT_ID_RESET_INTO_PAIRING );

pelikhan commented 5 years ago

I am also going to add back the "pairing mode" in our "open" setting in MakeCode. Otherwise, it's impossible to switch into this mode.

microbit-carlos commented 5 months ago

To save resources we can implement this as a function call instead of an event.

In that case we need to check if MakeCode has got anything implemented already in this area. This PR doesn't look like it was merged, but we need to double check: https://github.com/microsoft/pxt-microbit/pull/1329/files#diff-c7001311f13221572261a0ad046afe85b7cdd4be0fe876c7ed1f4803bc403c71