8000 ibeacon UUId & by markiv25 · Pull Request #675 · nkolban/esp32-snippets · GitHub
[go: up one dir, main page]

Skip to content

ibeacon UUId & #675

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

Merged
merged 103 commits into from
Nov 9, 2018
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
937a81c
Work in progress for DMA driver
nkolban Jun 8, 2018
75d405c
Set spi_bus_config_t and spi_device_interface_config_t flags
HanVertegaal Jun 14, 2018
61604a9
Merge pull request #564 from HanVertegaal/Set-SPI-flags
nkolban Jun 15, 2018
f778541
splitted BLEScan::start to blocking & non-blocking oveloads
olehs Jun 17, 2018
eead14a
Add remove service
chegewara Jun 19, 2018
21ba4a8
- Added way to remove services.
jim-ber Jun 20, 2018
07c4b82
- Updated comments for documentation.
jim-ber Jun 21, 2018
de9d413
Add Arduino compatibility to BLEDevice::init
me-no-dev Jun 21, 2018
798be6b
Merge pull request #576 from me-no-dev/master
nkolban Jun 21, 2018
c054b18
Merge pull request #567 from olehs/patch-scan
nkolban Jun 22, 2018
d875fec
Merge pull request #575 from jim-ber/master
nkolban Jun 22, 2018
4743dfc
Addition of missing header for Arduino
nkolban Jun 23, 2018
7e1cf23
added a way to connect to a Station while keeping the AP running
damonsmith Jun 26, 2018
18a03f9
fixed to just use default value params
damonsmith Jun 26, 2018
cc56443
fix up comments on connectAP
damonsmith Jun 26, 2018
8dbdaa5
added getServiceByUUID() to BLEServer
Donderda Jun 26, 2018
faf2839
Merge pull request #582 from damonsmith/master
nkolban Jun 26, 2018
d6ef149
FIX: BLESecurity.h -> BLESecurityCallbacks.
joaoc Jul 5, 2018
74b056f
Handle `response` argument for BLERemoteDescriptor#writeValue()
robertklep Jul 6, 2018
14cdfb6
Merge remote-tracking branch 'origin'
chegewara Jul 10, 2018
caa546a
Update remote characteristic to register for notify/indications (writ…
chegewara Jul 10, 2018
49d6aba
Add onConnect callback with parameter to allow retrieve client MAC
chegewara Jul 10, 2018
1012efc
Add read raw data from remote characteristic
chegewara Jul 10, 2018
cf45586
Merge pull request #601 from chegewara/master
nkolban Jul 10, 2018
c224f3c
Merge pull request #595 from robertklep/remote-ble-descriptor-fix
nkolban Jul 10, 2018
8980fb1
Merge pull request #594 from joaoc/master
nkolban Jul 10, 2018
8cf6891
Quick fix
chegewara Jul 10, 2018
11125da
Merge pull request #602 from chegewara/master
nkolban Jul 10, 2018
db78095
Sync
nkolban Aug 6, 2018
f50bcb0
sync
nkolban Aug 6, 2018
35c8cb7
Merge pull request #1 from nkolban/master
Donderda Aug 7, 2018
5f0a168
fixes #447
Donderda Aug 7, 2018
d04db84
Merge pull request #622 from Donderda/feature_eddystone
nkolban Aug 7, 2018
b1922a8
Initial samples for VSCode
nkolban Aug 16, 2018
2c8b0f2
Merge branch 'master' of https://github.com/nkolban/esp32-snippets.git
nkolban Aug 16, 2018
ed1de4b
Addition of GCP JWT sample
nkolban Aug 26, 2018
1d976d2
Create pcf8523
menesesleonardo Aug 29, 2018
297db2c
Merge pull request #635 from menesesleonardo/patch-1
nkolban Aug 29, 2018
f8d3438
Fix params passed to i2c.init() to include DEVICE_ADDRESS in the firs…
SolipsistD Sep 3, 2018
2b7d590
Merge pull request #640 from SolipsistD/i2c-tests
nkolban Sep 3, 2018
b0503a6
add multiple servers support
chegewara Sep 5, 2018
fc0a957
I2C: fix ignored clockSpeed
toxuin Sep 15, 2018
de865db
Fix a bug in U8G2 HAL SPI initialize
aodzip Sep 23, 2018
83ca169
Update GeneralUtils.cpp
hetlelid Sep 26, 2018
5ce0c50
update BLECharacteristic.h to include `getData` call
pvtmert Sep 27, 2018
7e64a01
update BLECharacteristic.cpp to proxy `getData` function
pvtmert Sep 27, 2018
dcd7492
Merge pull request #648 from toxuin/master
nkolban Sep 28, 2018
21a1850
Merge pull request #652 from aodzip/patch-1
nkolban Sep 28, 2018
f61031c
Merge pull request #657 from hetlelid/patch-2
nkolban Sep 28, 2018
e2d9976
Merge pull request #658 from pvtmert/patch-1
nkolban Sep 28, 2018
cc85e03
Added switch case to fix compilation
toxuin Oct 1, 2018
db2ce46
Merge pull request #665 from toxuin/master
nkolban Oct 1, 2018
2147b7c
Merge branch 'master' of https://github.com/nkolban/esp32-snippets
chegewara Oct 1, 2018
bb251b7
move m_advertising to BLEDevice
chegewara Oct 1, 2018
e827bd9
Merge pull request #667 from chegewara/master
nkolban Oct 1, 2018
b5ab56a
Revert "Move m_advertising to BLEDevice"
chegewara Oct 1, 2018
ade8bcd
Merge pull request #668 from chegewara/revert-667-master
nkolban Oct 1, 2018
874ce79
move m_bleAdvertising to BLEDevice
chegewara Oct 1, 2018
ae9c8a0
Merge pull request #670 from chegewara/wip
nkolban Oct 2, 2018
482f7b4
some small bugfixes
chegewara Oct 2, 2018
a916fba
Merge pull request #671 from chegewara/bugfix
nkolban Oct 2, 2018
b1ef951
fix macOS compatibility
chegewara Oct 3, 2018
bac1b24
fix macOS HID compatibility
chegewara Oct 3, 2018
8f106d7
Merge pull request #672 from chegewara/multi_connect
nkolban Oct 10, 2018
b17e346
Common code style
toxuin Oct 14, 2018
5501cf6
Sanitize Neopixel logging
toxuin Oct 14, 2018
466332c
BT: uint16_t numHandles
toxuin Oct 14, 2018
814c324
FreeRTOS: Check if value is pdTRUE
toxuin Oct 14, 2018
a3b7fe3
Return bool from Ringbuffer::send
toxuin Oct 14, 2018
409a178
FreeRTOS: Stack size is uint32_t
toxuin Oct 14, 2018
009d003
GPIO: Add checks for bool returns
toxuin Oct 14, 2018
18e77c7
I2C: Configurable pullups
toxuin Oct 14, 2018
7843ceb
Memory.cpp: variable size fixes
toxuin Oct 14, 2018
e048557
PubSub: pass pdTRUE instead of true
toxuin Oct 14, 2018
db61e20
Fixed ternary operator spacing
toxuin Oct 14, 2018
61bb6ed
PWM: idle level is bool
toxuin Oct 14, 2018
871a946
WebSocket: Opcodes are uint8_t
toxuin Oct 14, 2018
e215f9d
PCF8574 & PCF8575: i2c on heap
toxuin Oct 14, 2018
bd24fab
Release memory from CLASSIC_BT when not enabled
toxuin Oct 14, 2018
d1127a6
Merge pull request #686 from toxuin/neopixel-logging
nkolban Oct 14, 2018
4e0fc44
Merge pull request #687 from toxuin/num-handles
nkolban Oct 14, 2018
d554704
Merge pull request #688 from toxuin/freertos-checks
nkolban Oct 14, 2018
ec342a3
Merge pull request #689 from toxuin/freertos-ringbuffer-check
nkolban Oct 14, 2018
d9a31c2
Merge pull request #690 from toxuin/freertos-stack-unsigned
nkolban Oct 14, 2018
51e943f
Merge pull request #692 from toxuin/gpio-check
nkolban Oct 14, 2018
3067f78
Merge pull request #693 from toxuin/i2c-pullup
nkolban Oct 14, 2018
6836550
Merge pull request #694 from toxuin/memory-varsizes
nkolban Oct 14, 2018
def0952
Merge pull request #695 from toxuin/pubsub-args
nkolban Oct 14, 2018
25e694e
Merge pull request #696 from toxuin/bt-classic-release
nkolban Oct 14, 2018
9d2d2ed
Merge pull request #697 from toxuin/pwm-idleLevel
nkolban Oct 14, 2018
e4ce7da
Merge pull request #698 from toxuin/websocket-types
nkolban Oct 15, 2018
f8d6a65
Merge pull request #699 from toxuin/PCF8574-i2c
nkolban Oct 15, 2018
b367e5a
Merge branch 'master' into code-cleanup
toxuin Oct 15, 2018
b50dec3
Fix array dereferencing
toxuin Oct 15, 2018
2dcd6aa
Fix HttpResponse line mangling
toxuin Oct 15, 2018
4cfef4d
Change return type of bitSize() to uint8_t
toxuin Oct 15, 2018
d14071a
Fix line mangling on merge
toxuin Oct 15, 2018
a338ca1
Merge pull request #691 from toxuin/code-cleanup
nkolban Oct 15, 2018
5a97e68
added getServiceCount() to BLEServer.cpp
Donderda Oct 15, 2018
6a8c821
improved getServiceCount()
Donderda Oct 15, 2018
693e2c9
improved BLEServer::getServiceCount() and added parameter for optiona…
Donderda Oct 17, 2018
96f76c0
fixed some issues
Donderda Oct 17, 2018
e742546
Merge pull request #700 from Donderda/master
nkolban Oct 17, 2018
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
4 changes: 2 additions & 2 deletions cpp_utils/BLEService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static const char* LOG_TAG = "BLEService"; // Tag for logging.
* @param [in] uuid The UUID of the service.
* @param [in] numHandles The maximum number of handles associated with the service.
*/
BLEService::BLEService(const char* uuid, uint32_t numHandles) : BLEService(BLEUUID(uuid), numHandles) {
BLEService::BLEService(const char* uuid, uint16_t numHandles) : BLEService(BLEUUID(uuid), numHandles) {
}


Expand All @@ -44,7 +44,7 @@ BLEService::BLEService(const char* uuid, uint32_t numHandles) : BLEService(BLEUU
* @param [in] uuid The UUID of the service.
* @param [in] numHandles The maximum number of handles associated with the service.
*/
BLEService::BLEService(BLEUUID uuid, uint32_t numHandles) {
BLEService::BLEService(BLEUUID uuid, uint16_t numHandles) {
m_uuid = uuid;
m_handle = NULL_HANDLE;
m_pServer = nullptr;
Expand Down
6 changes: 3 additions & 3 deletions cpp_utils/BLEService.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ class BLEService {
uint8_t m_id = 0;

private:
BLEService(const char* uuid, uint32_t numHandles);
BLEService(BLEUUID uuid, uint32_t numHandles);
BLEService(const char* uuid, uint16_t numHandles);
BLEService(BLEUUID uuid, uint16_t numHandles);
friend class BLEServer;
friend class BLEServiceMap;
friend class BLEDescriptor;
Expand All @@ -84,7 +84,7 @@ class BLEService {
FreeRTOS::Semaphore m_semaphoreStartEvt = FreeRTOS::Semaphore("StartEvt");
FreeRTOS::Semaphore m_semaphoreStopEvt = FreeRTOS::Semaphore("StopEvt");

uint32_t m_numHandles;
uint16_t m_numHandles;

BLECharacteristic* getLastCreatedCharacteristic();
void handleGATTServerEvent(esp_gatts_cb_event_t event, esp_gatt_if_t gatts_if, esp_ble_gatts_cb_param_t* param);
Expand Down
10 changes: 5 additions & 5 deletions cpp_utils/FreeRTOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void FreeRTOS::sleep(uint32_t ms) {
* @param[in] param An optional parameter to be passed to the started task.
* @param[in] stackSize An optional paremeter supplying the size of the stack in which to run the task.
*/
void FreeRTOS::startTask(void task(void*), std::string taskName, void* param, int stackSize) {
void FreeRTOS::startTask(void task(void*), std::string taskName, void* param, uint32_t stackSize) {
::xTaskCreate(task, taskName.data(), stackSize, param, 5, NULL);
} // startTask

Expand Down Expand Up @@ -162,7 +162,7 @@ bool FreeRTOS::Semaphore::take(std::string owner) {
if (m_usePthreads) {
pthread_mutex_lock(&m_pthread_mutex);
} else {
rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY);
rc = ::xSemaphoreTake(m_semaphore, portMAX_DELAY) == pdTRUE;
}
m_owner = owner;
if (rc) {
Expand All @@ -187,7 +187,7 @@ bool FreeRTOS::Semaphore::take(uint32_t timeoutMs, std::string owner) {
if (m_usePthreads) {
assert(false); // We apparently don't have a timed wait for pthreads.
} else {
rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS);
rc = ::xSemaphoreTake(m_semaphore, timeoutMs / portTICK_PERIOD_MS) == pdTRUE;
}
m_owner = owner;
if (rc) {
Expand Down Expand Up @@ -262,8 +262,8 @@ void Ringbuffer::returnItem(void* item) {
* @param [in] wait How long to wait before giving up. The default is to wait indefinitely.
* @return
*/
uint32_t Ringbuffer::send(void* data, size_t length, TickType_t wait) {
return ::xRingbufferSend(m_handle, data, length, wait);
bool Ringbuffer::send(void* data, size_t length, TickType_t wait) {
B422 return ::xRingbufferSend(m_handle, data, length, wait) == pdTRUE;
} // send


4 changes: 2 additions & 2 deletions cpp_utils/FreeRTOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
class FreeRTOS {
public:
static void sleep(uint32_t ms);
static void startTask(void task(void*), std::string taskName, void* param = nullptr, int stackSize = 2048);
static void startTask(void task(void*), std::string taskName, void* param = nullptr, uint32_t stackSize = 2048);
static void deleteTask(TaskHandle_t pTask = nullptr);

static uint32_t getTimeSinceStart();
Expand Down Expand Up @@ -63,7 +63,7 @@ class Ringbuffer {

void* receive(size_t* size, TickType_t wait = portMAX_DELAY);
void returnItem(void* item);
uint32_t send(void* data, size_t length, TickType_t wait = portMAX_DELAY);
bool send(void* data, size_t length, TickType_t wait = portMAX_DELAY);
private:
RingbufHandle_t m_handle;
};
Expand Down
4 changes: 2 additions & 2 deletions cpp_utils/GPIO.cpp
< F438 thead class="sr-only">
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void ESP32CPP::GPIO::low(gpio_num_t pin) {
* @return True if the pin is high, false if the pin is low.
*/
bool ESP32CPP::GPIO::read(gpio_num_t pin) {
return ::gpio_get_level(pin);
return ::gpio_get_level(pin) == 1;
} // read


Expand Down Expand Up @@ -179,7 +179,7 @@ void ESP32CPP::GPIO::setOutput(gpio_num_t pin) {
*/
void ESP32CPP::GPIO::write(gpio_num_t pin, bool value) {
//ESP_LOGD(LOG_TAG, ">> write: pin: %d, value: %d", pin, value);
esp_err_t errRc = ::gpio_set_level(pin, value);
esp_err_t errRc = ::gpio_set_level(pin, value ? 1 : 0);
if (errRc != ESP_OK) {
ESP_LOGE(LOG_TAG, "<< gpio_set_level: pin=%d, rc=%d %s", pin, errRc, GeneralUtils::errorToString(errRc));
}
Expand Down
6 changes: 3 additions & 3 deletions cpp_utils/I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ uint8_t I2C::getAddress() const {
* @param [in] sclPin The pin to use for SCL clock.
* @return N/A.
*/
void I2C::init(uint8_t address, gpio_num_t sdaPin, gpio_num_t sclPin, uint32_t clockSpeed, i2c_port_t portNum) {
void I2C::init(uint8_t address, gpio_num_t sdaPin, gpio_num_t sclPin, uint32_t clockSpeed, i2c_port_t portNum, bool pullup) {
ESP_LOGD(LOG_TAG, ">> I2c::init. address=%d, sda=%d, scl=%d, clockSpeed=%d, portNum=%d", address, sdaPin, sclPin, clockSpeed, portNum);
assert(portNum < I2C_NUM_MAX);
m_portNum = portNum;
Expand All @@ -106,8 +106,8 @@ void I2C::init(uint8_t address, gpio_num_t sdaPin, gpio_num_t sclPin, uint32_t c
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = sdaPin;
conf.scl_io_num = sclPin;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.sda_pullup_en = pullup ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE;
conf.scl_pullup_en = pullup ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE;
conf.master.clk_speed = clockSpeed;
esp_err_t errRc = ::i2c_param_config(m_portNum, &conf);
if (errRc != ESP_OK) {
Expand Down
2 changes: 1 addition & 1 deletion cpp_utils/I2C.h
10000
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class I2C {
void beginTransaction();
void endTransaction();
uint8_t getAddress() const;
void init(uint8_t address, gpio_num_t sdaPin = DEFAULT_SDA_PIN, gpio_num_t sclPin = DEFAULT_CLK_PIN, uint32_t clkSpeed = DEFAULT_CLK_SPEED, i2c_port_t portNum = I2C_NUM_0);
void init(uint8_t address, gpio_num_t sdaPin = DEFAULT_SDA_PIN, gpio_num_t sclPin = DEFAULT_CLK_PIN, uint32_t clkSpeed = DEFAULT_CLK_SPEED, i2c_port_t portNum = I2C_NUM_0, bool pullup = true);
void read(uint8_t* bytes, size_t length, bool ack = true);
void read(uint8_t* byte, bool ack = true);
void scan();
Expand Down
2 changes: 1 addition & 1 deletion cpp_utils/Memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ size_t Memory::m_lastHeapSize = 0;

/* STATIC */ void Memory::dumpHeapChange(std::string tag) {
size_t currentUsage = heap_caps_get_free_size(MALLOC_CAP_8BIT);
int diff = currentUsage - m_lastHeapSize;
size_t diff = currentUsage - m_lastHeapSize;
ESP_LOGD(LOG_TAG, "%s: Heap changed by %d bytes (%d to %d)", tag.c_str(), diff, m_lastHeapSize, currentUsage);
m_lastHeapSize = currentUsage;
} // dumpHeapChange
Expand Down
15 changes: 9 additions & 6 deletions cpp_utils/NeoPixelWiFiEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
* Author: kolban
*/
#include <stdio.h>
#include <esp_log.h>
#include "NeoPixelWiFiEventHandler.h"

static const char* LOG_TAG = "NeoPixelWiFiEventHandler";

NeoPixelWiFiEventHandler::NeoPixelWiFiEventHandler(gpio_num_t gpioPin) {
this->gpioPin = gpioPin;
ws2812 = new WS2812(gpioPin, 8);
Expand All @@ -17,42 +20,42 @@ NeoPixelWiFiEventHandler::~NeoPixelWiFiEventHandler() {
}

esp_err_t NeoPixelWiFiEventHandler::apStart() {
printf("XXX apStart\n");
ESP_LOGD(LOG_TAG, "XXX apStart");
ws2812->setPixel(0, 0, 00, 64);
ws2812->show();
return ESP_OK;
}

esp_err_t NeoPixelWiFiEventHandler::staConnected(system_event_sta_connected_t info) {
printf("XXX staConnected\n");
ESP_LOGD(LOG_TAG, "XXX staConnected");
ws2812->setPixel(0, 57, 89, 66);
ws2812->show();
return ESP_OK;
}

esp_err_t NeoPixelWiFiEventHandler::staDisconnected(system_event_sta_disconnected_t info) {
printf("XXX staDisconnected\n");
ESP_LOGD(LOG_TAG, "XXX staDisconnected");
ws2812->setPixel(0, 64, 0, 0);
ws2812->show();
return ESP_OK;
}

esp_err_t NeoPixelWiFiEventHandler::staStart() {
printf("XXX staStart\n");
ESP_LOGD(LOG_TAG, "XXX staStart");
ws2812->setPixel(0, 64, 64, 0);
ws2812->show();
return ESP_OK;
}

esp_err_t NeoPixelWiFiEventHandler::staGotIp(system_event_sta_got_ip_t info) {
printf("XXX staGotIp\n");
ESP_LOGD(LOG_TAG, "XXX staGotIp");
ws2812->setPixel(0, 0, 64, 0);
ws2812->show();
return ESP_OK;
}

esp_err_t NeoPixelWiFiEventHandler::wifiReady() {
printf("XXX wifiReady\n");
ESP_LOGD(LOG_TAG, "XXX wifiReady");
ws2812->setPixel(0, 64, 64, 0);
ws2812->show();
return ESP_OK;
Expand Down
18 changes: 10 additions & 8 deletions cpp_utils/PCF8574.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
* @param [in] address The %I2C address of the device on the %I2C bus.
*/
PCF8574::PCF8574(uint8_t address) {
i2c.setAddress(address);
i2c = new I2C();
i2c->setAddress(address);
lastWrite = 0;
}

Expand All @@ -27,6 +28,7 @@ PCF8574::PCF8574(uint8_t address) {
* @brief Class instance destructor.
*/
PCF8574::~PCF8574() {
delete i2c;
}


Expand All @@ -36,9 +38,9 @@ PCF8574::~PCF8574() {
*/
uint8_t PCF8574::read() {
uint8_t value;
i2c.beginTransaction();
i2c.read(&value,true);
i2c.endTransaction();
i2c->beginTransaction();
i2c->read(&value,true);
i2c->endTransaction();
return value;
} // read

Expand All @@ -65,9 +67,9 @@ void PCF8574::write(uint8_t value) {
if (invert) {
value = ~value;
}
i2c.beginTransaction();
i2c.write(value, true);
i2c.endTransaction();
i2c->beginTransaction();
i2c->write(value, true);
i2c->endTransaction();
lastWrite = value;
} // write

Expand Down Expand Up @@ -114,5 +116,5 @@ void PCF8574::setInvert(bool value) {
* @param [in] clkPin The pin to use for the %I2C CLK functions.
*/
void PCF8574::init(gpio_num_t sdaPin, gpio_num_t clkPin) {
i2c.init(0, sdaPin, clkPin);
i2c->init(0, sdaPin, clkPin);
} // init
2 changes: 1 addition & 1 deletion cpp_utils/PCF8574.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PCF8574 {
void writeBit(uint8_t bit, bool value);

private:
I2C i2c = I2C();
I2C* i2c;
uint8_t lastWrite;
bool invert = false;

Expand Down
22 changes: 12 additions & 10 deletions cpp_utils/PCF8575.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* @param [in] address The %I2C address of the device on the %I2C bus.
*/
PCF8575::PCF8575(uint8_t address) {
i2c.setAddress(address);
i2c = new I2C();
i2c->setAddress(address);
m_lastWrite = 0;
}

Expand All @@ -28,6 +29,7 @@ PCF8575::PCF8575(uint8_t address) {
* @brief Class instance destructor.
*/
PCF8575::~PCF8575() {
delete i2c;
}


Expand All @@ -37,10 +39,10 @@ PCF8575::~PCF8575() {
*/
uint16_t PCF8575::read() {
uint16_t value;
i2c.beginTransaction();
i2c.read((uint8_t*) &value, true);
i2c.read(((uint8_t*) &value) + 1, true);
i2c.endTransaction();
i2c->beginTransaction();
i2c->read((uint8_t*) &value, true);
i2c->read(((uint8_t*) &value) + 1, true);
i2c->endTransaction();
return value;
} // read

Expand All @@ -67,10 +69,10 @@ void PCF8575::write(uint16_t value) {
if (invert) {
value = ~value;
}
i2c.beginTransaction();
i2c.write(value & 0xff, true);
i2c.write((value >> 8) & 0xff, true);
i2c.endTransaction();
i2c->beginTransaction();
i2c->write(value & 0xff, true);
i2c->write((value >> 8) & 0xff, true);
i2c->endTransaction();
m_lastWrite = value;
} // write

Expand Down Expand Up @@ -117,5 +119,5 @@ void PCF8575::setInvert(bool value) {
* @param [in] clkPin The pin to use for the %I2C CLK functions.
*/
void PCF8575::init(gpio_num_t sdaPin, gpio_num_t clkPin) {
i2c.init(0, sdaPin, clkPin);
i2c->init(0, sdaPin, clkPin);
} // init
4 changes: 2 additions & 2 deletions cpp_utils/PCF8575.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class PCF8575 {
void writeBit(uint16_t bit, bool value);

private:
I2C i2c = I2C();
uint8_t m_lastWrite;
I2C* i2c;
uint16_t m_lastWrite;
bool invert = false;
};

Expand Down
2 changes: 1 addition & 1 deletion cpp_utils/PWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,5 @@ void PWM::setFrequency(uint32_t freq) {
* @return N/A.
*/
void PWM::stop(bool idleLevel) {
ESP_ERROR_CHECK(::ledc_stop(LEDC_HIGH_SPEED_MODE, m_channel, idleLevel));
ESP_ERROR_CHECK(::ledc_stop(LEDC_HIGH_SPEED_MODE, m_channel, idleLevel ? 1 : 0));
} // stop
7 changes: 3 additions & 4 deletions cpp_utils/PubSubClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,10 @@ void PubSubClient::setup() {
UNSUBACK_Outstanding = false;

keepAliveTimer = new FreeRTOSTimer((char*) "keepAliveTimer",
(MQTT_KEEPALIVE * 1000) / portTICK_PERIOD_MS, true, this,
(MQTT_KEEPALIVE * 1000) / portTICK_PERIOD_MS, pdTRUE, this,
keepAliveTimerMapper);
timeoutTimer = new FreeRTOSTimer((char*) "timeoutTimer",
(MQTT_KEEPALIVE * 1000) / portTICK_PERIOD_MS, true, this,
(MQTT_KEEPALIVE * 1000) / portTICK_PERIOD_MS, pdTRUE, this,
timeoutTimerMapper);
m_task = new PubSubClientTask("PubSubClientTask");
} // setup
Expand Down Expand Up @@ -399,8 +399,7 @@ bool PubSubClient::connect() {
* @param N/A.
* @return Number of received bytes.
*/
uint16_t PubSubClient::readPacket() {

size_t PubSubClient::readPacket() {
size_t res = _client->receive(buffer, MQTT_MAX_PACKET_SIZE);

if (res > MQTT_MAX_PACKET_SIZE) {
Expand Down
2 changes: 1 addition & 1 deletion cpp_utils/PubSubClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class PubSubClient {

MQTT_CALLBACK_SIGNATURE;
void setup();
uint16_t readPacket();
size_t readPacket();
bool write(uint8_t header, uint8_t* buf, uint16_t length);
uint16_t writeString(const char* string, uint8_t* buf, uint16_t pos);
void parseData(mqtt_message* msg, uint16_t len);
Expand Down
Loading
0