This post is a request for help using painlessMesh, but it is to do with string manipulation above all else.
I am creating a character array of 65536 elements representing 32784 ADC readings.
The ADC read routine is
Code: Select all
rdg=analogRead(ADC0);
twf[a]=(char)encoder((int(rdg/64)));
twf[a+1]=(char)encoder((int(rdg%64)));
As the ADC is 12 bits, I encode each value to 2 ascii characters using this function to ensure certain character values are avoided
Code: Select all
int encoder(int data){
if (data < 52)
return data + 40;
else
return data + 45;
}
I want to send the data in 128 packets of 512 characters using the painlessMesh library. So I need to put the first 512 characters into a String (followed by further 512 char packets) called pkt so I can send it out over WiFi using
Code: Select all
mesh.sendBroadcast(pkt);
Code: Select all
for(a=0; a<512; a++)
pkt[a]=twf[a];
pkt[512]='\0';
If I replace the above code with pkt = "Anything at all", it works and me seconde ESP32 reports an incoming message perfectly. Where am I going wrong?
Please help, Im going insane trying to work it out! Steve.