Start to work on networking
This commit is contained in:
		@@ -1,5 +1,10 @@
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Backend unsecure API URL
 | 
			
		||||
 */
 | 
			
		||||
#define BACKEND_UNSECURE_URL "http://devweb.internal:8080"
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Device name len
 | 
			
		||||
 */
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@
 | 
			
		||||
#include "storage.h"
 | 
			
		||||
#include "system.h"
 | 
			
		||||
#include "crypto.h"
 | 
			
		||||
#include "unsecure_api.h"
 | 
			
		||||
 | 
			
		||||
void app_main(void)
 | 
			
		||||
{
 | 
			
		||||
@@ -36,5 +37,10 @@ void app_main(void)
 | 
			
		||||
    printf("Current CSR:\n%s\n", 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();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										11
									
								
								esp32_device/main/unsecure_api.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								esp32_device/main/unsecure_api.c
									
									
									
									
									
										Normal 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);
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										22
									
								
								esp32_device/main/unsecure_api.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								esp32_device/main/unsecure_api.h
									
									
									
									
									
										Normal 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
 | 
			
		||||
		Reference in New Issue
	
	Block a user