Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Being able to identify micro:bit board version #16

Open
microbit-carlos opened this issue Mar 6, 2023 · 0 comments
Open

Being able to identify micro:bit board version #16

microbit-carlos opened this issue Mar 6, 2023 · 0 comments
Assignees

Comments

@microbit-carlos
Copy link

microbit-carlos commented Mar 6, 2023

There is already a "Board Version" property in the JS side that is used to identify the board, but needs be updated for V2.2 support anyway:

The following properties provide version information:
<dl>
<dt>boardVersion</dt><dd>
Property. The micro:bit hardware version (currently either 1.3 or 1.5).</dd>

this.boardVersion = this.boardVersionFromSerialNumber(p.serialNumber);

boardVersionFromSerialNumber(usbSerialNumber) {
// The micro:bit board version can be determined from the USB device serial number.
// See https://support.microbit.org/support/solutions/articles/19000084312-micro-bit-motion-sensor-hardware-changes-for-editor-developers
var id = usbSerialNumber.slice(0, 4);
if ('9900' == id) return '1.3';
if ('9901' == id) return '1.5';
if ('9903' == id) return '2.0';
if ('9904' == id) return '2.0';
return 'unrecognized board';
}

We also need to fix the Firmware Version reported by the firmware programme, as the DAL_VERSION macro does not get a valid version number in CODAL (lancaster-university/codal-microbit-v2#138):

static void reportFirmwareVersion() {
// Send firmware version plus DAL, mbed library, and softdevice version info.
// The softdevice version can be found by looking up the firmward ID (FWID) here:
// https://devzone.nordicsemi.com/f/nordic-q-a/1171/how-do-i-access-softdevice-version-string
// Some Event IDs changed between firmware 1.0 (DAL <= 2.1.1) and 1.1 (DAL >= 2.2.0-rc6 and CODAL)
// MICROBIT_ID_DISPLAY/GESTURE/IO_P0/IO_P1/IO_P2
int major = 1;
int minor = 1;
char s[100];
ble_version_t bleInfo;
sd_ble_version_get(&bleInfo);
sprintf(s, "[based on DAL %s; mbed %d; softdeviceFWID %d] micro:bit Firmata",
DAL_VERSION, MBED_LIBRARY_VERSION, bleInfo.subversion_number);
send2Bytes(SYSEX_START, REPORT_FIRMWARE);
send2Bytes(major, minor); // firmware version (vs. Firmata protocol version)
sendStringData((const char *) s);
sendByte(SYSEX_END);
}

The "Board Version" property is only provided from the JS firmware library, which uses the USB ID to identify the board.
@JohnVidler we should consider if we also want to provide that info from the micro:bit firmata programme, as it could be included (only as V1 or V2, no need to query DAPLink to identify V2.0 or V2.2) in the "Firmware Version" string form.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants