Commit Graph

20 Commits (040baa12c08b439f9a09f0c1594ac625e58e2ad1)

Author SHA1 Message Date
Joe Finney 67d0ac737d microbit: Update to indicate when system attributes require intialisation 2016-02-11 22:01:37 +00:00
Joe Finney 06a34dad44 microbit: Revert service changed indication.
Some central devices under testing performed poorly, failing to correctly
conect or discover services.
2016-02-07 19:03:28 +00:00
Joe Finney fd017fbf2b microbit: Update to indicate service change on SYS_ATTR_MISSING
When using bonded connections to a central device, an explicit service changed
indication should be used in cases where a device's GATT table appears out of
date. This patch preserves the metadata of the Service Changed
characterisitic, and also adds this indication as described.
2016-01-25 17:18:10 +00:00
Joe Finney f0333be39e microbit: Update to acomodate changed ble-nrf51822 API 2016-01-16 15:16:06 +00:00
Joe Finney 5928b5e443 microbit: Added support for explicit characteristic notification
Required to allow the mbed layer to avoid caching large amounts of state in its GattCharacteristics

n.b. this should be removed once all optimisations to the mbed layer are completed.
2016-01-12 22:10:52 +00:00
Andres Amaya Garcia 90de915fac Replace deprecated inclusions of mbed.h
Replace all deprecated inclusions of mbed.h for mbed-drivers/mbed.h when using
mbed OS. Applications should compile for mbed classic.
2015-12-15 13:58:54 +00:00
Andres Amaya Garcia 0bcc2e96c9 Modify shutdown due to BLE API change
The module is updated to comply with the changes to BLE API regarding correct
shutdown functionality. The following changes are introduced to ble-nrf51822:

* Calls to the old static function shutdown in Gap, GattClient, GattServer and
SecurityManager are removed.
* The cleanup function in Gap, GattClient, GattServer and SecurityManager is
renamed to `reset()` and made public.
* The static references inside nRF5xGap, nRF5xGattClient, nRF5xGattServer and
nRF5xSecurityManager to objects of their own class are moved to nRF5xn.
* The static getInstance accessors in nRF5xGap, nRF5xGattClient,
nRF5xGattServer and nRF5xSecurityManager are removed and their functionality is
moved to the implemented virtual accessors in nRF5xn i.e. getGap(),
getGattClient, etc.
* A static function Instance is added to nRF5xn class to make the transport
object accessible across the module.
2015-12-14 15:15:35 +00:00
Andres Amaya Garcia 7bf81e7edb Improve shutdown to clear BLE API and not just SD
Improve the shutdown functionality, such that a call to ble.shutdown() from
the user application clears the API and nRF5x state and NOT only the
SoftDevice. To achieve this the following changes are introduced:

* Add a protected member cleanup() to nRF5xGap, nRF5xGattClient,
nRF5xGattServer, nRF5xSecurityManager and nRF5xServiceDiscovery.
* Modify the shutdown() implementation in nRF5xn such that it also calls the
static member shutdown() exposed by the BLE API in Gap.h, SecurityManager.h,
GattClient.h and GattServer.h.
* Modify nRF5xGattClient, nRF5xGattServer and nRF5xSecurityManager
classes so that they dynamically create their respective objects only if
needed. Previously the GattClient, GattServer and SecurityManager objects were
declared as static, which means that they were always present even though they
were not always needed. This increases memory consumption unnecessarily.
Furthermore, pointers to the object instances are stored in static members of
the classes as specified by the BLE API base classes. This ensures that
calls to shutdown do not require calls to getInstance() functions that would
otherwise result in undesired memory allocations.
* nRF5xGap object is always needed, so this remains allocated statically. But
the reference in Gap is pointed to this object.

The shutdown procedure is as follows:

1. The user calls ble.shutdown() which executes the code in nRF5xn::shutdown()
1. The SoftDevice is shutdown
1. The static members of Gap.h, SecurityManager.h, GattClient.h and
GattServer.h are called to clean up their own state.

If at any point an error occur during the last step, BLE_ERROR_INVALID_STATE is
2015-12-11 17:56:57 +00:00
Andres Amaya Garcia 4b3a1c85b5 Allow GattAttributes to have fixed length
Previously the concepts of initLength and lenth were clearly separated.
However, this was at the cost of registering all characteristics in the
SoftDevice as having variable length. Clearly, this is not the desired
behaviour. Therefore, an additional field '_hasVariableLen' is added to the
GattAttribute to address the problem. Also, the GattAttribute and
GattCharacteristic constructors have been modified to take a boolean that
sets '_hasVariableLen'.

**NOTE:** Changes to this module will cause projects to fail the build stage
if changes to the BLE_API are not published first.
2015-12-02 10:41:01 +00:00
Andres Amaya Garcia 3fb32e167f Separate concept of minlen and len for BLE chars
In previous versions of BLE_API the GattCharacteristic initLen parameter is
named minLen as well. When the characteristic is committed to the SoftDevice
the value of initial length is also used as the minimum length of the
characteristic value. Furthermore, the test (max_length == min_length) is used
to determine whether the characteristic value has variable length. This is
slightly confusing and also causes problems if the user wishes to use a
characteristic with variable length but the initial lenght is equal to max

To solve this problem the characteristic is now always committed to the
SoftDevice as variable. Furthermore, the API only maintains the current lenght
and the max length i.e. the field initialLen in the GattAttribute is removed.
In nRF5xGattServer all calls to getInitialLength() are removed and replaced
with getLength().

* This change requires updates to ble.
* Ideally we would like the characteristics to be declared as 'variable' only
when necessary, but this requires changing the signature of the
GattCharacteristic and GattAttribute constructors. Therefore, it will be part
of a separate pull request.
2015-11-27 17:25:58 +00:00
Rohit Grover 816f4559f1 white space diffs; convert tabs to spaces 2015-10-13 12:54:46 +01:00
Tim 4af5d03cd5 Error check number of characteristics
Currently it just blindly writes beyond the end of the array, leading to impossible-to-find bugs.

It doesn't help that the limit on the number of characteristics doesn't seem to be documented anywhere.
2015-09-29 15:04:59 +01:00
Rohit Grover ee2b3dfe4a nRF5xGattServer::write()L remember to setup returnValue to BLE_STACK_BUSY in the case of an unforseen error. 2015-09-25 14:19:49 +01:00
Rohit Grover 167f304b68 minor cleanup to Fabien's pull request; remove the un-necessary gapConnectionHandle 2015-09-02 09:17:02 +01:00
Rohit Grover 887426ad0b minor white space diff 2015-08-28 14:01:52 +01:00
Rohit Grover b0bf2db253 Merge branch 'master' of into fabiencomte-master2 2015-08-28 13:51:10 +01:00
Fabien Comte 6cdb6f161f rgrover patch fixed 2015-08-28 14:44:34 +02:00
Rohit Grover 6a5d142f03 initialize the member authorizationReply when posting authorization callbacks to the application.
This is a nice-to-do.
2015-08-25 10:34:01 +01:00
Jean-Philippe Brucker 73147b41c2 Fill connection handle in Gatt callbacks parameters 2015-08-11 11:31:20 +01:00
Rohit Grover 0eb58d86f5 rename nRF51... to nRF5x...
This prepares us to support nRF52.
2015-07-06 14:18:01 +01:00