BLE_API wrapper library for STMicroelectronics' BlueNRG Bluetooth Low Energy expansion board shield (Component)

Dependents:   Nucleo_Zumo_BLE_IDB04A1 contest_IOT5 contest_IOT6 contest_IOT_10 ... more

Fork of X_NUCLEO_IDB0XA1 by ST Expansion SW Team

Embed: (wiki syntax)

« Back to documentation index

BlueNRGDevice

BlueNRGDevice

BlueNRG BLE_API Device Adaptation. More...

Functions

BlueNRGDevice bluenrgDeviceInstance (IDB0XA1_PIN_SPI_MOSI, IDB0XA1_PIN_SPI_MISO, IDB0XA1_PIN_SPI_SCK, IDB0XA1_PIN_SPI_nCS, IDB0XA1_PIN_SPI_RESET, IDB0XA1_PIN_SPI_IRQ)
 The singleton which represents the BlueNRG transport for the BLEDevice.
BLEInstanceBase * createBLEInstance (void)
 BLE-API requires an implementation of the following function in order to obtain its transport handle.
 BlueNRGDevice (PinName mosi, PinName miso, PinName sck, PinName cs, PinName rst, PinName irq)
 Constructor.
virtual ~BlueNRGDevice (void)
 Destructor.
uint8_t getUpdaterHardwareVersion (uint8_t *hw_version)
 Get BlueNRG HW version in bootloader mode.
int updateFirmware (const uint8_t *fw_image, uint32_t fw_size)
 Flash a new firmware using internal bootloader.
virtual ble_error_t init (BLE::InstanceID_t instanceID, FunctionPointerWithContext< BLE::InitializationCompleteCallbackContext * > callback)
 Initialises anything required to start using BLE.
void reset (void)
 Resets the BLE HW, removing any existing services and characteristics.
virtual void waitForEvent (void)
 Wait for any BLE Event like BLE Connection, Read Request etc.
virtual const char * getVersion (void)
 get GAP version
virtual Gap & getGap ()
 get reference to GAP object
virtual GattServer & getGattServer ()
 get reference to GATT server object
virtual ble_error_t shutdown (void)
 shut down the BLE device
int32_t spiRead (uint8_t *buffer, uint8_t buff_size)
 Reads from BlueNRG SPI buffer and store data into local buffer.
int32_t spiWrite (uint8_t *data1, uint8_t *data2, uint8_t Nb_bytes1, uint8_t Nb_bytes2)
 Writes data from local buffer to SPI.

Detailed Description

BlueNRG BLE_API Device Adaptation.


Function Documentation

BlueNRGDevice ( PinName  mosi,
PinName  miso,
PinName  sck,
PinName  cs,
PinName  rst,
PinName  irq 
) [inherited]

Constructor.

Parameters:
mosimbed pin to use for MOSI line of SPI interface
misombed pin to use for MISO line of SPI interface
sckmbed pin to use for SCK line of SPI interface
csmbed pin to use for not chip select line of SPI interface
rstmbed pin to use for BlueNRG reset
irqmbed pin for BlueNRG IRQ

Definition at line 99 of file BlueNRGDevice.cpp.

BlueNRGDevice bluenrgDeviceInstance ( IDB0XA1_PIN_SPI_MOSI  ,
IDB0XA1_PIN_SPI_MISO  ,
IDB0XA1_PIN_SPI_SCK  ,
IDB0XA1_PIN_SPI_nCS  ,
IDB0XA1_PIN_SPI_RESET  ,
IDB0XA1_PIN_SPI_IRQ   
)

The singleton which represents the BlueNRG transport for the BLEDevice.

See file 'x_nucleo_idb0xa1_targets.h' for details regarding the peripheral pins used!

BLEInstanceBase* createBLEInstance ( void   )

BLE-API requires an implementation of the following function in order to obtain its transport handle.

Definition at line 83 of file BlueNRGDevice.cpp.

Gap & getGap (  ) [virtual, inherited]

get reference to GAP object

Parameters:
[in]void
Returns:
Gap&

Definition at line 265 of file BlueNRGDevice.cpp.

GattServer & getGattServer (  ) [virtual, inherited]

get reference to GATT server object

Parameters:
[in]void
Returns:
GattServer&

Definition at line 282 of file BlueNRGDevice.cpp.

uint8_t getUpdaterHardwareVersion ( uint8_t *  hw_version ) [inherited]

Get BlueNRG HW version in bootloader mode.

Parameters:
hw_versionThe HW version is written to this parameter
Return values:
Itreturns BLE_STATUS_SUCCESS on success or an error code otherwise

Definition at line 139 of file BlueNRGDevice.cpp.

const char * getVersion ( void   ) [virtual, inherited]

get GAP version

Get the BLE stack version information

Parameters:
[in]void
Returns:
char *
char *

Definition at line 253 of file BlueNRGDevice.cpp.

ble_error_t init ( BLE::InstanceID_t  instanceID,
FunctionPointerWithContext< BLE::InitializationCompleteCallbackContext * >  callback 
) [virtual, inherited]

Initialises anything required to start using BLE.

Parameters:
[in]instanceIDThe ID of the instance to initialize.
[in]callbackA callback for when initialization completes for a BLE instance. This is an optional parameter set to NULL when not supplied.
Returns:
BLE_ERROR_NONE if the initialization procedure was started successfully.

Definition at line 178 of file BlueNRGDevice.cpp.

void reset ( void   ) [inherited]

Resets the BLE HW, removing any existing services and characteristics.

Parameters:
[in]void
Returns:
void

Definition at line 209 of file BlueNRGDevice.cpp.

ble_error_t shutdown ( void   ) [virtual, inherited]

shut down the BLE device

Parameters:
[out]errorif any

Definition at line 298 of file BlueNRGDevice.cpp.

int32_t spiRead ( uint8_t *  buffer,
uint8_t  buff_size 
) [inherited]

Reads from BlueNRG SPI buffer and store data into local buffer.

Parameters:
buffer: Buffer where data from SPI are stored
buff_size,:Buffer size
Return values:
int32_t: Number of read bytes

Definition at line 339 of file BlueNRGDevice.cpp.

int32_t spiWrite ( uint8_t *  data1,
uint8_t *  data2,
uint8_t  Nb_bytes1,
uint8_t  Nb_bytes2 
) [inherited]

Writes data from local buffer to SPI.

Parameters:
data1: First data buffer to be written
data2: Second data buffer to be written
Nb_bytes1,:Size of first data buffer to be written
Nb_bytes2,:Size of second data buffer to be written
Return values:
Numberof read bytes

Definition at line 407 of file BlueNRGDevice.cpp.

int updateFirmware ( const uint8_t *  fw_image,
uint32_t  fw_size 
) [inherited]

Flash a new firmware using internal bootloader.

Parameters:
fw_imagePointer to the firmware image (raw binary data, little-endian).
fw_sizeSize of the firmware image. The firmware image size shall be multiple of 4 bytes.
Return values:
intIt returns BLE_STATUS_SUCCESS on success, or a number not equal to 0 in case of error (ACI_ERROR, UNSUPPORTED_VERSION, WRONG_IMAGE_SIZE, CRC_ERROR)

Definition at line 158 of file BlueNRGDevice.cpp.

void waitForEvent ( void   ) [virtual, inherited]

Wait for any BLE Event like BLE Connection, Read Request etc.

Parameters:
[in]void
Returns:
char *

Definition at line 229 of file BlueNRGDevice.cpp.

~BlueNRGDevice ( void   ) [virtual, inherited]

Destructor.

Definition at line 130 of file BlueNRGDevice.cpp.