forked from h2zero/esp-nimble-cpp
Add support for creating a NimBLEClient from a NimBLEServer peer.
This allows the NimBLEServer instance to create a NimBLEClient instance to read/write form/to a connected peer. Only one instance is supported subsequent calls will overwrite the previous client connection information and data.
This commit is contained in:
@@ -48,6 +48,9 @@ class NimBLEExtAdvertising;
|
||||
# else
|
||||
class NimBLEAdvertising;
|
||||
# endif
|
||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||
class NimBLEClient;
|
||||
# endif
|
||||
|
||||
/**
|
||||
* @brief The model of a BLE server.
|
||||
@@ -77,6 +80,12 @@ class NimBLEServer {
|
||||
void advertiseOnDisconnect(bool enable);
|
||||
void setDataLen(uint16_t connHandle, uint16_t tx_octets) const;
|
||||
|
||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||
NimBLEClient* getClient(uint16_t connHandle);
|
||||
NimBLEClient* getClient(const NimBLEConnInfo& connInfo);
|
||||
void deleteClient();
|
||||
# endif
|
||||
|
||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||
NimBLEExtAdvertising* getAdvertising() const;
|
||||
bool startAdvertising(uint8_t instanceId, int duration = 0, int maxEvents = 0) const;
|
||||
@@ -115,6 +124,10 @@ class NimBLEServer {
|
||||
std::vector<NimBLEService*> m_svcVec;
|
||||
std::array<uint16_t, CONFIG_BT_NIMBLE_MAX_CONNECTIONS> m_connectedPeers;
|
||||
|
||||
# if defined(CONFIG_BT_NIMBLE_ROLE_CENTRAL)
|
||||
NimBLEClient* m_pClient{nullptr};
|
||||
# endif
|
||||
|
||||
static int handleGapEvent(struct ble_gap_event* event, void* arg);
|
||||
static int handleGattEvent(uint16_t connHandle, uint16_t attrHandle, ble_gatt_access_ctxt* ctxt, void* arg);
|
||||
static int peerNameCB(uint16_t connHandle, const ble_gatt_error* error, ble_gatt_attr* attr, void* arg);
|
||||
|
||||
Reference in New Issue
Block a user