Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added flag activeScan as parameter to begin() #11

Merged
merged 4 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ jobs:
|
ps -p "$$"
arduino-cli lib install NimBLE-Arduino@1.4.1
arduino-cli lib install ATC_MiThermometer@0.4.1
arduino-cli lib install ATC_MiThermometer@0.4.2

- name: Install platform
if: ${{ env.run-build == 'true' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
// History:
//
// 20221123 Created
// 20240403 Added reedSwitchState, gpioTrgOutput, controlParameters,
// tempTriggerEvent &humiTriggerEvent
// 20240425 Added device name
//
// To Do:
// -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// https://github.com/matthias-bs/ATC_MiThermometer
// Mijia lywsd03mmc thermometers are first to be loaded with a custom firmware as per:
// https://pvvx.github.io/ATC_MiThermometer/TelinkMiFlasher.html
//
// 20240425 Added device name

#include "ATC_MiThermometer.h"

Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=ATC_MiThermometer
version=0.4.1
version=0.4.2
author=Matthias Prinke <matthias-bs@web.de>
maintainer=Matthias Prinke <matthias-bs@web.de>
sentence=Arduino library for BLE ATC_MiThermometer thermometer/hygrometer sensors.
Expand Down
11 changes: 7 additions & 4 deletions src/ATC_MiThermometer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
//
// 20221123 Created
// 20221223 Added support for ATC1441 format
// 20240403 Added reedSwitchState, gpioTrgOutput, controlParameters,
// tempTriggerEvent &humiTriggerEvent
// 20240425 Added device name
//
// ToDo:
// -
Expand Down Expand Up @@ -73,12 +76,12 @@ class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {


// Set up BLE scanning
void ATC_MiThermometer::begin(void)
void ATC_MiThermometer::begin(bool activeScan)
{
NimBLEDevice::init("");
_pBLEScan = BLEDevice::getScan(); //create new scan
_pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
_pBLEScan->setActiveScan(false); //active scan uses more power, but get results faster
_pBLEScan->setActiveScan(activeScan); //active scan uses more power, but get results faster
_pBLEScan->setInterval(100);
_pBLEScan->setFilterPolicy(BLE_HCI_SCAN_FILT_NO_WL);
_pBLEScan->setWindow(99); // less or equal setInterval value
Expand Down Expand Up @@ -133,7 +136,7 @@ unsigned ATC_MiThermometer::getData(uint32_t duration) {
data[n].batt_level = foundDevices.getDevice(i).getServiceData().c_str()[12];

// Count
data[n].count = foundDevices.getDevice(i).getServiceData().c_str()[13];
data[n].count = foundDevices.getDevice(i).getServiceData().c_str()[13];

//Flags
uint8_t flagsByte = foundDevices.getDevice(i).getServiceData().c_str()[14];
Expand Down Expand Up @@ -178,7 +181,7 @@ unsigned ATC_MiThermometer::getData(uint32_t duration) {
return foundDevices.getCount();
}


// Set all array members invalid
void ATC_MiThermometer::resetData(void)
{
Expand Down
14 changes: 11 additions & 3 deletions src/ATC_MiThermometer.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@
// History:
//
// 20221123 Created
// 20240403 Added reedSwitchState, gpioTrgOutput, controlParameters,
// tempTriggerEvent &humiTriggerEvent
// 20240425 Added device name
// 20240426 Added parameter activeScan to begin()
//
// ToDo:
// -
Expand Down Expand Up @@ -92,9 +96,13 @@ class ATC_MiThermometer {
};

/*!
\brief Initialization.
*/
void begin(void);
* \brief Initialization.
*
* \param activeScan Set to true for achtive scan, which uses more power,
* but get results faster. As a side effect, the device name
* is received (most of the times).
*/
void begin(bool activeScan = true);

/*!
\brief Delete results from BLEScan buffer to release memory.
Expand Down
Loading