8000 Merge branch 'master' of https://github.com/nkolban/esp32-snippets · twellocity/esp32-snippets@2147b7c · GitHub
[go: up one dir, main page]

Skip to content

Commit 2147b7c

Browse files
committed
2 parents b0503a6 + db2ce46 commit 2147b7c

File tree

6 files changed

+28
-16
lines changed

6 files changed

+28
-16
lines changed

cpp_utils/BLECharacteristic.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,14 @@ std::string BLECharacteristic::getValue() {
198198
return m_value.getValue();
199199
} // getValue
200200

201+
/**
202+
* @brief Retrieve the current raw data of the characteristic.
203+
* @return A pointer to storage containing the current characteristic data.
204+
*/
205+
uint8_t* BLECharacteristic::getData() {
206+
return m_value.getData();
207+
} // getData
208+
201209

202210
/**
203211
* Handle a GATT server event.

cpp_utils/BLECharacteristic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class BLECharacteristic {
6565
//size_t getLength();
6666
BLEUUID getUUID();
6767
std::string getValue();
68+
uint8_t* getData();
6869

6970
void indicate();
7071
void notify();

cpp_utils/BLEUtils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,8 @@ std::string BLEUtils::gattServerEventTypeToString(esp_gatts_cb_event_t eventType
10581058
case ESP_GATTS_SET_ATTR_VAL_EVT:
10591059
return "ESP_GATTS_SET_ATTR_VAL_EVT";
10601060

1061+
case ESP_GATTS_SEND_SERVICE_CHANGE_EVT:
1062+
return "ESP_GATTS_SEND_SERVICE_CHANGE_EVT";
10611063
}
10621064
return "Unknown";
10631065
} // gattServerEventTypeToString

cpp_utils/GeneralUtils.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ void GeneralUtils::dumpInfo() {
109109
size_t freeHeap = heap_caps_get_free_size(MALLOC_CAP_8BIT);
110110
esp_chip_info_t chipInfo;
111111
esp_chip_info(&chipInfo);
112-
ESP_LOGD(LOG_TAG, "--- dumpInfo ---");
113-
ESP_LOGD(LOG_TAG, "Free heap: %d", freeHeap);
114-
ESP_LOGD(LOG_TAG, "Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
115-
ESP_LOGD(LOG_TAG, "ESP-IDF version: %s", esp_get_idf_version());
116-
ESP_LOGD(LOG_TAG, "---");
112+
ESP_LOGV(LOG_TAG, "--- dumpInfo ---");
113+
ESP_LOGV(LOG_TAG, "Free heap: %d", freeHeap);
114+
ESP_LOGV(LOG_TAG, "Chip Info: Model: %d, cores: %d, revision: %d", chipInfo.model, chipInfo.cores, chipInfo.revision);
115+
ESP_LOGV(LOG_TAG, "ESP-IDF version: %s", esp_get_idf_version());
116+
ESP_LOGV(LOG_TAG, "---");
117117
} // dumpInfo
118118

119119

@@ -231,7 +231,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
231231
if (index % 16 == 0) {
232232
strcpy(hexBuf, hex.str().c_str());
233233
strcpy(asciiBuf, ascii.str().c_str());
234-
ESP_LOGD(tag, "%s %s", hexBuf, asciiBuf);
234+
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
235235
hex.str("");
236236
ascii.str("");
237237
}
@@ -243,8 +243,8 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
243243
}
244244
strcpy(hexBuf, hex.str().c_str());
245245
strcpy(asciiBuf, ascii.str().c_str());
246-
ESP_LOGD(tag, "%s %s", hexBuf, asciiBuf);
247-
//ESP_LOGD(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
246+
ESP_LOGV(tag, "%s %s", hexBuf, asciiBuf);
247+
//ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
248248
}
249249
FreeRTOS::sleep(1000);
250250
}
@@ -266,7 +266,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
266266
}
267267
index++;
268268
if (index % 16 == 0) {
269-
ESP_LOGD(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
269+
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
270270
hex.str("");
271271
ascii.str("");
272272
}
@@ -276,7 +276,7 @@ void GeneralUtils::hexDump(uint8_t* pData, uint32_t length) {
276276
hex << " ";
277277
index++;
278278
}
279-
ESP_LOGD(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
279+
ESP_LOGV(tag, "%s %s", hex.str().c_str(), ascii.str().c_str());
280280
}
281281
FreeRTOS::sleep(1000);
282282
}
@@ -296,8 +296,8 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
296296
char tempBuf[80];
297297
uint32_t lineNumber = 0;
298298

299-
ESP_LOGD(LOG_TAG, " 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
300-
ESP_LOGD(LOG_TAG, " -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
299+
ESP_LOGV(LOG_TAG, " 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f");
300+
ESP_LOGV(LOG_TAG, " -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
301301
strcpy(ascii, "");
302302
strcpy(hex, "");
303303
uint32_t index=0;
@@ -312,7 +312,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
312312
strcat(ascii, tempBuf);
313313
index++;
314314
if (index % 16 == 0) {
315-
ESP_LOGD(LOG_TAG, "%.4x %s %s", lineNumber*16, hex, ascii);
315+
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber*16, hex, ascii);
316316
strcpy(ascii, "");
317317
strcpy(hex, "");
318318
lineNumber++;
@@ -323,7 +323,7 @@ void GeneralUtils::hexDump(const uint8_t* pData, uint32_t length) {
323323
strcat(hex, " ");
324324
index++;
325325
}
326-
ESP_LOGD(LOG_TAG, "%.4x %s %s", lineNumber*16, hex, ascii);
326+
ESP_LOGV(LOG_TAG, "%.4x %s %s", lineNumber*16, hex, ascii);
327327
}
328328
} // hexDump
329329

cpp_utils/I2C.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ void I2C::init(uint8_t address, gpio_num_t sdaPin, gpio_num_t sclPin, uint32_t c
109109
conf.scl_io_num = sclPin;
110110
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
111111
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
112-
conf.master.clk_speed = 100000;
112+
conf.master.clk_speed = clockSpeed;
113113
esp_err_t errRc = ::i2c_param_config(m_portNum, &conf);
114114
if (errRc != ESP_OK) {
115115
ESP_LOGE(LOG_TAG, "i2c_param_config: rc=%d %s", errRc, GeneralUtils::errorToString(errRc));
@@ -279,7 +279,7 @@ void I2C::write(uint8_t byte, bool ack) {
279279
if (debug) {
280280
ESP_LOGD(LOG_TAG, "write(val=0x%.2x, ack=%d)", byte, ack);
281281
}
282-
if (m_directionKnown == false) {
282+
if (!m_directionKnown) {
283283
m_directionKnown = true;
284284
esp_err_t errRc = ::i2c_master_write_byte(m_cmd, (m_address << 1) | I2C_MASTER_WRITE, !ack);
285285
if (errRc != ESP_OK) {

hardware/displays/U8G2/u8g2_esp32_hal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ uint8_t u8g2_esp32_spi_byte_cb(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void
4747
}
4848

4949
spi_bus_config_t bus_config;
50+
memset(&bus_config, 0, sizeof(spi_bus_config_t));
5051
bus_config.sclk_io_num = u8g2_esp32_hal.clk; // CLK
5152
bus_config.mosi_io_num = u8g2_esp32_hal.mosi; // MOSI
5253
bus_config.miso_io_num = -1; // MISO

0 commit comments

Comments
 (0)
0