Merge branch 'ble-profile' of https://github.com/lancaster-university/microbit-dal into ble-profile

master
Joe Finney 7 years ago
commit b00fc85548
  1. 4
      ble_issue_tracker.md
  2. BIN
      docs/BBC Micro Bit Bluetooth Profile V1.5.docx
  3. BIN
      docs/BBC Micro Bit Bluetooth Profile V1.6.docx
  4. 103
      docs/Report 1/BBC Micro Bit.html
  5. 51
      docs/Report 1/style.css
  6. 1227
      docs/Report 2/BBC Micro Bit.html
  7. 26
      docs/Report 2/style.css
  8. 1040
      docs/Report 3/BBC Micro Bit.html
  9. 26
      docs/Report 3/style.css
  10. 116
      docs/microbit pairing and over the air firmware updates.txt

@ -54,4 +54,8 @@ T6. Device Name in advertising packets includes the flash code so anyone could p
T7. Generic Access Service: Device Name and Appearance are mandatory and so need values
T8. Review advertising parameters: Advertising frequency seems quite low. This will make the discovery process slower and overall, both the pairing and FOTA processes a little slower. Are all three advertising channels in use or not? Thinking of a class room or event it would be best to use all three.
T9. Consider using directed advertising and white listing so that only the paired peer device can (re)connect to the micro:bit. I believe we are currently performing undirected advertising.... basically broadcasting. Directed advertising will address ADV packets to the paired peer device only. As things stand it seems to me that if some other person in the classroom just decides to connect to a micro:bit that is not theirs, they’ve effectively blocked all other use of the device.... a simple DOS attack.
### CLOSED:

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head><title>Bluetooth Developer Studio - Profile Report</title>
<head><title>Bluetooth Developer Studio - Level 1 Profile Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<script language="javascript" type="text/javascript" src="functions.js"></script>
@ -12,7 +12,7 @@
<div class="main_heading">
<div id="id_date" class="date">The Date</div>
<div class="heading_title">Bluetooth Developer Studio Level 1 Report</div>
<div class="heading_title">Bluetooth Developer Studio Level 1 Profile Report</div>
<div class="icon"><img src="BluetoothSIG.png"/></div>
</div>
@ -63,143 +63,160 @@
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Generic Access</p></div>
<div><p class="service_hdg_text1">Generic Access</p></div>
<div class="service_hdg_text2"><p>00001800-0000-1000-8000-00805F9B34FB</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A00 : Device Name</p></div>
<div class="characteristic_summary"><p>Device Name : 2A00</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A01 : Appearance</p></div>
<div class="characteristic_summary"><p>Appearance : 2A01</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Device Information</p></div>
<div><p class="service_hdg_text1">Device Information</p></div>
<div class="service_hdg_text2"><p>0000180A-0000-1000-8000-00805F9B34FB</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A24 : Model Number String</p></div>
<div class="characteristic_summary"><p>Model Number String : 2A24</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A25 : Serial Number String</p></div>
<div class="characteristic_summary"><p>Serial Number String : 2A25</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A27 : Hardware Revision String</p></div>
<div class="characteristic_summary"><p>Hardware Revision String : 2A27</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A26 : Firmware Revision String</p></div>
<div class="characteristic_summary"><p>Firmware Revision String : 2A26</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Accelerometer Service</p></div>
<div><p class="service_hdg_text1">Accelerometer Service</p></div>
<div class="service_hdg_text2"><p>0753</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>CA4B : Accelerometer Data</p></div>
<div class="characteristic_summary"><p>Accelerometer Data : E95DCA4B-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>FB24 : Accelerometer Period</p></div>
<div class="characteristic_summary"><p>Accelerometer Period : FB24</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Magnetometer Service</p></div>
<div><p class="service_hdg_text1">Magnetometer Service</p></div>
<div class="service_hdg_text2"><p>F2D8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>FB11 : Magnetometer Data</p></div>
<div class="characteristic_summary"><p>Magnetometer Data : FB11</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>386C : Magnetometer Period</p></div>
<div class="characteristic_summary"><p>Magnetometer Period : 386C</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>Magnetometer Bearing : E95D9715-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Battery Service</p></div>
<div><p class="service_hdg_text1">Temperature Service</p></div>
<div class="service_hdg_text2"><p>E95D6100-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>2A19 : Battery Level</p></div>
<div class="characteristic_summary"><p>Temperature : E95D8A38-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Button Service</p></div>
<div><p class="service_hdg_text1">Button Service</p></div>
<div class="service_hdg_text2"><p>9882</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>DA90 : Button 1 State</p></div>
<div class="characteristic_summary"><p>Button 1 State : E95DDA90-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95DDA91-251D-470A-A062-FA1922DFA9A8 : Button 2 State</p></div>
<div class="characteristic_summary"><p>Button 2 State : E95DDA91-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>LED Service</p></div>
<div><p class="service_hdg_text1">LED Service</p></div>
<div class="service_hdg_text2"><p>D91D</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95D7B77-251D-470A-A062-FA1922DFA9A8- : LED Matrix State</p></div>
<div class="characteristic_summary"><p>LED Matrix State : E95D7B77-251D-470A-A062-FA1922DFA9A8-</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>93EE : LED Text</p></div>
<div class="characteristic_summary"><p>LED Text : 93EE</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>0D2D : Scrolling Speed</p></div>
<div class="characteristic_summary"><p>Scrolling Speed : E95D0D2D-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>IO Pin Service</p></div>
<div><p class="service_hdg_text1">IO Pin Service</p></div>
<div class="service_hdg_text2"><p>127B</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>8D00 : IO Pin 0</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>C58C : IO Pin 1</p></div>
<div class="characteristic_summary"><p>Pin Data : E95D8D00-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>04F4 : IO Pin 2</p></div>
<div class="characteristic_summary"><p>Pin AD Configuration : E95D5899-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>5899 : IO Pin Configuration</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>60CF : IO Parallel Port</p></div>
<div class="characteristic_summary"><p>Pin IO Configuration : E95DB9FE-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>Event Service</p></div>
<div><p class="service_hdg_text1">Event Service</p></div>
<div class="service_hdg_text2"><p>93AF</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95DB84C-251D-470A-A062-FA1922DFA9A8 : MicroBit Requirements</p></div>
<div class="characteristic_summary"><p>MicroBit Requirements : E95DB84C-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95D9775-251D-470A-A062-FA1922DFA9A8- : Client Event</p></div>
<div class="characteristic_summary"><p>Client Event : E95D9775-251D-470A-A062-FA1922DFA9A8-</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95D5404-251D-470A-A062-FA1922DFA9A8- : MicroBit Event</p></div>
<div class="characteristic_summary"><p>MicroBit Event : E95D5404-251D-470A-A062-FA1922DFA9A8-</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>E95D23C4-251D-470A-A062-FA1922DFA9A8- : Client Requirements</p></div>
<div class="characteristic_summary"><p>Client Requirements : E95D23C4-251D-470A-A062-FA1922DFA9A8-</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div class="service_hdg_text"><p>DFU SERVICE</p></div>
<div><p class="service_hdg_text1">DFU CONTROL SERVICE</p></div>
<div class="service_hdg_text2"><p>E95D93B0-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>97109547E63A-442A-BF89-9D73-0413DC2F : DFU Control</p></div>
<div class="characteristic_summary"><p>DFU Control : E95D93B1-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>947B6934-64D1-4FAD-9BD0-CC9D6E9F3EA3 : DFU Flash Code</p></div>
<div class="characteristic_summary"><p>DFU Flash Code : E95D93B2-251D-470A-A062-FA1922DFA9A8</p></div>
</div>
<!-- Service Block -->
<div class="service_hdg">
<div><p class="service_hdg_text1">Generic Attribute</p></div>
<div class="service_hdg_text2"><p>1801</p></div>
</div>
<div class="characteristic_hdg">
<div class="characteristic_summary"><p>Service Changed : 2A05</p></div>
</div>
</div>

@ -42,25 +42,25 @@ p
}
.date {
width: 240px;
width: 100px;
line-height: 79px;
height: 79px;
float:left;
float:left;
}
.heading_title {
width: 800px;
width: 980px;
line-height: 79px;
height: 79px;
float:left;
text-align:center;
float:left;
text-align:center;
}
.icon {
width: 240px;
width: 200px;
line-height: 79px;
height: 79;
float:left;
height: 79;
float:left;
}
.section_hdg {
@ -96,19 +96,19 @@ p
}
.profile_label {
width: 300px;
font-size: 14px;
font-weight:bold;
width: 300px;
font-size: 14px;
font-weight:bold;
line-height: 33px;
height: 33px;
float:left;
float:left;
}
.profile_value {
font-size: 14px;
font-size: 14px;
line-height: 33px;
height: 33px;
float:left;
float:left;
}
.services_section_hdg {
@ -141,17 +141,28 @@ p
border-color: #FFFFFF;
}
.service_hdg_text {
font-size: 18px;
font-weight:bold;
color:#ffffff;
float:left;
width:1270px;
.service_hdg_text1 {
font-size: 18px;
font-weight:bold;
color:#ffffff;
float:left;
width:800px;
padding-left: 10px;
height:33px;
line-height: 33px;
background-color: #339933
}
.service_hdg_text2 {
font-size: 18px;
font-weight:bold;
color:#ffffff;
float:left;
width:470px;
height:33px;
line-height: 33px;
background-color: #339933
}
.service_item {
float:left;

File diff suppressed because it is too large Load Diff

@ -42,25 +42,25 @@ p
}
.date {
width: 240px;
width: 100px;
line-height: 79px;
height: 79px;
float:left;
float:left;
}
.heading_title {
width: 800px;
width: 980px;
line-height: 79px;
height: 79px;
float:left;
text-align:center;
float:left;
text-align:center;
}
.icon {
width: 240px;
width: 200px;
line-height: 79px;
height: 79;
float:left;
height: 79;
float:left;
}
.section_hdg {
@ -443,3 +443,13 @@ p
{
text-align: right;
}
.mandatory_property {
width: 935px;
font-size: 12px;
line-height: 33px;
height: 33px;
float:left;
font-weight:bold;
color:#ff0000;
}

File diff suppressed because it is too large Load Diff

@ -42,25 +42,25 @@ p
}
.date {
width: 240px;
width: 100px;
line-height: 79px;
height: 79px;
float:left;
float:left;
}
.heading_title {
width: 800px;
width: 980px;
line-height: 79px;
height: 79px;
float:left;
text-align:center;
float:left;
text-align:center;
}
.icon {
width: 240px;
width: 200px;
line-height: 79px;
height: 79;
float:left;
height: 79;
float:left;
}
.section_hdg {
@ -443,3 +443,13 @@ p
{
text-align: right;
}
.mandatory_property {
width: 935px;
font-size: 12px;
line-height: 33px;
height: 33px;
float:left;
font-weight:bold;
color:#ff0000;
}

@ -0,0 +1,116 @@
micro:bit pairing and over the air firmware updates
---------------------------------------------------
Version: 1.0
Date : 17th September 2015
Authors: Joe Finney (j.finney@lancaster.ac.uk) and Martin Woolley (mwoolley@bluetooth.com)
Terminology
-----------
FOTA: Firmware Over The Air (Nordic's name)
DFU: Device Firmware Update (the process of using FOTA to reprogram a nordic chip)
A Tale of Two DFU GATT Services
-------------------------------
The micro:bit possesses two BLE GATT services that are concerned with FOTA. Only one, however should be "visible" to a GATT client at any one time.
The first is the standard Nordic DFU service which has not been modified. See https://devzone.nordicsemi.com/documentation/nrf51/4.4.1/html/group__dfu__ble__service__spec.html for further details.
The Nordic DFU service is *not* visible to clients most of the time and this is by design.
The second service is the MicroBit DFU Service. This service *is* active/visible in general.
Whilst the Nordic DFU service may not be visible to GATT clients most of the time, it is always resident in the top 20K or so of FLASH program memory.
Flashing the micro:bit OTA involves rebooting the micro:bit in a special way which results in the Nordic boot loader being entered and this brings up the Nordic DFU service instead of the MicroBit DFU service.
The MicroBit DFU Control Service
--------------------------------
This service has two characteristics:
ControlPoint (unsigned 32 bits)
FlashCode (unsigned 32 bits)
The FlashCode characteristic is a primitive used for authentication. Every micro:bit has a unique code (derived from its unique serial ID).
Rebooting into the Nordic Bootloader
------------------------------------
As described, to flash the device OTA we must first instruct the micro:bit to reboot into the Nordic boot loader to bring up the Nordic DFU service which will then process firmware OTA updates from the client.
To reboot the micro:bit into the Nordic bootloader, two things need to happen:
1) The FlashCode characteristic has to be written with the correct secret key
2) The ControlPoint characteristic has to be written with a value of 0x01
At this point the micro:bit should automatically reboot and bring up the Nordic DFU service.
Note that the user doesn't have to press the reboot button. Reboot takes place automatically.
Obtaining and Using the flash code
----------------------------------
To be able to initiate the reboot into the Nordic boot loader therefore, the client must be in possession of the flash code. This gives us two scenarios to consider and essentially gives us a two stage process of which stage 1 is optional.
Either (1) the client does not possess the flash code and therefore must somehow obtain it or (2) it already has it from some previous interaction with the micro:bit and has cached it.
Stage 1 - Client Does Not Possess flash code
------------------------------------------
MicroBit has a special mode of operation or state known currently as "Blue Zone". The device enters this state when rebooted by pressing the reset button whilst at the same time holding down both buttons A and B. The device indicates itself to be in the Blue Zone mode by scrolling "BLUEZONE" across the display.
Once in the Blue Zone state, the MicroBit DFU Service also enables another command via the ControlPoint characteristic known as 'REQUEST_FLASHCODE' which is represented by a value of 0x02.
To obtain the flash code the client should enable GATT notifications on the FlashCode characteristic and then write 0x02 to the Control characteristic. The micro:bit will respond by displaying "PAIR?" on the LED display.
The user must now press Button A on the micro:bit. This is an "authorization to proceed" step and results in the client receiving the flash code value as a GATT notification which it can then store for use in the second stage and any subsequent execution of stage 2 without the need to execute the stage 1 procedure.
Stage 2 - Client in Possession of flash code
-------------------------------------------
If a device already knows the flashcode, it can connect any time and initiate rebooting into "Nordic DFU mode" by writing the FlashCode characteristic with the previously cached value and then writing the 'ENTER NORDIC BOOTLOADER' command (0x01) to the Control characteristic. The device will reboot into the stock nordic bootloader and then the attached device can interact with that to reflash the device. The device does NOT need to be in Blue Zone mode.
Issues for Client Application Developers
----------------------------------------
It should be noted that rebooting into "Nordic DFU Mode" will break any existing BLE connection between the client device and micro:bit. The client will therefore need to re-establish its connection to the MicroBit before being able to proceed with FOTA and discover and then make use of the Nordic DFU service.
More About flash code
---------------------
Each micro:bit has a secret key (flash code) derived from a 128 bit serial number that's etched onto every nordic nrf51822 during manufacture. All chips are different. Half of the serial number is hashed to generate the flash code.
micro:bit human identifiers
---------------------------
In addition to a secret key (flash code) used in the FOTA process as described, micro:bits have a human readable identifier (public name) which is included in BLE advertising packets and can be discovered and used by human users during any process, including FOTA, where there needs to be a confirmation that the device which is to be interacted with is the one the human intends to interact with. In the context of this document, "interact with" means update using the FOTA procedure.
The public name is generated by the run time from the other half of the Nordic serial number. Humans can discover the public name of a device by switching into BLUEZONE mode. The public name is displayed in a coded but simple graphical form on the LED display and can then be entered into (say) a mobile application screen to verify the device to be updated is the one we mean to update.
Summary of the FOTA Process
---------------------------
Case 1 - Client does not know the flash code
--------------------------------------------
a) User switches micro:bit into BLUEZONE mode - must do this first since it involves a reboot and will therefore disconnect the client
b) Client connects to micro:bit
c) Client discovers MicroBit DFU service
d) Client enables notifications on the MicroBit DFU Service::FlashCode characteristic
e) Client writes 0x02 to the MicroBit DFU Service::Control characteristic
f) micro:bit displays "PAIR?" on the LED display
g) User presses Button A
h) Client should receive FlashCode notification containing the flash code value
We then proceed by following the steps for Case 2
Case 2 - Client is in Possession of flash code
----------------------------------------------
i) Client writes the cached flash code value to the MicroBit DFU Service::FlashCode characteristic
Note: this is optional if following directly on from Case 1 as the FlashCode characterisitic would have been written locally by the micro:bit runtime
j) Client writes 0x01 to the MicroBit DFU Service::Control characteristic. This should cause the micro:bit to reboot into the Nordic boot loader. The Nordic DFU GATT service should become active and visible to GATT clients that subsequently connect and the MicroBit DFU Service should disappear.
k) Client reconnects to micro:bit and proceeds with FOTA per the Nordic documentation on using their DFU service.
UUIDs
-----
MicroBit DFU Service : E95D93B0-251D-470A-A062-FA1922DFA9A8
Control Characteristic : E95D93B1-251D-470A-A062-FA1922DFA9A8
FlashCode Characteristic: E95D93B2-251D-470A-A062-FA1922DFA9A8
Nordic DFU Service : 00001530-1212-EFDE-1523-785FEABCD123
Loading…
Cancel
Save