-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: read wifi credentials via ble for ota
- Loading branch information
Showing
12 changed files
with
359 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
senseBox-bike-atrai-v2/src/ble/Utf16Converter/Utf16Converter.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include "Utf16Converter.h" | ||
|
||
String utf16leToString(uint8_t *data, size_t length) | ||
{ | ||
String result = ""; | ||
|
||
// Ensure the length is even | ||
if (length % 2 != 0) | ||
{ | ||
return result; | ||
} | ||
|
||
for (size_t i = 0; i < length; i += 2) | ||
{ | ||
// Combine the two bytes to form a UTF-16 character | ||
uint16_t utf16_char = data[i] | (data[i + 1] << 8); | ||
|
||
// If the character is null (0x0000), break the loop as it indicates the end of the string | ||
if (utf16_char == 0x0000) | ||
{ | ||
break; | ||
} | ||
|
||
// Append the character to the result string if it is within the ASCII range | ||
if (utf16_char <= 0x007F) | ||
{ | ||
result += (char)utf16_char; | ||
} | ||
} | ||
|
||
return result; | ||
} |
8 changes: 8 additions & 0 deletions
8
senseBox-bike-atrai-v2/src/ble/Utf16Converter/Utf16Converter.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef UTF16_CONVERTER_H | ||
#define UTF16_CONVERTER_H | ||
|
||
#include <Arduino.h> | ||
|
||
String utf16leToString(uint8_t *data, size_t length); | ||
|
||
#endif // UTF16_CONVERTER_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
senseBox-bike-atrai-v2/src/sensors/DistanceSensor/DistanceSensor.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.