Commit Graph

224 Commits (9218e647e0868ae68608aab18b53c6c417fe5240)

Author SHA1 Message Date
Joe Finney 9218e647e0 microbit: Refactor of periodc timer callbacks
- Factored periodic timer funcitonality out of fiber scheduler and into a new SystemTimer module module.
- Enapsulated "ticks" variable within SystemTimer module, with accessor funciton.
- Added accessor/mutator functions to get and set the tick period.
- Added a class wrapper to permit periodic callbacks to both C and C++
  functions.
- Updated all references in microbit-dal to use this refactored API.
2016-03-10 17:01:17 +00:00
Joe Finney 8a06a4e3be microbit: Introduced microbitDevice.[h,cpp] to hold platform specific low
level functionality
2016-03-10 12:02:17 +00:00
Joe Finney 000351b599 Factored idle/interrupt callback events out of MicroBit.cpp 2016-03-10 12:02:15 +00:00
Joe Finney 5231b5f526 First cut at a build without a global MicroBit singleton 2016-03-10 12:02:13 +00:00
Joe Finney b7f260074c Merge branch 'servo-fix' 2016-03-08 19:14:42 +00:00
James Devine 77e7fdc71f microbit-dal: updated comments to reflect changes to the constants.
The comments for the setServoValue member function have been updated to reflect changes in the default Range and Center from the previous commit.
2016-03-07 13:59:24 +00:00
Joe Finney 27ffb0b91c Merge branch 'ram-efficient-multibutton' 2016-02-26 16:33:55 +00:00
Joe Finney 2f4e542fee Merge branch 'radio-recv-bug-94' 2016-02-26 16:33:28 +00:00
Joe Finney caa4924336 microbit: Added validation case in MicroBitRadioDatagram::recv()
Introduced missed validation case in MicroBitRadioDatagram::recv().
Added PacketBuffer::EmptyPacket as a NULL reference.
2016-02-26 16:27:13 +00:00
James Devine e115e5af8d microbit-dal: BUGFIX maintain cccd state when service changed fails
Previously, we would rely on service changed to complete successfully
to signify a successful cccd state restore.

However, android doesn’t register for service_changed notifications,
and as a result sd_ble_gatts_service_changed always returns an error.

This meant that cccds would be erased when the complete flag was not
one, which would have been all the time.
2016-02-26 15:45:15 +00:00
Joe Finney d3922d21e9 microbit: Aligning MicroBitButton and MicroBitMultiButton APIs
Updates to MicroBitButton and MicroBitMultiButton to align the API through
which CLICK events are filtered. Also, updates to the mechanism through which
buttonA and buttonB CLICK/LONG_CLICK events are filtered by
MicroBitMultiButotn to reduce RAM footprint.

No changes to external behaviour of these classes.
2016-02-26 15:42:57 +00:00
James Devine 5505fc6687 microbit-dal: fixed android waiting after DFU mode initiated
This commit introduces a wait_ms before entering DFU mode to allow soft
device to communicate to an android handset that the current connection
should be terminated.
2016-02-26 15:24:35 +00:00
James Devine 3019e34dd9 microbit: BLE fixes
This commit addresses a number of outstanding issues:

* whitelisting behaviour, form the nrf51-sdk, where an address and an
irk were added to the whitelist

* bond management bugs, from the nrf51-sdk, where one device would
replace another.

closes #57, closes #56, closes #58, closes #59, closes #44, closes #60
2016-02-26 15:21:30 +00:00
Joe Finney 6900bd8415 microbit: BUGFIX supporting repairing of the same device #2829
Re-pairing the same BLE device under SoftDevice 8.0 Nordic SDK 10 appears to
add a second entry to the bonding table when private resolvable addresses are
used by the central device. This adversely affects whitelisting, as only the
first added matching entry will be succesfully added to the whitelist. i.e. A
central device will no longer be able to connect to a micro:bit after pairing
a second time as the older bond will take prescedence.

Althoguh reported to Nordic, a long term fix is not immediately forthcoming.
This patch applies a workaround, by simply reversing the order of the
whitelist before use. As the list is maintained in the order of insertion,
reversing the list guarantees that the entry added to the whitelist will be
the most recently bonded one for any given peer.
2016-02-12 18:54:19 +00:00
Joe Finney 30ec004dc7 WIP: Working IOS pairing with service changed notification
n.b. changes to microBitConfig may need reverting
2016-02-11 21:58:07 +00:00
Joe Finney 3b25fe81ac WIP: Updates to IOS support 2016-02-10 18:12:31 +00:00
Joe Finney a61113f950 Merge branch 'rssi' 2016-02-09 01:09:36 +00:00
Joe Finney 2f6d405e81 microbit: Introduced managed type for packet buffers.
Introduce PacketBuffer as a mutable reference counted type Radio operations
Updated send() and recv() to use PacketBuffer rather than ManagedString
2016-02-09 01:04:57 +00:00
Joe Finney eca55e279d Merge pull request #93 from lancaster-university/pin-updates
Pin updates
2016-02-08 16:55:34 +00:00
Joe Finney 72d14be1d4 microbit: Added ability to define how long a device will remain in panic
before resetting

Requests made for an optional timeout function to define the period of time in
which the device will remain in a panic state. This patch introduces a
setErrorTimeout() method with this functionality.
2016-02-08 14:37:43 +00:00
Joe Finney c1ae235ebd microbit: On demand suppression on button click events.
MicroBitMultiButton now provides an indication to MicroBitButton instances when an application is actively utilising that button as part of a button group. This
permits that MicroBitButton to more accurately filter events, and provide a
consistent abstraction.

More specifically, this patch:

 - Extends the MessageBus functionality to indicate when listeners are
   attached to events. This allows components to perform on demand tailoring
   of their behaviour.

 - Extends MicroBitMultiButton to indicate to relevant MicroBitButton
   instances when they are part of a button group.

 - Extends MicroBitButton to perform filtering of button events dynamically
   (rather than statically) when part of a MultiButton group.

 - Code cleanup of static functions that are more cleanly implemented as
   methods.
2016-02-08 13:31:48 +00:00
Joe Finney dda8598513 microbit: Added support for configurable GATT table size
Updates to MicroBitConfig options and initialisaiton code of the BLE stack to
allow Soft Device's GATT table to be of a given size. If this size is smaller
then the default, the runtime will reclaim that that memory as heap storage.
2016-02-08 00:57:20 +00:00
Joe Finney 8e3e061bec microbit: BUGFIX Fixed incorrect bond table entry count
The nordic implementation of the mbed whitelist API introduces entries into
the table that are not bonds. This patch corrects an assumption in
microbit-dal that the number of entries in the bond table table corellates
with the number of bonds.
2016-02-07 19:59:56 +00:00
Joe Finney 2e6459404b microbit: Added configuration to enable/disable BLE security
The BLE security options mandated for child protection can be highly
detrimental to the development process for new BLE services. This patch
introduces a configuration option to disable BLE security for this purpose.
Default BLE security settings remain unchanged.
2016-02-06 23:34:10 +00:00
James Devine e34971902f microbit: swapped capabilities for changes to pin mappings
In the previous commit, we swapped 2 pins around, but the capabilities
for those pins were not updated.

This commit updates those capabilities.
2016-02-05 14:02:08 +00:00
James Devine af13c940c1 microbit: add RSSI to MicroBitRadio
Added the ability to capture the RSSI value, and an accessor and
mutator for the last received RSSI value.
2016-02-04 03:45:57 +00:00
James Devine ffc217e7ac microbit: fixed formatting issues in MicroBitRadio
Removed trailing whitespace.
2016-02-04 03:44:25 +00:00
Joe Finney 9d039fd9be microbit: BUGFIX Corrected length calculation for validation case
Incorreclty calculated payload bug also addressed here.
2016-02-03 14:41:45 +00:00
Joe Finney 5cb265c158 microbit: BUGFIX: Length field of datagram receive now correct
Datagram receive code incorrectly calculated the payload length, resulting in
packets being delivered to applications that were two bytes shorter than they
should be.
2016-02-03 14:35:12 +00:00
James Devine 41447b634d Merge pull request #89 from lancaster-university/ble-ccccd-persist
Basic Persistent Storage
2016-02-02 21:50:33 +00:00
James Devine 23d56edbdd microbit: integrated MicroBitStorage with MicroBitCompass
This commit introduces persistent storage for the compass between
device resets.

setCalibration now also stores the data in FLASH if it differs from
what it contains.

In source/MicroBitSuperMain.cpp, the data is restored if there is
persistent data available that is non-zero.

(i.e. x, y and z are NOT zero).

This ensures that users can code without interference from persistent
storage.
2016-02-02 21:24:40 +00:00
James Devine 4c9f32d79a microbit: added debug to MicroBitStorage
Added debug to make testing simpler and faster.
2016-02-02 21:24:40 +00:00
Joe Finney 5e7334b0bf microbit: integrated persistent storage for CCCD data.
There is an issue (https://github.com/bbc/microbit-extras/issues/2755)
whereby CCCD data is required to be persisted through device resets.

This commit integrates the new MicroBitStorage class, and persistently
stores this information in flash.

P.S. what a long night!
2016-02-02 21:24:40 +00:00
Joe Finney d1d78b9b35 microbit: added MicroBitStorage for Persistent data
Integrated simple 1K block buffer to host small amount of persistent
data and a 1K FLASH memory block located immediately below the FOTA/DFU
bootloader and APPDATA region that intended to hold core configuration
information, such as:

* BLE bonding information.
* Compass Calibration data.
* Thermometer Calibration data.

The block is resident at 0x0003B400 - 0x0003B800.
2016-02-02 21:22:49 +00:00
James Devine f546da66e8 microbit: improved appearance of greyscale
The impact of the pixels at lower values was  not distinct enough
this commit adds a blocking wait for the first two timings for
greyscale.

Additionally, this commit  modifies the timings const array to
take into account the time taken for renderGreyscale to execute.
2016-02-02 17:05:59 +00:00
James Devine 3596f3d842 microbit: update to greyscale mode
Floats were used as timings for the renderTimer in MicroBitDisplay.
Now timings are in us, and a direct called to renderTimer.attach_us
is now used.
2016-02-02 16:36:09 +00:00
James Devine 4cefd55ef5 microbit: updated the dal to use a higher resolution ticker.
Previously the DAL relied upon an implementation of a timer that
was very imprecise and lacked resolution, this commit adds a reference
to a frozen repo with us_ticker.c modifications, so that a higher resolution
timer is utilised.

This fixes #13 (finally), and also fixes lower brightness levels when using
DISPLAY_MODE_BLACK_AND_WHITE to not cause a device lockup.
2016-02-02 16:21:28 +00:00
James Devine 3fa9bb09c2 microbit: fixed an off by 10 bug
Missed a zero in a previous commit, that caused a system lockup due to
a missed timer event.

This commit also changes the minimum display brightness to 4, to also
minimise another feature that needs fixing in the future, where the
timer does not interrupt in the expected time frame.
2016-02-02 01:13:39 +00:00
James Devine a27b2314be microbit: modified the range of read() MicroBitLightSensor
Previously the range of MicrobitLightSensor read() was 0 - 100,
this didn't align with other APIs.

The new range is 0-255 which aligns with display brightness to give
a more consistent overall API.
2016-02-01 23:58:33 +00:00
Joe Finney e983b80b0b Merge branch 'master' into ble-bondtablepurge 2016-02-01 22:50:05 +00:00
Joe Finney e7132b0d13 microbit: Change to BLE bonding table replacement policy
Previous revisions of microbit-dal would handle the case of a bonding request
when the bond table was full by attempting to purge the bonding table on
demand. This suffered two flaws:

 1) Nordic's device manager does not support the purging of the bonding table
while a connection is active (including a pairing request).

 2) Some devices (e.g. Android 4.4.2 take two entries in the bonding table
when paired), thus making predictions of how 'full' the table is challenging.

This patch employs a simpler replacement policy. The maximum size of the bond
table has been increased to 6 (from 4). However, if the bond table contains 4
or more entries when entering pairing mode it will be purged in advance of any
pairing requetss being initiated.
2016-02-01 22:30:03 +00:00
James Devine 97c49d3279 Merge pull request #87 from lancaster-university/broadcast-radio
Adding Multicast peer-to-peer radio support MicroBitRadio!
2016-02-01 21:50:54 +00:00
James Devine 004b701419 Merge pull request #86 from lancaster-university/light-sensor
Adding MicroBitLightSensor to the DAL
2016-02-01 21:50:22 +00:00
James Devine 8150b2ac67 microbit: modified as per suggestions
* This commit fixes an exposed member variable
  that was not intended to be public 'tickPeriod'

* normalised the light level to return values between 0 - 100
2016-02-01 21:46:15 +00:00
Joe Finney 9026ca6e98 microbit: Optimisation of BLE mutex.
The BLE stack locks out the CPU for long periods of time when necessary. This
can be alleviated by eans of a flag that release the CPU between radio events.
(BLE_COMMON_OPT_RADIO_CPU_MUTEX).

This can cause issues from applications with tighter timing requirements.
This patch only enables this MUTEX when a BLE connection is active, rather
than automatically at startup. Therefore, application that do not actively use
BLE will not suffer this penalty.
2016-02-01 19:25:07 +00:00
Joe Finney 6838b38fc1 microbit: Remove redundant characteristics in BLE DeviceInformationService
The MANUFACTURER and HARDWARE_REVISION fields from this standard service have
been removed, as they carried no useful information.
2016-02-01 18:59:48 +00:00
Joe Finney 8bec31fe76 microbit: Additional validation on MicroBitRadio methods
MicroBitRadio methods that touch internal RADIO registers now ensure that
the BLE stack is not running before changing such registers.
2016-02-01 18:19:02 +00:00
Joe Finney d7aa95e867 microbit: minor updates to consistently use the MICROBIT_RADIO_HEADER_SIZE constant 2016-02-01 18:05:02 +00:00
Joe Finney 12c9ed246a microbit: Whitespace fixes 2016-02-01 17:54:33 +00:00
Joe Finney 420a73673d microbit: rename of MicroBitRadioEvent methods to align with MessageBus naming conventions. 2016-02-01 17:43:17 +00:00