mirror of
https://github.com/espruino/Espruino.git
synced 2025-12-08 19:06:15 +00:00
- added variables_mode in config. build_platform_config.py - added define for variables_mode jsvar.h - added jsVarsSize; //size of jsVars for option malloc - added support of malloc jsVars in jsvInit jsvar.c - added definition jsVars for variables_mode_malloc jshardwareESP32.h - new file with functions to set/get enable status of BLE and Wifi jshardwareESP32.c - new file with functions to set/get enable status of BLE and Wifi ESP32.make - added jshardware.c to SOURCES main.c - added handling for Wifi enabled - added calculation for jsVars - initialise jsVars based on calculation jshardware.c - used new API call to get Serial Number, even if Wifi is not enabled - initialises BLE, if BLE is enabled (in NVS storage) bluetooth.c - check if BLE is enabled before initialising jswrap_esp32.h - defines functions to enable BLE and/or Wifi jswrap_esp32.c - wrapper for functions to enable BLE/Wifi, remove code from Flash, to avoid overflow in jsVars - added status for BLE/Wifi to ESP32.getStatus esp32_gap_func.c - get mac adress even if Wifi is not enabled Changes to be committed: modified: boards/ESP32.py modified: make/family/ESP32.make modified: scripts/build_platform_config.py modified: src/jsvar.c modified: src/jsvar.h modified: targets/esp32/BLE/esp32_gap_func.c modified: targets/esp32/bluetooth.c modified: targets/esp32/jshardware.c new file: targets/esp32/jshardwareESP32.c new file: targets/esp32/jshardwareESP32.h modified: targets/esp32/jswrap_esp32.c modified: targets/esp32/jswrap_esp32.h modified: targets/esp32/main.c
50 lines
1.7 KiB
C
50 lines
1.7 KiB
C
/*
|
|
* This file is designed to support Analog functions in Espruino,
|
|
* a JavaScript interpreter for Microcontrollers designed by Gordon Williams
|
|
*
|
|
* Copyright (C) 2016 by Juergen Marsch
|
|
*
|
|
* This Source Code Form is subject to the terms of the Mozilla Publici
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
*
|
|
* ----------------------------------------------------------------------------
|
|
* This file is designed to be parsed during the build process
|
|
*
|
|
* Contains ESP32 board specific functions for networking (wifi, ble).
|
|
* ----------------------------------------------------------------------------
|
|
*/
|
|
|
|
#include "jshardwareESP32.h"
|
|
#include "esp_system.h"
|
|
#include "nvs_flash.h"
|
|
#include "nvs.h"
|
|
|
|
static char *ESP32_hardwareName(esp_hardware_esp32_t hardware){
|
|
switch(hardware){
|
|
case ESP_NETWORK_BLE: return "bleStatus";
|
|
case ESP_NETWORK_WIFI: return "wifiStatus";
|
|
}
|
|
return "unknownHardware";
|
|
}
|
|
|
|
bool ESP32_Get_NVS_Status(esp_hardware_esp32_t hardware){
|
|
esp_err_t err;nvs_handle hardwareHandle; uint32_t status;
|
|
nvs_open("nvs",NVS_READWRITE,&hardwareHandle);
|
|
err = nvs_get_u32(hardwareHandle,ESP32_hardwareName(hardware),&status);
|
|
if(err) {
|
|
status = ESP32HARDWAREDEFAULT;
|
|
nvs_set_u32(hardwareHandle,ESP32_hardwareName(hardware),ESP32HARDWAREDEFAULT);
|
|
}
|
|
nvs_close(hardwareHandle);
|
|
return (bool) status;
|
|
}
|
|
|
|
void ESP32_Set_NVS_Status(esp_hardware_esp32_t hardware, bool enable){
|
|
nvs_handle hardwareHandle; uint32_t status;
|
|
if(enable) status = 1; else status = 0;
|
|
nvs_open("nvs",NVS_READWRITE,&hardwareHandle);
|
|
nvs_set_u32(hardwareHandle,ESP32_hardwareName(hardware),status);
|
|
nvs_close(hardwareHandle);
|
|
}
|