1

Fork of nRF51822 by Nordic Semiconductor

Committer:
rgrover1
Date:
Thu Jul 02 09:08:44 2015 +0100
Revision:
362:6fa0d4d555f6
Parent:
361:d2405f5a4853
Child:
370:295f76db798e
Synchronized with git rev 2716309c
Author: Rohit Grover
Release 0.4.0
=============

This is a major release which introduces the GATT Client functionality. It
aligns with release 0.4.0 of BLE_API.

Enhancements
~~~~~~~~~~~~

* Introduce GattClient. This includes functionality for service-discovery,
connections, and attribute-reads and writes. You'll find a demo program for
LEDBlinker on the mbed.org Bluetooth team page to use the new APIs. Some of
the GATT client functionality hasn't been implemented yet, but the APIs have
been added.

* We've added an implementation for the abstract base class for
SecurityManager. All security related APIs have been moved into that.

* There has been a major cleanup of APIs under BLE. APIs have now been
categorized as belonging to Gap, GattServer, GattClient, or SecurityManager.
There are accessors to get references for Gap, GattServer, GattClient, and
SecurityManager. A former call to ble.setAddress(...) is now expected to be
achieved with ble.gap().setAddress(...).

* We've cleaned up our APIs, and this has resulted in dropping some APIs like
BLE::reset().

* We've also dropped GattServer::initializeGattDatabase(). THis was added at
some point to support controllers where a commit point was needed to
indicate when the application had finished constructing the GATT database.
This API would get called internally before Gap::startAdvertising(). We now
expect the underlying port to do the equivalent of initializeGattDatabase()
implicitly upon Gap::startAdvertising().

* We've added a version of Gap::disconnect() which takes a connection handle.
The previous API (which did not take a connection handle) has been
deprecated; it will still work for situations where there's only a single
active connection. We hold on to that API to allow existing code to migrate
to the new API.

Bugfixes
~~~~~~~~

* None.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rohit Grover 22:c6ee8136847e 1 /* mbed Microcontroller Library
Rohit Grover 22:c6ee8136847e 2 * Copyright (c) 2006-2013 ARM Limited
Rohit Grover 22:c6ee8136847e 3 *
Rohit Grover 22:c6ee8136847e 4 * Licensed under the Apache License, Version 2.0 (the "License");
Rohit Grover 22:c6ee8136847e 5 * you may not use this file except in compliance with the License.
Rohit Grover 22:c6ee8136847e 6 * You may obtain a copy of the License at
Rohit Grover 22:c6ee8136847e 7 *
Rohit Grover 22:c6ee8136847e 8 * http://www.apache.org/licenses/LICENSE-2.0
Rohit Grover 22:c6ee8136847e 9 *
Rohit Grover 22:c6ee8136847e 10 * Unless required by applicable law or agreed to in writing, software
Rohit Grover 22:c6ee8136847e 11 * distributed under the License is distributed on an "AS IS" BASIS,
Rohit Grover 22:c6ee8136847e 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Rohit Grover 22:c6ee8136847e 13 * See the License for the specific language governing permissions and
Rohit Grover 22:c6ee8136847e 14 * limitations under the License.
Rohit Grover 22:c6ee8136847e 15 */
Rohit Grover 22:c6ee8136847e 16
Rohit Grover 22:c6ee8136847e 17 #include "mbed.h"
Rohit Grover 22:c6ee8136847e 18 #include "nRF51822n.h"
Rohit Grover 23:cdab28442479 19 #include "nrf_soc.h"
Rohit Grover 22:c6ee8136847e 20
Rohit Grover 22:c6ee8136847e 21 #include "btle/btle.h"
Rohit Grover 56:a1071b629aa3 22 #include "nrf_delay.h"
Rohit Grover 22:c6ee8136847e 23
rgrover1 80:cdcc094ab166 24 #include "softdevice_handler.h"
rgrover1 80:cdcc094ab166 25
Rohit Grover 22:c6ee8136847e 26 /**
rgrover1 362:6fa0d4d555f6 27 * The singleton which represents the nRF51822 transport for the BLE.
Rohit Grover 22:c6ee8136847e 28 */
Rohit Grover 25:a1c356620131 29 static nRF51822n deviceInstance;
Rohit Grover 22:c6ee8136847e 30
Rohit Grover 22:c6ee8136847e 31 /**
Rohit Grover 22:c6ee8136847e 32 * BLE-API requires an implementation of the following function in order to
Rohit Grover 22:c6ee8136847e 33 * obtain its transport handle.
Rohit Grover 22:c6ee8136847e 34 */
rgrover1 362:6fa0d4d555f6 35 BLEInstanceBase *
rgrover1 362:6fa0d4d555f6 36 createBLEInstance(void)
Rohit Grover 22:c6ee8136847e 37 {
Rohit Grover 25:a1c356620131 38 return (&deviceInstance);
Rohit Grover 22:c6ee8136847e 39 }
Rohit Grover 22:c6ee8136847e 40
Rohit Grover 22:c6ee8136847e 41 nRF51822n::nRF51822n(void)
Rohit Grover 22:c6ee8136847e 42 {
Rohit Grover 22:c6ee8136847e 43 }
Rohit Grover 22:c6ee8136847e 44
Rohit Grover 22:c6ee8136847e 45 nRF51822n::~nRF51822n(void)
Rohit Grover 22:c6ee8136847e 46 {
Rohit Grover 22:c6ee8136847e 47 }
Rohit Grover 22:c6ee8136847e 48
Rohit Grover 52:120bd37b9d0d 49 const char *nRF51822n::getVersion(void)
Rohit Grover 52:120bd37b9d0d 50 {
rgrover1 113:2fb5fde31edc 51 static char versionString[32];
Rohit Grover 52:120bd37b9d0d 52 static bool versionFetched = false;
Rohit Grover 52:120bd37b9d0d 53
Rohit Grover 52:120bd37b9d0d 54 if (!versionFetched) {
Rohit Grover 52:120bd37b9d0d 55 ble_version_t version;
rgrover1 113:2fb5fde31edc 56 if ((sd_ble_version_get(&version) == NRF_SUCCESS) && (version.company_id == 0x0059)) {
rgrover1 113:2fb5fde31edc 57 switch (version.version_number) {
rgrover1 113:2fb5fde31edc 58 case 0x07:
rgrover1 113:2fb5fde31edc 59 snprintf(versionString, sizeof(versionString), "Nordic BLE4.1 fw:%04x", version.subversion_number);
rgrover1 113:2fb5fde31edc 60 break;
rgrover1 113:2fb5fde31edc 61 default:
rgrover1 113:2fb5fde31edc 62 snprintf(versionString, sizeof(versionString), "Nordic (spec unknown) fw:%04x", version.subversion_number);
rgrover1 113:2fb5fde31edc 63 break;
rgrover1 113:2fb5fde31edc 64 }
Rohit Grover 52:120bd37b9d0d 65 versionFetched = true;
Rohit Grover 52:120bd37b9d0d 66 } else {
Rohit Grover 52:120bd37b9d0d 67 strncpy(versionString, "unknown", sizeof(versionString));
Rohit Grover 52:120bd37b9d0d 68 }
Rohit Grover 52:120bd37b9d0d 69 }
Rohit Grover 52:120bd37b9d0d 70
Rohit Grover 52:120bd37b9d0d 71 return versionString;
Rohit Grover 52:120bd37b9d0d 72 }
Rohit Grover 52:120bd37b9d0d 73
Rohit Grover 22:c6ee8136847e 74 ble_error_t nRF51822n::init(void)
Rohit Grover 22:c6ee8136847e 75 {
Rohit Grover 22:c6ee8136847e 76 /* ToDo: Clear memory contents, reset the SD, etc. */
Rohit Grover 22:c6ee8136847e 77 btle_init();
Rohit Grover 22:c6ee8136847e 78
Rohit Grover 22:c6ee8136847e 79 return BLE_ERROR_NONE;
Rohit Grover 22:c6ee8136847e 80 }
Rohit Grover 22:c6ee8136847e 81
rgrover1 80:cdcc094ab166 82 ble_error_t nRF51822n::shutdown(void)
rgrover1 80:cdcc094ab166 83 {
rgrover1 80:cdcc094ab166 84 return (softdevice_handler_sd_disable() == NRF_SUCCESS) ? BLE_ERROR_NONE : BLE_STACK_BUSY;
rgrover1 80:cdcc094ab166 85 }
rgrover1 80:cdcc094ab166 86
Rohit Grover 23:cdab28442479 87 void
Rohit Grover 23:cdab28442479 88 nRF51822n::waitForEvent(void)
Rohit Grover 23:cdab28442479 89 {
Rohit Grover 23:cdab28442479 90 sd_app_evt_wait();
rgrover1 79:540d11f2764f 91 }