[SOLVED] BLE and Wifi = out of memory ??
Posted: Sat Apr 28, 2018 2:10 pm
Hi all,
I'm trying to setup BLE and Wifi together (ESP-WROVER-Kit), but the image is to big for the flash ??
My code is based on Kolban's BLE example in his esp32-snippets/cpp_utils :
Anyone ?
Thanks,
Paul.
I'm trying to setup BLE and Wifi together (ESP-WROVER-Kit), but the image is to big for the flash ??
Code: Select all
paulvdbergh@ssd-debian:~/IoTTrains/IoTaT$ make monitor
MONITOR
--- idf_monitor on /dev/ttyUSB1 115200 ---
--- Quit: Ctrl+] | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x3e (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:4672
ho 0 tail 12 room 4
load:0x40078000,len:0
load:0x40078000,len:13636
entry 0x40078578
E (505) esp_image: Image length 1316096 doesn't fit in partition length 1048576
E (505) boot: Factory app partition is not bootable
E (507) boot: No bootable app partitions in the partition table
user code done
Code: Select all
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "BLEDevice.h"
#include "BLEServer.h"
#include "BLEUtils.h"
#include "BLE2902.h"
#include "esp_log.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include <string>
#include "Task.h"
#include "esp_log.h"
#include "nvs_flash.h"
static char LOG_TAG[] = "SampleServer";
class MainBLEServer : public Task
{
void run(void* data)
{
ESP_LOGD(LOG_TAG, "Starting BLE work!");
BLEDevice::init("ESP32");
BLEServer* pServer = BLEDevice::createServer();
BLEService* pService = pServer->createService("91bad492-b950-4226-aa2b-4ede9fa42f59");
BLECharacteristic* pCharacteristic = pService->createCharacteristic(
BLEUUID("0d563a58-196a-48ce-ace2-dfec78acc814"),
BLECharacteristic::PROPERTY_BROADCAST | BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_WRITE |
BLECharacteristic::PROPERTY_INDICATE
);
pCharacteristic->setValue("Hello World!");
BLE2902* p2902Descriptor = new BLE2902();
p2902Descriptor->setNotifications(true);
pCharacteristic->addDescriptor(p2902Descriptor);
pService->start();
BLEAdvertising* pAdvertising = pServer->getAdvertising();
pAdvertising->addServiceUUID(BLEUUID(pService->getUUID()));
pAdvertising->start();
ESP_LOGD(LOG_TAG, "Advertising started!");
delay(1000000);
}
};
esp_err_t event_handler(void *ctx, system_event_t *event)
{
return ESP_OK;
}
extern "C"
void app_main(void)
{
/* Initialize NVS — it is used to store PHY calibration data */
esp_err_t ret = nvs_flash_init();
if (ret == ESP_ERR_NVS_NO_FREE_PAGES)
{
ESP_ERROR_CHECK(nvs_flash_erase());
ret = nvs_flash_init();
}
ESP_ERROR_CHECK( ret );
tcpip_adapter_init();
ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) );
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
ESP_ERROR_CHECK( esp_wifi_set_storage(WIFI_STORAGE_RAM) );
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
wifi_config_t sta_config;
memcpy(&sta_config.sta.ssid, "devolo-8f4", strlen("devolo-8f4"));
memcpy(&sta_config.sta.password, "----------------", strlen("----------------"));
sta_config.sta.bssid_set = false;
ESP_ERROR_CHECK( esp_wifi_set_config(WIFI_IF_STA, &sta_config) );
ESP_ERROR_CHECK( esp_wifi_start() );
ESP_ERROR_CHECK( esp_wifi_connect() );
MainBLEServer* pMainBleServer = new MainBLEServer();
pMainBleServer->setStackSize(20000);
pMainBleServer->start();
gpio_set_direction(GPIO_NUM_4, GPIO_MODE_OUTPUT);
int level = 0;
while (true) {
gpio_set_level(GPIO_NUM_4, level);
level = !level;
vTaskDelay(300 / portTICK_PERIOD_MS);
}
}
Thanks,
Paul.