nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

Creating service with const char* #1171

Closed johnathanchiu closed 1 year ago

johnathanchiu commented 1 year ago

I have an issue when creating a new service with a const char *. It seems like createService function works with input type of const char * but whenever I try to do something like

const char *a = "hi";
...
BLEService *pService = pServer->createService(a);

The code compiles fine but it seems to have some sort of issue trying to access memory. See the following:

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0030,len:1184
load:0x40078000,len:13260
load:0x40080400,len:3028
entry 0x400805e4
Guru Meditation Error: Core  1 panic'ed (LoadProhibited). Exception was unhandled.
johnathanchiu commented 1 year ago

Okay, I understand the issue now. I specifically was trying to use the "Device Information" string as a direct UUID. There are pre-assigned UUIDs for these specific services. You can find them here: https://btprodspecificationrefs.blob.core.windows.net/assigned-numbers/Assigned%20Number%20Types/Assigned_Numbers.pdf