Start to work on networking

This commit is contained in:
Pierre HUBERT 2024-08-17 13:49:55 +02:00
parent 6b9d5e9d85
commit 0d90973842
4 changed files with 44 additions and 0 deletions

View File

@ -1,5 +1,10 @@
#pragma once #pragma once
/**
* Backend unsecure API URL
*/
#define BACKEND_UNSECURE_URL "http://devweb.internal:8080"
/** /**
* Device name len * Device name len
*/ */

View File

@ -5,6 +5,7 @@
#include "storage.h" #include "storage.h"
#include "system.h" #include "system.h"
#include "crypto.h" #include "crypto.h"
#include "unsecure_api.h"
void app_main(void) void app_main(void)
{ {
@ -36,5 +37,10 @@ void app_main(void)
printf("Current CSR:\n%s\n", csr); printf("Current CSR:\n%s\n", csr);
free(csr); free(csr);
printf("Check secure origin\n");
char *sec_orig = unsecure_api_get_secure_origin();
assert(sec_orig != NULL);
printf("Res = %s\n", sec_orig);
reboot(); reboot();
} }

View File

@ -0,0 +1,11 @@
#include "unsecure_api.h"
#include "constants.h"
#include "esp_http_client.h"
#include <string.h>
char *unsecure_api_get_secure_origin()
{
const char *url = BACKEND_UNSECURE_URL "/secure_origin";
return strdup(url);
}

View File

@ -0,0 +1,22 @@
/**
* Unsecure API functions
*/
#pragma once
#ifdef __cplusplus
extern "C"
{
#endif
/**
* Get secure origin
*
* @returns The URL to the secure origin or NULL in case of failure. Value must be
* released by caller.
*/
char *unsecure_api_get_secure_origin();
#ifdef __cplusplus
}
#endif