microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
715 stars 589 forks source link

Make BLE Event Service optional (like other BLE services) #3715

Closed ngammarano closed 3 years ago

ngammarano commented 3 years ago

Is your feature request related to a problem? Please describe.

BLE services consume memory, restricting the size of the program. So it would be great to make all optional services optional in MakeCode.

Describe the solution you'd like

In MakeCode, there are blocks for adding the accelerometer service, the button service, the io pin service, the led service, the temperature service, the magnetometer service and the uart service. Since the event service is optional (see Lancaster University micro:bit BLE profile), it would be great to create a MakeCode block named "bluetooth event service", and disable the service by default (just like the other services).

micro:bit version

This feature request is for both micro:bit V1 and V2.

pelikhan commented 3 years ago

I beleive the event service is not optional so this requires a CODAL fix. @finneyj

ngammarano commented 3 years ago

@pelikhan According to Lancaster University, that service is optional:

  1. in the Bluetooth Developer Studio Level 3 Profile Report, the Event Service has Requirement Optional
  2. in micro:bit documentation > BLE > GATT services table, the Event Service appears as optional
  3. in micro:bit documentation > BLE > Event Service, it says:

    The Bluetooth service is an optional part of the standard Bluetooth profile for the micro:bit.

jaustin commented 3 years ago

@ngammarano just to check, you're using a micro:bit V1, is that right?

@pelikhan don't we turn on the event service here? https://github.com/microsoft/pxt-microbit/blob/d6867610fd4921d56fe9f1dfddf00c3ce2f4362d/libs/core/pxt.json#L112

In which case could it be a userconfig to turn it off? Like the pairing mode config?

It would break existing projects to change the default from on to off, and quite possibly a number of other things rely on it being there (perhaps @martinwork will know what might break if the event service is off). However, I think having it as an option might work well.

ngammarano commented 3 years ago

@jaustin This happens for both micro:bit V1 and micro:bit V2 versions.

Maybe there is a way to make the event service optional, and if a program uses event service blocks add it automatically such that this does not break the existing programs?

martinwork commented 3 years ago

I can't think of anything that internally depends on the event service. Was there a plan to trigger a restart into pairing mode by using the event service?

pelikhan commented 3 years ago

I've added a PR to have a toggle in the project settings. Until then, you can do this manually.

abchatra commented 3 years ago

Fixed.