Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket - Allow to choose which memory takes (internal, external) for buffer (IDFGH-12913) #581

Open
filzek opened this issue May 28, 2024 · 3 comments
Assignees

Comments

@filzek
Copy link

filzek commented May 28, 2024

Is your feature request related to a problem?

Memory allocartion always internal, need to have an option to choose it to delegates internal or external.

Describe the solution you'd like.

No response

Describe alternatives you've considered.

No response

Additional context.

No response

@github-actions github-actions bot changed the title Websocket - Allow to choose which memory takes (internal, external) for buffer Websocket - Allow to choose which memory takes (internal, external) for buffer (IDFGH-12913) May 28, 2024
@filzek
Copy link
Author

filzek commented May 28, 2024

could be setup in the esp_websocket_client_config_t or with a custom handler like in the CJSON to override:

memoryHook.malloc_fn = spiram_calloc;
memoryHook.free_fn = spiram_free;
cJSON_InitHooks(&memoryHook);

// Wrapper calloc SPI RAM.
void* spiram_calloc(size_t size) {
void* ptr = TRACEABLE_HEAP_CAPS_CALLOC(1, size * sizeof(unsigned char), MALLOC_CAP_SPIRAM);
if(ptr == NULL) {
printf("Fail alloc SPIRAM\n");
}
return ptr; // return NULL if TRACEABLE_HEAP_CAPS_CALLOC fail
}

void spiram_free(void* ptr) {
heap_caps_free(ptr);
}

so in the hooks the way to handle the memory could be lead to user to choose, or just like a flag in the esp_websocket_client_config_t as:
.memorytouse = 0 (0, internal, 1, external)

@filzek
Copy link
Author

filzek commented Jun 3, 2024

I have sent an pull request proposal to the maintainers.

@filzek
Copy link
Author

filzek commented Jun 3, 2024

#586

send, so, if you need to use external memory in websocket, now it is full working like a charm.,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants