Commit Graph

347 Commits

Author SHA1 Message Date
James Devine 3b435c0d30 microbit-dal: BUGFIX in MicroBitStorage
There was an off by one error when storing the key of the key value
pair, where the null terminator was dropped. This would mean that if
the returned key of the KeyValuePair were used, it would cause a number
of issues.

Another issue raised was the copying a random 48 bytes from memory
regardless of the position of memory in the stack. If the memory was
smaller than 48 bytes, and existed at the top of the stack, this could
have dire consequences. As a result, MicroBitStorage now accepts a size
parameter which informs the number of bytes to be copied into flash.

#130
2016-04-23 19:58:29 +01:00
James Devine 0048a9ac8e microbit-dal: fixed UART service buffer sizing, and re-enabled config options for default services
There was a perspective mismatch with the UART service, where the
actual buffer size given in the constructor, did not reflect the size
of the user buffer that was available to the application. This was not
documented, and hence cause confusion. The patch applied in this
commit, increments the given buffer sizes by one, so that the
application buffer has the available size given in the constructor.

Additionally, some configuration options were lost during the component
refactor, these have now been restored.
2016-04-19 15:41:51 +01:00
James Devine c844e6104a microbit-dal: fixed a warning in MicroBitBLEManager.cpp 2016-04-18 15:25:30 +01:00
James Devine 9914a98050 Merge pull request #120 from bluetooth-mdw/master
Added BLE connect/disconnect events and fixed bug in MagnetometerService.cpp

Possible fix for #114
2016-04-15 14:12:19 +01:00
Martin Woolley ae2c351d56 Fixed dodgy comment 2016-04-15 14:00:27 +01:00
Martin Woolley 051abec174 Changed BLE connection event constant names to match LU groovy naming convention 2016-04-15 13:56:23 +01:00
James Devine 7cf98c2290 microbit-dal: patch for fiber_wake_on_event
fiber_wake_on_event used to crash after forking a FOB fiber.

It would attempt to obtain a new fiber context, and would place it on the wait queue.
Then when that fiber was paged in, the context of that fiber would not have been
initialised, as the function presumed schedule would be called immediately after
fiber initialisation.

This patch catches that edge case.
2016-04-15 13:40:41 +01:00
Martin Woolley 87f7233a84 Added BLE connect/disconnect events and fixed bug in MagnetometerService re: bearing characteristic 2016-04-15 13:38:24 +01:00
Joe Finney 94e2c66185 microbit: Additional optional autoClear parameter to MicroBitDisplay::animate
The MicroBitDisplay::animate() and MicroBitDisplayAnimateAsync() function both
assumed that the display should be cleared once the requested animation was
complete.

This patch allows the user to control this funcitonality through an
addiitonal, optional boolean parameter to the animate() and animateAsync()
functions.
2016-04-15 12:37:09 +01:00
Joe Finney 82ed22d1b2 microbit: MicroBitRadio group ID now persists enable/disable operations
MicroBitradio::enable() would reset the group ID of the radio to the default
value on each call. Updated to do this only once at object initialisation time.
2016-04-15 11:33:53 +01:00
Joe Finney a82254b9e2 microbit: MicroBitRadio support for multiple enable/disable operations
MicroBitRadio::disable neglected to reset the internal status flag indicating
that the radio has bene initialised, which prevent subsequent enable()
operations completing properly.
2016-04-15 10:47:40 +01:00
James Devine c39a6b3b36 microbit-dal: added default assembler file for armcc for mbed 2.0 compatability 2016-04-08 11:43:30 +01:00
James Devine 6702a5f51a microbit-dal: Zero initialised C99 compatible buffers 2016-04-07 17:45:32 +01:00
James Devine cdeabd26c6 microbit-dal: patched armcc incompatibilities. 2016-04-07 16:57:16 +01:00
Joe Finney 72d2d2b10a microbit: MessageBus now treats all listeners as MESSAGE_BUS_LISTENER_IMMEDIATE if no scheduler is present
The default THREADING_MODE for event handlers is typically set to run through
the scheduler. However, it is possible to create and operate a MessageBus without the scheduler being initialised.

This patch changes the behaviour of the MessageBus to treat all registered
listeners as MESSAGE_BUS_LISTENER_IMMEDIATE (i.e. directly called) if no
scheduler is present. This default allows for a more user friendly experience
in this case.
2016-04-07 11:55:31 +01:00
James Devine 63a8ae81ec microbit-dal: Fixed multiline note which had artefacts in microbit-docs. 2016-04-07 11:32:13 +01:00
James Devine 387c4f18e4 microbit-dal: fixed C99 incompatible array initialisation.
Removed { 0 }; from all buffer initialisations.

Also replaced all uses of Serial::IrqType:: with IrqType::
2016-04-07 11:31:33 +01:00
James Devine 55cb919987 microbit-dal: Added MIT license information. 2016-04-06 17:07:03 +01:00
James Devine ea91e0281a microbit-dal: more doxygen documentation updates. 2016-04-05 23:41:32 +01:00
James Devine d6310db9aa microbit-dal: further updates to doxygen style comments used for documentation 2016-04-04 02:01:15 +01:00
James Devine 2f7d361ed5 microbit-dal: updates to doxygen style comments used for documentation generation. 2016-03-29 08:02:57 +01:00
Matthew Else 2664003d23 Fix debugging in UART service 2016-03-27 10:41:47 +01:00
Joe Finney d6079d45d2 microbit: Updated SERIAL_DEBUG symbol to a pointer
Moved the global SERIAL_DEBUG symbol from a reference to a pointer. This is to
enable late binding of a debug channel.
2016-03-26 20:31:29 +00:00
James Devine b5c8714ea3 microbit: added BLE UART service
Added a serial implementation for bluetooth, needs a review at a later date.
2016-03-26 19:53:28 +00:00
James Devine 728604423f microbit: refactored event codes used by a shared listener "MICROBIT_ID_NOTIFY"
There was no common place to track event codes used in Events intended
for the shared channel using the ID MICROBIT_ID_NOTIFY. This commit
adds a common place for these Event codes.
2016-03-26 19:39:05 +00:00
James Devine 776131e4cb microbit: BUGFIX for MicroBitStorage
There was a bug with Bluetooth pairing. If a user were to bond with the
micro:bit, and the KeyValueStore region had not been configured, the
class would attempt to write to flash in interrupt context, which
conflicted with soft device.

The fix is to do this initialisation in the constructor for
MicroBitStorage.
2016-03-26 14:06:14 +00:00
Joe Finney 3efd76e9d4 microbit: Update to MicroBitMultiButton contructor signature
Changed ordering of parameters to promote consistency with other components.
2016-03-26 11:58:36 +00:00
Joe Finney 4f31ffa9d4 microbit; Added default case in MessageBus.cpp when scheduler is inactive
Added condition into MicroBitMessageBus::process(), such that all event
listeners are diretly invoked if no scheduler is present.

This provides a best effort base case for builds running without a scheduler.
2016-03-24 23:46:17 +00:00
Joe Finney 0a1a9c7865 microbit: Consistency change in scheduler_init()
Updated parameter of scheduler_init() to accpet a reference to an EventModel,
rather than a pointer. This is simply to promote consistency with the other
components.
2016-03-24 23:30:17 +00:00
James Devine f35c4b359e microbit: MicroBitLightSensor startSensing is now public! 2016-03-24 16:05:11 +00:00
Joe Finney 06c3c95609 microbit: Restructure of repo
- Introduction of core, drivers, types and bluetooth folders in source and inc
- Added all inc subfolfers to the search path
- Removed MicroBit.cpp and MicroBit.h (yay!)
2016-03-24 14:00:11 +00:00
Joe Finney f5f983dbdd microbit: Added explicit support for printing characters in MicroBitDisplay
The C type system connaot easily distinguish integer literals from character
literals. To promote a simpler API, the print() overload for numeric values
has been replaced with an explicit printChar() method.

Print operation on single byte strings have been ammended to act consistently
with printing a single digit.
2016-03-24 11:40:18 +00:00
James Devine 03a5353cc0 microbit: Added MicroBitSerial default mode config option, and modified overload for send(char)
MicroBitSerial now uses a #define in MicroBitConfig.h to configure the default mode
for send and read calls.

send(char c, MicroBitSerialMode mode) has now been renamed to sendChar(char c, MicroBitSerialMode mode),
which means if users want to send an integer as a char, they have to do so explicitly.
2016-03-24 11:17:23 +00:00
Joe Finney cc2beb02c6 microbit: Added overload to allow direct send/receive of strings via
MicroBitRadioDatagram

 - Added constructor into managedString to allow conversion from PcketBuffer
 - Added overload of MicroBitRadioDatagram::send() to accpet a string
2016-03-24 10:33:05 +00:00
James Devine a73a6b6560 microbit: Added additional validation check for fiber_wait_for_event 2016-03-24 01:45:56 +00:00
James Devine 79a13c7edf Merge branch 'component-refactor' of https://github.com/lancaster-university/microbit-dal into component-refactor 2016-03-24 00:45:33 +00:00
James Devine a512afb1b3 microbit: MicroBitSerial memory optimisation
Previously, MicroBitSerial inherited from Serial, which had a large
memory overhead.

n.b. This is due to a setbuf call in the underlying stdio library that
mallocs a massive struct, which is largely unused.

MicroBitSerial now inherits from RawSerial, which doesn’t use any
setbuf calls, thus reducing the static memory overhead of
MicroBitSerial to 8 bytes (448 bytes), when unused.

The definition for SERIAL_DEBUG in MicroBitConfig has now been updated
to use RawSerial instead of Serial.
2016-03-24 00:43:10 +00:00
James Devine 12c84395d3 microbit: Added fiber_wake_on_event to MicroBitFiber[.h,.cpp]
Added a new call fiber_wake_on_event which does not call schedule. This
means that execution continues after the context has been set until the
next use of schedule (i.e. fiber_sleep).
2016-03-24 00:32:41 +00:00
Joe Finney 91cd6d2a08 microbit: Updated enable/disable functions in MicroBitDisplay to free pin
resources cleanly.
2016-03-24 00:18:32 +00:00
Joe Finney fea0f720df microbit: Removed uncessary #includes in MicroBitDisplay 2016-03-23 21:33:02 +00:00
Joe Finney 10298934da microbit: Generalised MicrobitDisplay to be mbed compliant
Removed references to direct nrf51 sdk calls, in favour of the mbed
PortOut class, which provides equivalent functionality whilst remaining
platform agnostic.
2016-03-23 21:25:51 +00:00
Joe Finney 31b7eb487f microbit: Factored repurposeable functionality out of MicroBit.cpp
- moved all device specific utility funcitons into MicroBitDevice.cpp
 - moved compass calibration funcitonality into a dedicated class
 - moved panic() from MicroBitDisplay into MicroBitDevice
 - introduced inline utility functions into MicroBit to promote a degree of
   backward compatibility and easy of use.
 - updated panic() to use platform agnostic mbed calls.
2016-03-23 19:30:15 +00:00
Joe Finney 6b6c83092a microbit: Added validation check on MicroBit::init()
Added simple validation check to protect against accidental re-initialisation.
2016-03-22 19:49:14 +00:00
Joe Finney 34856a6942 microbit: refactor of component constructors
- Updates to ordering and default values for component constructors to improve
consistency, and to common default default values for parameters where
applicable.

- Updates to MiroBitDisplay MatrixMap to record physical geometry in addition
to logical geometry of LED matrix display layouts. This removes the need for
explicit (and unecessary) definition of display size by the user.
2016-03-22 19:36:23 +00:00
James Devine 38b6c8ff6c microbit: corrected includes in MicroBitSerial.cpp 2016-03-21 13:37:08 +00:00
James Devine 8bd34edfd1 microbit: updated MicroBitStorage to use our new MICROBIT_NO_DATA error code
MicroBitStorage previously used MICROBIT_NOT_SUPPORTED if the given key was not found
during a remove call, it now returns MICROBIT_NO_DATA.
2016-03-21 13:31:14 +00:00
James Devine 937395f0f4 microbit: MicroBitSerial redesign
This implementation uses a circular buffer for both transmission and reception of data.

There are a number of new methods:

	* redirect - which dynamically redirects the output of the serial module
	* eventOn and eventAfter - which fire events based on delimeters, or x number of characters.
	* operations on the circular buffers.

A main difference is the ability to select the mode you want to perform your operation in:

	* ASYNC - reads directly from the circular buffer, returning immediately.
	* SYNC_SPINWAIT - spins whilst reading from the circular buffer.
	* SYNC_SLEEP - blocks the current fiber, but doesn't lock out the processor,
		       whilst reading from the circular buffer.

This should support a wide variety of operations. To see more specific details of the different methods,
it is advised to read the doxygen comments for each method.
2016-03-21 13:27:20 +00:00
James Devine 174fa29c81 microbit: fixed overload ambiguity in MicroBitStorage
MicroBitStorage accepts both ManagedString and char * variants, this
caused ambiguity at compile time, and meant that the ManagedString
variant was never selected when given character literals. This meant
that the only way to access the ManagedString variant, was to explicitly
wrap the character literals.

This applies to:
	* put
	* get
	* remove

The fix was to apply a const prefix to all member functions accepting
a char *.
2016-03-20 18:28:48 +00:00
James Devine 468d7e24c5 microbit: MicroBitThermometer lazy addition to fiber components
Previously, MicroBitThermometer was always added to fiber_components,
even in the case where it wasn't actually in use.

This commit introduces a similar behaviour to that introduced to the compass
and accelerometer classes in previous commits, where these components
are only added to fiber_components when in use.

Similarly, MicroBitThermometer now has an exposed updateSample() member
function that can be used to manually drive temperature updates, if
the fiber scheduler is not in use.
2016-03-20 17:05:32 +00:00
James Devine aca1c24a24 microbit: added calibration and persistence to MicroBitThermometer
MicroBitThermometer now persists data using MicroBitStorage. An instance
of MicroBitStorage must be given at construction, if data is required to
be persisted.

The ability to calibrate the thermometer using an offset has been added
as well, produces the data that is then persisted by MicroBitStorage.
2016-03-20 17:05:31 +00:00
James Devine 4988fd4ea7 microbit: moved MicroBitStorage to a Key Value Store
MicroBitStorage used to rely on a static struct as a memory
map when writing to flash "MicroBitConfigBlock", this solution
was constraining, and not fit for general purpose.

Whilst modularising the runtime, a cyclic dependency between
MicroBitStorage and MicroBitCompass was discovered, which meant
these two class could not be fully decoupled.

This version of MicroBitStorage is a Key Value Store, and allows
3 base operations:

	* put - add a new KeyValuePair to flash
	* get - retreive a KeyValuePair from flash
	* remove - delete a KeyValuePair from flash

An instance of MicroBitStorage is also now a part of uBit (uBit.storage)
and this is now passed as a parameter to the constructors of BLEManager
and compass, both of which require the persistence of data.

There are also overloads for the constructors of MicroBitBLEManager
and MicroBitCompass, which do not require an instance of
MicroBitStorage to be passed.
2016-03-20 17:05:31 +00:00
Joe Finney b9e8dc979b microbit: Updated MicroBitSystemTimer to use dynamically allocated Ticker
MicroBitSystemTimer uses a statically allocated Ticker object as a timer
source. This both incurs a static memory overhead when the timer is never
initialised, and causes temporal dependencies for applicaitons that
initialise the timer from within a static context.

This patch simply changes the implementaiton of MicroBitSystemTimer to
dynamically allocate the Ticker object on the heap when it is first used to
address both of these issues.

The patch also cleans up an unecessary call to system_timer_init() in
MicroBit::init().
2016-03-19 22:46:09 +00:00
Joe Finney 65affa35a8 microbit: Introduced demand activation of system_timer
system_timer updated to bring up the timer with the default configured period
automatically when a component registers for a callback.
2016-03-19 02:06:10 +00:00
Joe Finney 78ed31961c microbit: BUGFIX blocking display functions not terminating when scheduler
disabled

Calls to synchronous/blocking display animations, e.g. scroll("HELLO!"), did
not terminate correctly due to over optimisation in the
MicroBitDisplay::FiberWait() method.

Also corrected potential deadlock caused by an animation being explicitly
terminated.
2016-03-19 01:48:23 +00:00
Joe Finney 1dce004f10 microbit: Updates to enable BLE services to utilise the EventModel interface
- Updated all BLE services from the standard profile to us the defualt registered event model
- Updates to trigger calibration (when necessary) when BLE MagnetometerService is activated
- Updates to compass calibration algorithm to be non blocking (reduce unecessary fiber stack overhead)
- Cleanup of unused/out of date MicroBitConfig BLE options
2016-03-19 00:46:34 +00:00
Joe Finney 398f054956 microbit: Refactor of MicroBitHeap Allocator
- Cleanup of MicroBitHeapAllocator related CONFIG options to add clarity
 - Refactor of MicroBitHeapAllocator to provide more control over heap
   initialisation.
 - Creation of SERIAL_DEBUG macro in MicroBitConfig to permite external
   definition of a debug console.
 - Added validation cases to MicroBitFiber to protect against calls to fiber
   operations when the scheduler has not been initialised.
2016-03-18 01:30:54 +00:00
Joe Finney 3531cde893 microbit: Updates to all components to include MicroBitConfig.h
Also added configuration option to enable / disable MicroBitHeapAllocator
overloads.
2016-03-17 17:33:57 +00:00
Joe Finney 0e8034c5bc microbit: Replaced all internal references of the MicroBitMessageBus class
to the abstract EventModel interface.
2016-03-17 16:57:22 +00:00
Joe Finney 83390b9663 microbit: Update to camel case in comment blocks: uBit.MessageBus -> uBit.messageBus 2016-03-17 16:09:41 +00:00
Joe Finney 5b167fb743 microbit: completed removal of internal #include dependencies on Microbit.h 2016-03-17 16:02:50 +00:00
James Devine 7fc98ccaf8 microbit: WIP header refactor
Removed references to MicroBit.h in some header and cpp files.

As a result a number of changes had to be made in order to satisfy
include dependencies.
2016-03-17 14:47:43 +00:00
James Devine d58690a8a7 microbit: removed whitespace from all files
Commits were polluted by the amount of trailing whitespace there was
in files. All whitespace errors should now be fixed.
2016-03-17 12:24:45 +00:00
James Devine 0fd04e11a4 microbit: decoupled MicroBitDisplay, MicroBitLightSensor from #defines
This commit removes the reliance upon #defines to control the
translation of x,y display coordinates to the hardware. This adds a
parameter of type MatrixMap to the constructor of MicroBitDisplay,
containing the necessary information for translation.

MicroBitLightSensor, now also has a constructor parameterised with a
MatrixMap.

The previously relevant #defines for display translation have now been
removed from MicroBitDisplay.h.

MicroBitMatrixMaps.h has been optimised, and a new type “MatrixMap”
contains all of the key information for rendering.

MicroBitDisplay also now performs blocking waits when operating without
a scheduler.

fiber_wait_for_event now drops through returning an error code to the
caller.
2016-03-16 22:01:03 +00:00
James Devine 3a74941a2f Merge branch 'component-refactor' of https://github.com/lancaster-university/microbit-dal into component-refactor 2016-03-16 15:38:53 +00:00
James Devine 8abec9239a microbit: completed lazy instantiation implementation for compass and the accelerometer.
The compass and accelerometer are now added to the idle fiber whenever a listener
is created using the IDs for these components.

This is a small optimisation which reduces the load on the idle fiber if these
two components aren't in use.
2016-03-16 15:35:29 +00:00
Joe Finney 687ff58646 microbit: WIP: Non-compiling build outlining matrix map refactor 2016-03-16 14:38:30 +00:00
James Devine d559eb6162 Merge remote-tracking branch 'refs/remotes/origin/component-refactor' into component-refactor 2016-03-16 13:40:09 +00:00
Joe Finney 6ac078a54f microbit: Added EventModel interface.
The microbit-dal runtime uses asynchronous events as a mechanism to decouple
user code from interrupt context and to provide an approach to asynchronous
programming on the micro:bit.

Not all languages may wish to use the default MessageBus service, and instead
prefer to roll their own event model. This patch adds a level of indirection
in the form of an EventModel interface that defines an API that allows any
EventModel to consume events from the microbit-dal runtime with whichever
implementaiton they choose. Such event models should subclass the
EventModel interface, and implement some (or none) of the defined functions:

 - send()
 - add()
 - remove()
 - elemenAt()

All uses of MicroBitMessageBus updated to use EventModel, and all event
listeners within the runtime now attmept to attach to a default service -
EventModel::defaultEventBus (which may or may not be present).
2016-03-16 13:32:50 +00:00
James Devine 6b9cabb209 microbit-dal: BUGFIX: possible status bit muxing
In some cases status bit 0x01 was shared with another status flag:

	* MICROBIT_COMPASS_STATUS_CALIBRATED and MICROBIT_COMPONENT_RUNNING
	* MICROBIT_ACCEL_PITCH_ROLL_VALID and MICROBIT_COMPONENT_RUNNING

This has now been patched.
2016-03-11 16:34:30 +00:00
James Devine 45528a437c microbit-dal: initial refactor to MicroBitAccelerometer
This refactor removes reliance on the scheduler. It allows the
accelerometer to be used even when the scheduler is not active,
and no idle thread is available for updating the sample used by
the accelerometer.

This commit also provides an optimisation through the lazy
addition of the accelerometer to the idle thread.
2016-03-11 16:12:52 +00:00
James Devine 65eaf8be30 microbit-dal: removed MicroBitCompass' reliance on MicroBitAccelerometer
Removed a dependency on MicroBitAccelerometer from MicroBitCompass, so
that a user can optionally create an instance of MicroBitCompass that
isn't tilt compensated.
2016-03-11 15:20:58 +00:00
James Devine bf9fdad3c6 microbit-dal: optimisation to MicroBitCompass
The Compass now only adds itself to the idle callback when it is first "used".
2016-03-11 12:07:46 +00:00
James Devine f3e6503e45 microbit-dal: refactored compass to update stale data on get[X,Y,Z]()
This commit introduces a new call "updateSample" which is used by both idleTick,
and get[X,Y,Z](). This allows the compass to be used in the absence of the scheduler.
2016-03-11 11:49:42 +00:00
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