mirror of
https://github.com/meshtastic/firmware.git
synced 2026-05-24 16:58:01 -04:00
Move pb string length method and fix linker error
This commit is contained in:
@@ -106,4 +106,15 @@ const std::string vformat(const char *const zcFormat, ...)
|
||||
std::vsnprintf(zc.data(), zc.size(), zcFormat, vaArgs);
|
||||
va_end(vaArgs);
|
||||
return std::string(zc.data(), iLen);
|
||||
}
|
||||
|
||||
size_t pb_string_length(const char *str, size_t max_len)
|
||||
{
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < max_len; i++) {
|
||||
if (str[i] != '\0') {
|
||||
len = i + 1;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
@@ -35,4 +35,7 @@ bool isOneOf(int item, int count, ...);
|
||||
|
||||
const std::string vformat(const char *const zcFormat, ...);
|
||||
|
||||
// Get actual string length for nanopb char array fields.
|
||||
size_t pb_string_length(const char *str, size_t max_len);
|
||||
|
||||
#define IS_ONE_OF(item, ...) isOneOf(item, sizeof((int[]){__VA_ARGS__}) / sizeof(int), __VA_ARGS__)
|
||||
|
||||
@@ -6,27 +6,11 @@
|
||||
#include "configuration.h"
|
||||
#include "main.h"
|
||||
#include "mesh/compression/unishox2.h"
|
||||
#include "meshUtils.h"
|
||||
#include "meshtastic/atak.pb.h"
|
||||
|
||||
AtakPluginModule *atakPluginModule;
|
||||
|
||||
/**
|
||||
* Get actual string length for nanopb char array fields.
|
||||
* Nanopb stores strings as fixed-size char arrays that may contain embedded nulls.
|
||||
* strlen() would stop at the first null, but we need to find the last non-null character.
|
||||
* This is critical for Android UIDs that can contain 0x00 bytes (e.g., ANDROID-e7e455b40002429d).
|
||||
*/
|
||||
static size_t pb_string_length(const char *str, size_t max_len)
|
||||
{
|
||||
size_t len = 0;
|
||||
for (size_t i = 0; i < max_len; i++) {
|
||||
if (str[i] != '\0') {
|
||||
len = i + 1;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
AtakPluginModule::AtakPluginModule()
|
||||
: ProtobufModule("atak", meshtastic_PortNum_ATAK_PLUGIN, &meshtastic_TAKPacket_msg), concurrency::OSThread("AtakPlugin")
|
||||
{
|
||||
|
||||
@@ -2,16 +2,7 @@
|
||||
#include <unity.h>
|
||||
|
||||
#include "TestUtil.h"
|
||||
|
||||
/**
|
||||
* Get actual string length for nanopb char array fields.
|
||||
* Nanopb stores strings as fixed-size char arrays that may contain embedded nulls.
|
||||
* strlen() would stop at the first null, but we need to find the last non-null character.
|
||||
* This is critical for Android UIDs that can contain 0x00 bytes (e.g., ANDROID-e7e455b40002429d).
|
||||
*
|
||||
* Use the firmware implementation declared elsewhere so tests exercise the same logic.
|
||||
*/
|
||||
extern size_t pb_string_length(const char *str, size_t max_len);
|
||||
#include "meshUtils.h"
|
||||
|
||||
void setUp(void)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user