That code is a bit complex for us to pick apart here on the forum (I feel like I’d need a whiteboard and a few hours), but we can definitely help with specific questions and general advice.
I’ve taken a look at the diff between the server files, and it looks like you added and changed quite a lot. Have you tried slowly adding in the functionality you need and testing as you go? Or at least testing the client-server stuff with dummy values first (i.e. it doesn’t have to reflect the whole project with remote and all)?
What I’d try next would be taking the “known good” code and modify slowly from there, checking that the service and UUID make it through each step of the way.
Now I reconfirmed that the code I did start with does work, and in fact it does. All I have changed with the new code, is add two more characteristics to the service, nothing else has been touched. here is what I get as an output from the client side:
Device Found! Name: '' Advertising Service: '0' Service UUID: '<NULL>'
Device Found! Name: 'ESP32' Advertising Service: '1' Service UUID: '4fafc201-1fb5-459e-8fcc-c5c9c331914b'
Attempting connection to device with valid service...
Successfully connected to service! attempting to fetch service...
Found service! attempting to find characteristic...
Found Characteristic! attempting to setup callback...
Guru Meditation Error: Core 0 panic'ed (Load access fault). Exception was unhandled.
Core 0 register dump:
MEPC : 0x42003d98 RA : 0x42000466 SP : 0x3fc9e7a0 GP : 0x3fc90200
TP : 0x3fc776cc T0 : 0x4005890e T1 : 0x0000000f T2 : 0xffffffff
S0/FP : 0x00000000 S1 : 0x3fcaea40 A0 : 0x00000000 A1 : 0x3c0b0294
A2 : 0x00000001 A3 : 0x00000000 A4 : 0x00000000 A5 : 0x00000000
A6 : 0x00000007 A7 : 0x00000036 S2 : 0x3fc93000 S3 : 0x3fc93000
S4 : 0x3fc93000 S5 : 0x3fc93000 S6 : 0x3fc92000 S7 : 0x3c0b0000
S8 : 0x3c0b0000 S9 : 0x3c0b0000 S10 : 0x3c0b0000 S11 : 0x00000000
T3 : 0x00000001 T4 : 0x00000000 T5 : 0x009e00a0 T6 : 0x00000000
MSTATUS : 0x00001881 MTVEC : 0x40380001 MCAUSE : 0x00000005 MTVAL : 0x00000028
MHARTID : 0x00000000
Stack memory: (A LOT of lines of memory traces, if you feel these are important, I will add them.)
ELF file SHA256: 1b4e303f76625cc8
Rebooting...
ESP-ROM:esp32c3-api1-20210207
Build:Feb 7 2021
rst:0x3 (RTC_SW_SYS_RST),boot:0x8 (SPI_FAST_FLASH_BOOT)
Saved PC:0x40048b82
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5820,len:0x458
load:0x403cc710,len:0x814
load:0x403ce710,len:0x2878
entry 0x403cc710
and then it ends.
that means, the issue with the code, is happening right here:
if (pRemoteCharacteristic) {
Serial.println("Found Characteristic! attempting to setup callback...");
pRemoteCharacteristic->registerForNotify(ledNotifyCallback);
pRemoteCharacteristic->getDescriptor(BLEUUID((uint16_t)0x2902))->writeValue((uint8_t*)"\x01", 1);
Serial.println("Set callback and found descriptor successfully! All Complete.");
}
Just a little note, I also checked both with the original code, and this modified code, if the data shows up correctly in NRFConnect, and it does.
Yes, I have learnt that, and I did use it, but its only useful for an extent, and I always make sure I understand what its actually changing, so I know why an error may occur in the future, but I thought I would be smart, and try and re-write the entire server and client code, which did not work in the end.
2 Likes
And you can get our latest projects and tips straight away by following us on: