mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-07-22 22:41:10 -04:00
BLE List improvements (#1595)
* WIP on add to save list * Added rewriting existing lines and appending new to same file. * format * not looking on new file. * Added temp list due to some issue of recent being updated during save I was receiving a system halt and this seems to fix it. Needs more testing though. * clang format * Stored entries backward. Fix. * Update file working, need to replace temp file though.
This commit is contained in:
parent
309f2fbd2c
commit
5a1676a0b9
5 changed files with 163 additions and 58 deletions
|
@ -348,6 +348,35 @@ void generateRandomMacAddress(char* macAddress) {
|
|||
macAddress[12] = '\0'; // Null-terminate the string
|
||||
}
|
||||
|
||||
uint64_t readUntil(File& file, char* result, std::size_t maxBufferSize, char delimiter) {
|
||||
std::size_t bytesRead = 0;
|
||||
|
||||
while (true) {
|
||||
char ch;
|
||||
File::Result<File::Size> readResult = file.read(&ch, 1);
|
||||
|
||||
if (readResult.is_ok() && readResult.value() > 0) {
|
||||
if (ch == delimiter) {
|
||||
// Found a space character, stop reading
|
||||
break;
|
||||
} else if (bytesRead < maxBufferSize) {
|
||||
// Append the character to the result if there's space
|
||||
result[bytesRead++] = ch;
|
||||
} else {
|
||||
// Buffer is full, break to prevent overflow
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break; // End of file or error
|
||||
}
|
||||
}
|
||||
|
||||
// Null-terminate the result string
|
||||
result[bytesRead] = '\0';
|
||||
|
||||
return bytesRead;
|
||||
}
|
||||
|
||||
std::string unit_auto_scale(double n, const uint32_t base_unit, uint32_t precision) {
|
||||
const uint32_t powers_of_ten[5] = {1, 10, 100, 1000, 10000};
|
||||
std::string string{""};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue