AdafruitBluefruit
This base class is the main entry point to the Adafruit Bluefruit nRF52 API, and exposes most of the helper classes and functions that you use to configure your device.
// Constructor AdafruitBluefruit(void); /*------------------------------------------------------------------*/ /* Lower Level Classes (Bluefruit.Advertising.*, etc.) *------------------------------------------------------------------*/ BLEGap Gap; BLEGatt Gatt; BLEAdvertising Advertising; BLEAdvertisingData ScanResponse; BLEScanner Scanner; BLECentral Central; BLEDiscovery Discovery; /*------------------------------------------------------------------*/ /* SoftDevice Configure Functions, must call before begin(). * These function affect the SRAM consumed by SoftDevice. *------------------------------------------------------------------*/ void configServiceChanged (bool changed); void configUuid128Count (uint8_t uuid128_max); void configAttrTableSize (uint32_t attr_table_size); // Config Bandwidth for connections void configPrphConn (uint16_t mtu_max, uint8_t event_len, uint8_t hvn_qsize, uint8_t wrcmd_qsize); void configCentralConn (uint16_t mtu_max, uint8_t event_len, uint8_t hvn_qsize, uint8_t wrcmd_qsize); // Convenient function to config connection void configPrphBandwidth (uint8_t bw); void configCentralBandwidth(uint8_t bw); err_t begin(uint8_t prph_count = 1, uint8_t central_count = 0); /*------------------------------------------------------------------*/ /* General Functions *------------------------------------------------------------------*/ void setName (const char* str); uint8_t getName (char* name, uint16_t bufsize); bool setTxPower (int8_t power); int8_t getTxPower (void); bool setApperance (uint16_t appear); uint16_t getApperance (void); void autoConnLed (bool enabled); void setConnLedInterval (uint32_t ms); /*------------------------------------------------------------------*/ /* GAP, Connections and Bonding *------------------------------------------------------------------*/ bool connected (void); bool disconnect (void); bool setConnInterval (uint16_t min, uint16_t max); bool setConnIntervalMS (uint16_t min_ms, uint16_t max_ms); uint16_t connHandle (void); bool connPaired (void); uint16_t connInterval (void); bool requestPairing (void); void clearBonds (void); ble_gap_addr_t getPeerAddr (void); uint8_t getPeerAddr (uint8_t addr[6]); void printInfo(void); /*------------------------------------------------------------------*/ /* Callbacks *------------------------------------------------------------------*/ void setConnectCallback ( BLEGap::connect_callback_t fp); void setDisconnectCallback( BLEGap::disconnect_callback_t fp);
These functions are generally available via 'Bluefruit.*'. For example, to check the connection status in your sketch you could run 'if (Bluefruit.connected()) { ... }'.
Examples
For examples of how to work with the parent Bluefruit class, see the Examples section later in this guide. It's better to examine this class in the context of a real world use case.
You can also browse the latest example code online via Github:
Page last edited March 08, 2024
Text editor powered by tinymce.