I have an issue doing the following:
Class "A":
const uint8_t arr1[] = {0x00, 0x00, 0x03, 0x00, ...};
const uint8_t arr2[] = {0xA1, 0x00, 0xFF, 0x00, ...};
struct s1 {
String name;
uint8_t const * arr;
};
std::vector<s1, std::allocator<alloc1>> vect1;
std::vector<s1>::iterator it = vect1.begin();
privateMethod1(uint8_t const * ptr) {
// this method receives pointer correctly, so I can doPrint(ptr)
s1 myStruct;
myStruct.name = "name";
myStruct.arr = ptr;
vect1.push_back(myStruct);
}
myPublicMethod(String arrName) {
uint8_t const * ptr;
if(arrName == "A") {
ptr = arr1;
} else if(arrName == "B") {
ptr = arr2;
}
privateMethod1(ptr);
}
Few moments later...
myPublicMethod2() {
for(; it < vect1.end(); it++) {
doPrint(it->arr);
// here the link between pointers broken,
// doPrint() shows me random characters
}
}
Apparently the problem is to store arr1 or arr2 correctly in myStruct. Anyone has an idea where I am wrong using pointers? Thanks