Adveritsing add multiple services API
- add Advertisable abstract class
This commit is contained in:
1 parent
d25bfe639d
commit
7695d8f4cc
3 files changed
+59
-22
No files matched your search
@@ -2,6 +2,17 @@
|
||||
|
||||
## 0.9.0
|
||||
|
||||
## Core
|
||||
|
||||
- Add IDE programmer option to upgrade bootloader from IDE
|
||||
|
||||
## BLE
|
||||
|
||||
- Upgrade Bluetooth 5 with Softdevice to S132 v5.0.0
|
||||
- Support max ATT MTU up to 247 (negotiable with peer)
|
||||
- Added BLEAdvertising multiple services addition API
|
||||
- Fixed an discovery bug introduced in 0.7.5
|
||||
|
||||
## 0.7.5
|
||||
|
||||
### Core
|
||||
|
||||
@@ -61,6 +61,9 @@ bool BLEAdvertisingData::addData(uint8_t type, const void* data, uint8_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Adding UUID
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEAdvertisingData::addUuid(BLEUuid bleuuid)
|
||||
{
|
||||
return addUuid(&bleuuid, 1);
|
||||
@@ -122,28 +125,29 @@ bool BLEAdvertisingData::addUuid(BLEUuid bleuuid[], uint8_t count)
|
||||
return true;
|
||||
}
|
||||
|
||||
//bool BLEAdvertisingData::addService(BLEService& service[], uint8_t count)
|
||||
//{
|
||||
// for(uint8_t i=0; i<count; i++)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
//
|
||||
//bool BLEAdvertisingData::addService(BLEClientService& service[], uint8_t count)
|
||||
//{
|
||||
// for(uint8_t i=0; i<count; i++)
|
||||
// {
|
||||
//
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Adding Service's UUID
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLEAdvertisingData::addService(BLEService& service)
|
||||
{
|
||||
return addUuid(service.uuid);
|
||||
}
|
||||
|
||||
bool BLEAdvertisingData::addService(BLEService& service1, BLEService& service2)
|
||||
{
|
||||
return addUuid(service1.uuid, service2.uuid);
|
||||
}
|
||||
|
||||
bool BLEAdvertisingData::addService(BLEService& service1, BLEService& service2, BLEService& service3)
|
||||
{
|
||||
return addUuid(service1.uuid, service2.uuid, service3.uuid);
|
||||
}
|
||||
|
||||
bool BLEAdvertisingData::addService(BLEService& service1, BLEService& service2, BLEService& service3, BLEService& service4)
|
||||
{
|
||||
return addUuid(service1.uuid, service2.uuid, service3.uuid, service4.uuid);
|
||||
}
|
||||
|
||||
bool BLEAdvertisingData::addService(BLEClientService& service)
|
||||
{
|
||||
// Central service is added to Solicitation UUID
|
||||
@@ -163,7 +167,14 @@ bool BLEAdvertisingData::addService(BLEClientService& service)
|
||||
return false;
|
||||
}
|
||||
|
||||
// Add Name to Adv packet, use setName() to set
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Adding Others
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Add Name to Adv packet, use setName() to set
|
||||
* @return true if success
|
||||
*/
|
||||
bool BLEAdvertisingData::addName(void)
|
||||
{
|
||||
char name[BLE_GAP_ADV_MAX_SIZE+1];
|
||||
|
||||
@@ -59,6 +59,16 @@
|
||||
#define BLE_ADV_INTERVAL_SLOW_DFLT 244 // 152.5 ms (in 0.625 ms unit)
|
||||
#define BLE_ADV_FAST_TIMEOUT_DFLT 30 // in seconds
|
||||
|
||||
// forward declaration
|
||||
class BLEAdvertisingData;
|
||||
|
||||
// Abstract Class to set Adv Data
|
||||
class Advertisable
|
||||
{
|
||||
public:
|
||||
virtual bool setAdv(BLEAdvertisingData& adv) = 0;
|
||||
};
|
||||
|
||||
class BLEAdvertisingData
|
||||
{
|
||||
protected:
|
||||
@@ -75,6 +85,7 @@ public:
|
||||
bool addName(void);
|
||||
bool addAppearance(uint16_t appearance);
|
||||
|
||||
/*------------- UUID -------------*/
|
||||
bool addUuid(BLEUuid bleuuid);
|
||||
bool addUuid(BLEUuid bleuuid1, BLEUuid bleuuid2);
|
||||
bool addUuid(BLEUuid bleuuid1, BLEUuid bleuuid2, BLEUuid bleuuid3);
|
||||
@@ -82,19 +93,23 @@ public:
|
||||
|
||||
bool addUuid(BLEUuid bleuuid[], uint8_t count);
|
||||
|
||||
/*------------- Service -------------*/
|
||||
bool addService(BLEService& service);
|
||||
bool addService(BLEClientService& service);
|
||||
bool addService(BLEService& service1, BLEService& service2);
|
||||
bool addService(BLEService& service1, BLEService& service2, BLEService& service3);
|
||||
bool addService(BLEService& service1, BLEService& service2, BLEService& service3, BLEService& service4);
|
||||
|
||||
// bool addService(BLEService& service[], uint8_t count);
|
||||
// bool addService(BLEClientService& service[], uint8_t count);
|
||||
/*------------- Client Service -------------*/
|
||||
bool addService(BLEClientService& service);
|
||||
|
||||
// Custom API
|
||||
uint8_t count(void);
|
||||
uint8_t* getData(void);
|
||||
bool setData(const uint8_t* data, uint8_t count);
|
||||
void clearData(void);
|
||||
};
|
||||
|
||||
bool setData(Advertisable& adv_able) { return adv_able.setAdv(*this); }
|
||||
};
|
||||
|
||||
class BLEAdvertising : public BLEAdvertisingData
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user