You are viewing an older revision! See the latest version

API Development

API Development

Change Requests

Main header file name (cacu)

<ble.h> or <bledevice.h> rather than <nRF51822n.h>. That way if one day the developer switches chips he does not have to change the source

Main stack instance (cacu)

Currently it is "nRF51822n nrf;", I suggest "BLEDevice ble;" instead

Repo Layout and Code sharing across multiple chipsets (cacu)

Currently the repo layout looks like this:

|-- BLE_API_Native
|    |-- hw
|    |    |-- nRF51822n
|    |    |    |-- btle
|    |    |    |-- common
|    |    |    |-- nordic
|    |    |    | nRF51Gap.cpp
|    |    |    | nRF51Gap.h
|    |    |    | [...]
|    |    |    | projectconfig.h
|    |    |
|    |    | BLEDevice.h
|    |    | Gap.h
|    |    | GapEvents.h
|    |    | GattServer.h
|    |    | GattServerEvents.h
|    |-- mbed-src-Nordic
|   
| blecommon.h
| GapAdvertisingData.cpp
| GapAdvertisingData.h
| [...]
|UUID.h
|

I think this layout does not split the common vs the chip-specific code clearly.

Instead I would suggest something along these lines:

|-- ble
|    |-- public // the public API that app developers are going to use, those are the only files they need to include
|    |    | BLEDevice.h
|    |    | Gap.h
|    |    | GapEvents.h
|    |    | GattServer.h
|    |    | GattServerEvents.h
|    |-- common
|    |    |-- hwapi // internal API for the hardware, isolates the chip-specific code from the common classes
|    |    |    | HwBLEDevice.h 
|    |    |    | ???  // depending on how this internal API is split there may be more interface files headers 
|    |    |    | [...]
|    |    | blecommon.h // all files on this level are common to all chips, they include the implementation to the "public" folder
|    |    | GapAdvertisingData.cpp
|    |    | GapAdvertisingData.h
|    |    | [...]
|    |    | UUID.h
|    |    | BLEDevice.cpp // this implements the API in public/
|    |    | Gap.cpp
|    |    | GapEvents.cpp
|    |    | GattServer.cpp
|    |    | GattServerEvents.cpp
|    |-- hw
|    |   |-- nRF51822n
|    |   |    |-- btle
|    |   |    |-- common
|    |   |    |-- nordic
|    |   |    | nRF51BLEDevice.cpp // this implements the HwBLEDevice.h API in common/hwapi
|    |   |    | ??? // depending on how this internal API is split there may be more implementation files
|    |   |    | [...]
|    |   |    | projectconfig.h
|    |   |
|    |-- mbed-src-Nordic
|   
|

Using the above repo layout, then the files in common/ would not need to know about which radio is running:

in ble/common:

class BLEDevice
{
   HwBLEDevice hwBLEDevice;
}

class GAP
{

void startAdvertising(void)
{
   // common adv code
  this->state = GAP_ADV;
   // tell the radio to start advertising 
   hwBLEDevice.startAdvertising();
}

}

And the application would simply:

BLEDevice bleDevice;

void main(void)
{
    bleDevice.reset();
    bleDevice.startAdvertising();
}

Feature Requests

Additional functionality not currently covered by the API

  • Description (request author)

All wikipages