forked from h2zero/esp-nimble-cpp
[Breaking] Change all time input parameters to milliseconds. (#78)
Changes all functions that accept a time parameter to use milliseconds instead of seconds. * Adds duration input to NimBLEDevice::startAdvertising and NimBLEServer::startAdvertising.
This commit is contained in:
1 parent
0b6337538c
commit
bb3dd5f114
14 files changed
+36
-35
No files matched your search
@@ -385,7 +385,7 @@ void NimBLEAdvertising::setScanResponseData(NimBLEAdvertisementData& advertiseme
|
||||
|
||||
/**
|
||||
* @brief Start advertising.
|
||||
* @param [in] duration The duration, in seconds, to advertise, 0 == advertise forever.
|
||||
* @param [in] duration The duration, in milliseconds, to advertise, 0 == advertise forever.
|
||||
* @param [in] advCompleteCB A pointer to a callback to be invoked when advertising ends.
|
||||
* @return True if advertising started successfully.
|
||||
*/
|
||||
@@ -423,9 +423,6 @@ bool NimBLEAdvertising::start(uint32_t duration, void (*advCompleteCB)(NimBLEAdv
|
||||
if(duration == 0){
|
||||
duration = BLE_HS_FOREVER;
|
||||
}
|
||||
else{
|
||||
duration = duration*1000; // convert duration to milliseconds
|
||||
}
|
||||
|
||||
m_advCompCB = advCompleteCB;
|
||||
|
||||
|
||||
@@ -533,10 +533,10 @@ NimBLEConnInfo NimBLEClient::getConnInfo() {
|
||||
|
||||
/**
|
||||
* @brief Set the timeout to wait for connection attempt to complete.
|
||||
* @param [in] time The number of seconds before timeout.
|
||||
* @param [in] time The number of milliseconds before timeout.
|
||||
*/
|
||||
void NimBLEClient::setConnectTimeout(uint8_t time) {
|
||||
m_connectTimeout = (uint32_t)(time * 1000);
|
||||
void NimBLEClient::setConnectTimeout(uint32_t time) {
|
||||
m_connectTimeout = time;
|
||||
} // setConnectTimeout
|
||||
|
||||
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ public:
|
||||
uint16_t getConnId();
|
||||
uint16_t getMTU();
|
||||
bool secureConnection();
|
||||
void setConnectTimeout(uint8_t timeout);
|
||||
void setConnectTimeout(uint32_t timeout);
|
||||
void setConnectionParams(uint16_t minInterval, uint16_t maxInterval,
|
||||
uint16_t latency, uint16_t timeout,
|
||||
uint16_t scanInterval=16, uint16_t scanWindow=16);
|
||||
|
||||
@@ -170,10 +170,11 @@ NimBLEAdvertising* NimBLEDevice::getAdvertising() {
|
||||
|
||||
/**
|
||||
* @brief Convenience function to begin advertising.
|
||||
* @param [in] duration The duration in milliseconds to advertise for, default = forever.
|
||||
* @return True if advertising started successfully.
|
||||
*/
|
||||
bool NimBLEDevice::startAdvertising() {
|
||||
return getAdvertising()->start();
|
||||
bool NimBLEDevice::startAdvertising(uint32_t duration) {
|
||||
return getAdvertising()->start(duration);
|
||||
} // startAdvertising
|
||||
# endif
|
||||
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ public:
|
||||
static bool stopAdvertising();
|
||||
# else
|
||||
static NimBLEAdvertising* getAdvertising();
|
||||
static bool startAdvertising();
|
||||
static bool startAdvertising(uint32_t duration = 0);
|
||||
static bool stopAdvertising();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
+1
-5
@@ -302,7 +302,7 @@ bool NimBLEScan::isScanning() {
|
||||
|
||||
/**
|
||||
* @brief Start scanning.
|
||||
* @param [in] duration The duration in seconds for which to scan.
|
||||
* @param [in] duration The duration in milliseconds for which to scan.
|
||||
* @param [in] scanCompleteCB A function to be called when scanning has completed.
|
||||
* @param [in] is_continue Set to true to save previous scan results, false to clear them.
|
||||
* @return True if scan started or false if there was an error.
|
||||
@@ -319,10 +319,6 @@ bool NimBLEScan::start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResul
|
||||
if(duration == 0){
|
||||
duration = BLE_HS_FOREVER;
|
||||
}
|
||||
else{
|
||||
// convert duration to milliseconds
|
||||
duration = duration * 1000;
|
||||
}
|
||||
|
||||
// Set the flag to ignore the results while we are deleting the vector
|
||||
if(!is_continue) {
|
||||
|
||||
@@ -748,15 +748,16 @@ bool NimBLEServer::stopAdvertising(uint8_t inst_id) {
|
||||
} // stopAdvertising
|
||||
#endif
|
||||
|
||||
#if !CONFIG_BT_NIMBLE_EXT_ADV|| defined(_DOXYGEN_)
|
||||
#if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
||||
/**
|
||||
* @brief Start advertising.
|
||||
* @param [in] duration The duration in milliseconds to advertise for, default = forever.
|
||||
* @return True if advertising started successfully.
|
||||
* @details Start the server advertising its existence. This is a convenience function and is equivalent to
|
||||
* @details Start the server advertising its existence. This is a convenience function and is equivalent to
|
||||
* retrieving the advertising object and invoking start upon it.
|
||||
*/
|
||||
bool NimBLEServer::startAdvertising() {
|
||||
return getAdvertising()->start();
|
||||
bool NimBLEServer::startAdvertising(uint32_t duration) {
|
||||
return getAdvertising()->start(duration);
|
||||
} // startAdvertising
|
||||
#endif
|
||||
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ public:
|
||||
bool stopAdvertising(uint8_t inst_id);
|
||||
#else
|
||||
NimBLEAdvertising* getAdvertising();
|
||||
bool startAdvertising();
|
||||
bool startAdvertising(uint32_t duration = 0);
|
||||
#endif
|
||||
bool stopAdvertising();
|
||||
void start();
|
||||
|
||||
Reference in new issue
Block a user