8000 Add readFloat to BLE (#3321) · MartinHruza/arduino-esp32@24b277a · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 24b277a

Browse files
copercinime-no-dev
authored andcommitted
Add readFloat to BLE (espressif#3321)
* Add readFloat * Add readFloat to BLE
1 parent c2b3f2d commit 24b277a

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

libraries/BLE/src/BLERemoteCharacteristic.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,17 @@ uint8_t BLERemoteCharacteristic::readUInt8() {
389389
return 0;
390390
} // readUInt8
391391

392+
/**
393+
* @brief Read a float value.
394+
* @return the float value.
395+
*/
396+
float BLERemoteCharacteristic::readFloat() {
397+
std::string value = readValue();
398+
if (value.length() >= 4) {
399+
return *(float*)(value.data());
400+
}
401+
return 0.0;
402+
} // readFloat
392403

393404
/**
394405
* @brief Read the value of the remote characteristic.

libraries/BLE/src/BLERemoteCharacteristic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line ch 6492 ange
@@ -45,6 +45,7 @@ class BLERemoteCharacteristic {
4545
uint8_t readUInt8();
4646
uint16_t readUInt16();
4747
uint32_t readUInt32();
48+
float readFloat();
4849
void registerForNotify(notify_callback _callback, bool notifications = true);
4950
void writeValue(uint8_t* data, size_t length, bool response = false);
5051
void writeValue(std::string newValue, bool response = false);

0 commit comments

Comments
 (0)
0