summaryrefslogtreecommitdiff
path: root/main/main.c
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2018-05-27 18:50:08 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2018-05-27 18:50:08 +0200
commit2d8d23b99873f3612b4d24a60cb20a1787381ce9 (patch)
treeb2a5c764cd264951862fa3dc910f91ed55f025a3 /main/main.c
parentd4abcad280df631b09a8cfe4c9387a9d8c610c1f (diff)
downloadmodern-esp-sandbox-2d8d23b99873f3612b4d24a60cb20a1787381ce9.tar.gz
modern-esp-sandbox-2d8d23b99873f3612b4d24a60cb20a1787381ce9.tar.bz2
modern-esp-sandbox-2d8d23b99873f3612b4d24a60cb20a1787381ce9.tar.xz
modern-esp-sandbox-2d8d23b99873f3612b4d24a60cb20a1787381ce9.zip
wip
Diffstat (limited to 'main/main.c')
-rw-r--r--main/main.c184
1 files changed, 0 insertions, 184 deletions
diff --git a/main/main.c b/main/main.c
deleted file mode 100644
index f1d9594..0000000
--- a/main/main.c
+++ /dev/null
@@ -1,184 +0,0 @@
-#include "esp_sta.h"
-#include "esp_system.h"
-#include "esp_wifi.h"
-#include "esp_spiffs.h"
-#include "spiffs.h"
-#include "sdkconfig.h"
-
-#include <assert.h>
-
-#include "main-config.h"
-
-// static bool show_ip = false;
-
-/******************************************************************************
- * FunctionName : user_rf_cal_sector_set
- * Description : SDK just reversed 4 sectors, used for rf init data and paramters.
- * We add this function to force users to set rf cal sector, since
- * we don't know which sector is free in user's application.
- * sector map for last several sectors : ABCCC
- * A : rf cal
- * B : rf init data
- * C : sdk parameters
- * Parameters : none
- * Returns : rf cal sector
-*******************************************************************************/
-uint32_t user_rf_cal_sector_set(void)
-{
- flash_size_map size_map = system_get_flash_size_map();
- uint32_t rf_cal_sec = 0;
-
- switch (size_map) {
- case FLASH_SIZE_4M_MAP_256_256:
- rf_cal_sec = 128 - 5;
- break;
-
- case FLASH_SIZE_8M_MAP_512_512:
- rf_cal_sec = 256 - 5;
- break;
-
- case FLASH_SIZE_16M_MAP_512_512:
- case FLASH_SIZE_16M_MAP_1024_1024:
- rf_cal_sec = 512 - 5;
- break;
-
- case FLASH_SIZE_32M_MAP_512_512:
- case FLASH_SIZE_32M_MAP_1024_1024:
- rf_cal_sec = 1024 - 5;
- break;
- case FLASH_SIZE_64M_MAP_1024_1024:
- rf_cal_sec = 2048 - 5;
- break;
- case FLASH_SIZE_128M_MAP_1024_1024:
- rf_cal_sec = 4096 - 5;
- break;
- default:
- rf_cal_sec = 0;
- break;
- }
-
- return rf_cal_sec;
-}
-
-__attribute__((used))
-static int32_t fs_init(void)
-{
- struct esp_spiffs_config config;
-
- uint32_t log_page_size = CONFIG_MAIN_FLASH_LOG_PAGE_SIZE;
-
- config.phys_size = CONFIG_MAIN_FLASH_SIZE_KB * 1024;
- config.phys_addr = CONFIG_MAIN_FLASH_FLASH_ADDR_KB * 1024;
- config.phys_erase_block = CONFIG_MAIN_FLASH_SECTOR_SIZE_KB * 1024;
- config.log_block_size = CONFIG_MAIN_FLASH_LOG_BLOCK_SIZE_KB * 1024;
- config.log_page_size = log_page_size;
- config.fd_buf_size = CONFIG_MAIN_FLASH_FD_BUF_SIZE * 2;
- config.cache_buf_size = (log_page_size + 32) * 8;
-
- return esp_spiffs_init(&config);
-}
-
-void wifi_event_handler_cb(System_Event_t *event)
-{
- if (event == NULL) {
- os_printf("NULL event\n");
- return;
- }
-
- if (event->event_id == EVENT_STAMODE_GOT_IP) {
- printf("STA GOT IP");
- // show_ip = true;
- } else if (event->event_id == EVENT_STAMODE_CONNECTED) {
- os_printf("STA CONNECTED\n");
- } else if (event->event_id == EVENT_STAMODE_DISCONNECTED) {
- os_printf("STA DISCONNECTED\n");
- wifi_station_connect();
- } else {
- os_printf("Unknown event\n");
- }
-}
-
-static void set_station_mode() {
- printf("STATION_MODE\n");
- if (wifi_get_opmode_default() != NULL_MODE) {
- printf("Setting default station mode");
- wifi_set_opmode(NULL_MODE);
- }
-
- wifi_set_opmode_current(STATION_MODE);
-
- struct station_config config;
- bzero(&config, sizeof(struct station_config));
- sprintf((char *)config.ssid, WIFI_SSID);
- sprintf((char *)config.password, WIFI_PASSWORD);
- wifi_station_set_config(&config);
-
- wifi_set_event_handler_cb(wifi_event_handler_cb);
-
- wifi_station_connect();
-}
-
-void ets_wdt_disable();
-void my_thread(void* ctx) {
- (void) ctx;
-
- // wifi_set_opmode(NULL_MODE);
-
- int count = 0;
- while (1) {
- printf("Hello World! %d\n", count);
- if (count == 2) {
- // pvShowMalloc();
- }
-
- if (count == 5) {
- // set_station_mode();
- }
- /*
- */
-
- /*
- show_ip = false;
- if (show_ip) {
- show_ip = false;
-
- struct ip_info info;
- bool ok = wifi_get_ip_info(STATION_IF, &info);
-
- if (ok) {
- printf("ip=" IPSTR ", nm=" IPSTR ", gw=" IPSTR "\n", IP2STR(&info.ip), IP2STR(&info.netmask), IP2STR(&info.gw));
- } else {
- printf("show ip failed\n");
- }
- }
- */
-
- count++;
- vTaskDelay(500 / portTICK_PERIOD_MS);
- }
-}
-
-#define THREAD_NAME "my_thread"
-#define THREAD_STACK_WORDS 2048
-#define THREAD_PRIO 8
-
-void user_init() {
- os_printf("SDK version: %s, free: %d\n", system_get_sdk_version(), system_get_free_heap_size());
-
- set_station_mode();
- // pvShowMalloc();
-
- // assert(fs_init() != -1);
-
- xTaskHandle thread_handle;
-
- // set_station_mode();
-
- int ret = xTaskCreate(my_thread,
- THREAD_NAME,
- THREAD_STACK_WORDS,
- NULL,
- THREAD_PRIO,
- &thread_handle);
- assert(ret == pdPASS);
-}