Send base64 by url

grayefx
Posts: 6
Joined: Sun Dec 09, 2018 8:36 pm
Location: Guadalajara, Mexico

Send base64 by url

Postby grayefx » Sun Dec 09, 2018 8:49 pm

Hi, this is my first post here. First of all, sorry for my english.

I have a problem:
I have a server pointing to raspberry server wich expects a JSON object.

When i pass parameters directly to raspberry server, there is no problem, it recive fine, but when i pass the parameters redirecting there is no answer. Every change if i encode base64 my JSON and send it, all works!. But when i try to implement in IDF doesnt work.

///////////////////////////ENCODING JSON//////////////////////////////////////////////////////////
char* to_Encode = "{\"user_usr\":\"DeviceUsr\",\"user_psw\":\"DevicePsw\"}";
size_t outPutLenght;
unsigned char * coded = base64_encode((const unsigned char *)to_Encode, strlen(to_Encode), &outPutLenght);
char* coded_send = (const char *)coded;
char* server_service_get_token = "http://myhost/user_login/";
char* full_service_token =concatb(server_service_get_token,coded_send);

///////////////////////////////CONFIGURE HTTP REQ//////////////////////////////////
esp_http_client_config_t config = {
.url = full_service_token,
.event_handler = _http_event_handler,
};

//////////////////////////////ERROR /////////////////////////////////////////////////////////
Error parse url http://myhost/user_login/eyJ1c2VyX3Vzci ... NlUHN3In0=
HTTP_CLIENT: Error set default configurations
Guru Meditation Error: Core 0 panic'ed (LoadProhibited). Exception was unhandled.


But if i do this on . url works!, WTFF

esp_http_client_config_t config = {
.url = "http://myhost/user_login/eyJ1c2VyX3Vzci ... NlUHN3In0=",
.event_handler = _http_event_handler,
};


Any idea?

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Send base64 by url

Postby chegewara » Mon Dec 10, 2018 10:22 am

maybe you are missing trailing \0 in coded variable?

grayefx
Posts: 6
Joined: Sun Dec 09, 2018 8:36 pm
Location: Guadalajara, Mexico

Re: Send base64 by url

Postby grayefx » Mon Dec 10, 2018 3:05 pm

Tested "\0" and not work u.u :(

chegewara
Posts: 2207
Joined: Wed Jun 14, 2017 9:00 pm

Re: Send base64 by url

Postby chegewara » Wed Dec 12, 2018 11:17 pm

Its how i am doing it:

Code: Select all

	unsigned char *buffer = (unsigned char*) heap_caps_calloc(1, (size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, MALLOC_CAP_SPIRAM);
	if (buffer == NULL)
	{
		ESP_LOGE(TAG, "cant allocate memory");
		return;
	}
	ESP_LOGI(TAG, "buffer size: %d", size);
	
	int err64 = mbedtls_base64_encode(buffer, (size + 2 - ((size + 2) % 3)) / 3 * 4 + 1, &buff_size, image, size);
I am allocating in spiram, because i need huge buffer.

Who is online

Users browsing this forum: Bing [Bot] and 151 guests