本文整理汇总了C++中ESP_ERROR_CHECK函数的典型用法代码示例。如果您正苦于以下问题:C++ ESP_ERROR_CHECK函数的具体用法?C++ ESP_ERROR_CHECK怎么用?C++ ESP_ERROR_CHECK使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ESP_ERROR_CHECK函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: wifi_init_softap
void wifi_init_softap()
{
ap_event_group = xEventGroupCreate();
//tcpip_adapter_init();
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
wifi_config_t wifi_config = {
.ap = {
.ssid = EXAMPLE_DEFAULT_SSID,
.ssid_len = 0,
.max_connection=EXAMPLE_MAX_STA_CONN,
.password = EXAMPLE_DEFAULT_PWD,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
},
};
if (strlen(EXAMPLE_DEFAULT_PWD) ==0) {
wifi_config.ap.authmode = WIFI_AUTH_OPEN;
}
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_LOGI(TAG, "wifi_init_softap finished.SSID:%s password:%s \n",
EXAMPLE_DEFAULT_SSID, EXAMPLE_DEFAULT_PWD);
}
开发者ID:fanhuanji,项目名称:esp32_baidu_rest,代码行数:28,代码来源:wifi.c
示例2: sc_callback
static void sc_callback(smartconfig_status_t status, void *pdata)
{
switch (status) {
case SC_STATUS_WAIT:
ESP_LOGI(TAG, "SC_STATUS_WAIT");
break;
case SC_STATUS_FIND_CHANNEL:
ESP_LOGI(TAG, "SC_STATUS_FINDING_CHANNEL");
break;
case SC_STATUS_GETTING_SSID_PSWD:
ESP_LOGI(TAG, "SC_STATUS_GETTING_SSID_PSWD");
break;
case SC_STATUS_LINK:
ESP_LOGI(TAG, "SC_STATUS_LINK");
wifi_config_t *wifi_config = pdata;
ESP_LOGI(TAG, "SSID:%s", wifi_config->sta.ssid);
ESP_LOGI(TAG, "PASSWORD:%s", wifi_config->sta.password);
ESP_ERROR_CHECK( esp_wifi_disconnect() );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, wifi_config) );
ESP_ERROR_CHECK( esp_wifi_connect() );
break;
case SC_STATUS_LINK_OVER:
ESP_LOGI(TAG, "SC_STATUS_LINK_OVER");
if (pdata != NULL) {
uint8_t phone_ip[4] = { 0 };
memcpy(phone_ip, (uint8_t* )pdata, 4);
ESP_LOGI(TAG, "Phone ip: %d.%d.%d.%d\n", phone_ip[0], phone_ip[1], phone_ip[2], phone_ip[3]);
}
xEventGroupSetBits(wifi_event_group, ESPTOUCH_DONE_BIT);
break;
default:
break;
}
}
开发者ID:danathughes,项目名称:esp-idf,代码行数:34,代码来源:smartconfig_main.c
示例3: app_main
void app_main()
{
vTaskDelay(1000 / portTICK_PERIOD_MS);
ESP_ERROR_CHECK(nvs_flash_init_partition("Mynvs"));
nvs_handle handle;
ESP_ERROR_CHECK(nvs_open_from_partition("Mynvs","store", NVS_READWRITE, &handle));
int32_t val = 0;
esp_err_t result = nvs_get_i32(handle, "val", &val);
switch (result)
{
case ESP_ERR_NOT_FOUND:
ESP_LOGE(TAG, "Value not set yet");
break;
case ESP_OK:
ESP_LOGI(TAG, "Value is %d", val);
break;
default:
ESP_LOGE(TAG, "Error (%s) opening NVS handle!\n", esp_err_to_name(result));
break;
}
val++;
ESP_ERROR_CHECK(nvs_set_i32(handle, "val", val));
ESP_ERROR_CHECK(nvs_commit(handle));
nvs_close(handle);
}
开发者ID:Mair,项目名称:esp32-course,代码行数:28,代码来源:main.c
示例4: event_handler
static esp_err_t event_handler(void *ctx, system_event_t *event)
{
httpd_handle_t *server = (httpd_handle_t *) ctx;
switch(event->event_id) {
case SYSTEM_EVENT_STA_START:
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_START");
ESP_ERROR_CHECK(esp_wifi_connect());
break;
case SYSTEM_EVENT_STA_GOT_IP:
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_GOT_IP");
ESP_LOGI(TAG, "Got IP: '%s'",
ip4addr_ntoa(&event->event_info.got_ip.ip_info.ip));
/* Start the web server */
if (*server == NULL) {
*server = start_webserver();
}
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
ESP_LOGI(TAG, "SYSTEM_EVENT_STA_DISCONNECTED");
ESP_ERROR_CHECK(esp_wifi_connect());
/* Stop the web server */
if (*server) {
stop_webserver(*server);
*server = NULL;
}
break;
default:
break;
}
return ESP_OK;
}
开发者ID:espressif,项目名称:ESP8266_RTOS_SDK,代码行数:34,代码来源:main.c
示例5: app_main
void app_main(void)
{
// Initialize NVS
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);
initialise_wifi();
ret = xTaskCreate(&mqtt_client_thread,
MQTT_CLIENT_THREAD_NAME,
MQTT_CLIENT_THREAD_STACK_WORDS,
NULL,
MQTT_CLIENT_THREAD_PRIO,
NULL);
if (ret != pdPASS) {
ESP_LOGE(TAG, "mqtt create client thread %s failed", MQTT_CLIENT_THREAD_NAME);
}
}
开发者ID:espressif,项目名称:ESP8266_RTOS_SDK,代码行数:25,代码来源:MQTTEcho.c
示例6: wifi_cmd_sta_join
static bool wifi_cmd_sta_join(const char* ssid, const char* pass)
{
int bits = xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, 0, 1, 0);
wifi_config_t wifi_config = { 0 };
strlcpy((char*) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid));
if (pass) {
strncpy((char*) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password));
}
if (bits & CONNECTED_BIT) {
reconnect = false;
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
ESP_ERROR_CHECK( esp_wifi_disconnect() );
xEventGroupWaitBits(wifi_event_group, DISCONNECTED_BIT, 0, 1, portTICK_RATE_MS);
}
reconnect = true;
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
ESP_ERROR_CHECK( esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config) );
ESP_ERROR_CHECK( esp_wifi_connect() );
xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT, 0, 1, 5000/portTICK_RATE_MS);
return true;
}
开发者ID:danathughes,项目名称:esp-idf,代码行数:27,代码来源:cmd_wifi.c
示例7: setup_gpios
static void setup_gpios()
{
// Input:
// 4: Joy #2 Pot x
//
// Output:
// 5: Joy #1 Pot X
// 21: Joy #1 Pot X
// Output: 5 (LED) and 21
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = ((1ULL << GPIO_NUM_21) | (1ULL << GPIO_NUM_5));
io_conf.pull_down_en = false;
io_conf.pull_up_en = false;
ESP_ERROR_CHECK( gpio_config(&io_conf) );
// Input: read POT X
io_conf.intr_type = GPIO_INTR_POSEDGE;
io_conf.mode = GPIO_MODE_INPUT;
io_conf.pin_bit_mask = 1ULL << GPIO_NUM_18;
io_conf.pull_down_en = false;
io_conf.pull_up_en = true;
ESP_ERROR_CHECK( gpio_config(&io_conf) );
// install gpio isr service
ESP_ERROR_CHECK( gpio_install_isr_service(0) );
//hook isr handler for specific gpio pin
ESP_ERROR_CHECK( gpio_isr_handler_add(GPIO_NUM_18, gpio_isr_handler_up, (void*) GPIO_NUM_18) );
// ESP_ERROR_CHECK( gpio_isr_register(gpio_isr_handler_up, (void*) GPIO_NUM_4, 0, NULL) );
}
开发者ID:ricardoquesada,项目名称:unijoysticle,代码行数:34,代码来源:main.c
示例8: test_spi_task
void test_spi_task(void *ignore) {
ESP_LOGD(tag, ">> test_spi_task");
spi_bus_config_t bus_config;
bus_config.sclk_io_num = 21; // CLK
bus_config.mosi_io_num = 22; // MOSI
bus_config.miso_io_num = -1; // MISO
bus_config.quadwp_io_num = -1; // Not used
bus_config.quadhd_io_num = -1; // Not used
ESP_LOGI(tag, "... Initializing bus.");
ESP_ERROR_CHECK(spi_bus_initialize(HSPI_HOST, &bus_config, 1));
spi_device_handle_t handle;
spi_device_interface_config_t dev_config;
dev_config.address_bits = 0;
dev_config.command_bits = 0;
dev_config.dummy_bits = 0;
dev_config.mode = 0;
dev_config.duty_cycle_pos = 0;
dev_config.cs_ena_posttrans = 0;
dev_config.cs_ena_pretrans = 0;
dev_config.clock_speed_hz = 10000;
dev_config.spics_io_num = 23;
dev_config.flags = 0;
dev_config.queue_size = 1;
dev_config.pre_cb = NULL;
dev_config.post_cb = NULL;
ESP_LOGI(tag, "... Adding device bus.");
ESP_ERROR_CHECK(spi_bus_add_device(HSPI_HOST, &dev_config, &handle));
char data[3];
spi_transaction_t trans_desc;
trans_desc.address = 0;
trans_desc.command = 0;
trans_desc.flags = 0;
trans_desc.length = 3 * 8;
trans_desc.rxlength = 0;
trans_desc.tx_buffer = data;
trans_desc.rx_buffer = data;
data[0] = 0x12;
data[1] = 0x34;
data[2] = 0x56;
ESP_LOGI(tag, "... Transmitting.");
ESP_ERROR_CHECK(spi_device_transmit(handle, &trans_desc));
ESP_LOGI(tag, "... Removing device.");
ESP_ERROR_CHECK(spi_bus_remove_device(handle));
ESP_LOGI(tag, "... Freeing bus.");
ESP_ERROR_CHECK(spi_bus_free(HSPI_HOST));
ESP_LOGD(tag, "<< test_spi_task");
vTaskDelete(NULL);
}
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:58,代码来源:spi_transmit.c
示例9: saveConnectionInfo
/**
* Save our connection info for retrieval on a subsequent restart.
*/
static void saveConnectionInfo(connection_info_t *pConnectionInfo) {
nvs_handle handle;
ESP_ERROR_CHECK(nvs_open(BOOTWIFI_NAMESPACE, NVS_READWRITE, &handle));
ESP_ERROR_CHECK(nvs_set_blob(handle, KEY_CONNECTION_INFO, pConnectionInfo,
sizeof(connection_info_t)));
ESP_ERROR_CHECK(nvs_set_u32(handle, KEY_VERSION, g_version));
ESP_ERROR_CHECK(nvs_commit(handle));
nvs_close(handle);
} // setConnectionInfo
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:12,代码来源:bootwifi.c
示例10: initialise_wifi
static void initialise_wifi(void)
{
wifi_event_group = xEventGroupCreate();
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));
ESP_ERROR_CHECK(esp_wifi_start());
}
开发者ID:Nicholas3388,项目名称:LuaNode,代码行数:10,代码来源:app_main.c
示例11: scan_task
static void scan_task(void *pvParameters)
{
while(1) {
xEventGroupWaitBits(wifi_event_group, SCAN_DONE_BIT, false, true, portMAX_DELAY);
ESP_LOGI(TAG, "WIFI scan doen");
xEventGroupClearBits(wifi_event_group, SCAN_DONE_BIT);
uint16_t apCount = 0;
esp_wifi_scan_get_ap_num(&apCount);
printf("Number of access points found: %d\n", apCount);
if (apCount == 0) {
ESP_LOGI(TAG, "Nothing AP found");
return;
}
wifi_ap_record_t *list = (wifi_ap_record_t *)malloc(sizeof(wifi_ap_record_t) * apCount);
ESP_ERROR_CHECK(esp_wifi_scan_get_ap_records(&apCount, list));
int i;
printf("======================================================================\n");
printf(" SSID | RSSI | AUTH \n");
printf("======================================================================\n");
for (i=0; i<apCount; i++) {
char *authmode;
switch(list[i].authmode) {
case WIFI_AUTH_OPEN:
authmode = "WIFI_AUTH_OPEN";
break;
case WIFI_AUTH_WEP:
authmode = "WIFI_AUTH_WEP";
break;
case WIFI_AUTH_WPA_PSK:
authmode = "WIFI_AUTH_WPA_PSK";
break;
case WIFI_AUTH_WPA2_PSK:
authmode = "WIFI_AUTH_WPA2_PSK";
break;
case WIFI_AUTH_WPA_WPA2_PSK:
authmode = "WIFI_AUTH_WPA_WPA2_PSK";
break;
default:
authmode = "Unknown";
break;
}
printf("%26.26s | % 4d | %22.22s\n",list[i].ssid, list[i].rssi, authmode);
}
free(list);
printf("\n\n");
// scan again
vTaskDelay(2000 / portTICK_PERIOD_MS);
//The true parameter cause the function to block until the scan is done.
ESP_ERROR_CHECK(esp_wifi_scan_start(&scanConf, true));
}
}
开发者ID:Nicholas3388,项目名称:LuaNode,代码行数:55,代码来源:app_main.c
示例12: assert
void Service::register_characteristic(Characteristic *nC) {
assert(handle != 0);
if(nC->is_descriptor) {
auto ret = esp_ble_gatts_add_char_descr(handle, &(nC->id), nC->perm, &(nC->value), &(nC->autoResp));
ESP_ERROR_CHECK(ret);
}
else {
auto ret = esp_ble_gatts_add_char(handle, &(nC->id), nC->perm, nC->prop, &(nC->value), &(nC->autoResp));
ESP_ERROR_CHECK(ret);
}
}
开发者ID:XasWorks,项目名称:XasCode,代码行数:11,代码来源:Service.cpp
示例13: initI2C
void initI2C() {
i2c_config_t conf;
conf.mode = I2C_MODE_MASTER;
conf.sda_io_num = SDA_PIN;
conf.scl_io_num = SCL_PIN;
conf.sda_pullup_en = GPIO_PULLUP_ENABLE;
conf.scl_pullup_en = GPIO_PULLUP_ENABLE;
conf.master.clk_speed = 100000;
ESP_ERROR_CHECK(i2c_param_config(I2C_NUM_0, &conf));
ESP_ERROR_CHECK(i2c_driver_install(I2C_NUM_0, I2C_MODE_MASTER, 0, 0, 0));
}
开发者ID:pilate,项目名称:esp32-snippets,代码行数:11,代码来源:pcf8523.c
示例14: app_main
void app_main()
{
// Initialize NVS
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 );
wifi_scan();
}
开发者ID:danathughes,项目名称:esp-idf,代码行数:12,代码来源:scan.c
示例15: app_main
void app_main()
{
/* 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 );
start_wps();
}
开发者ID:danathughes,项目名称:esp-idf,代码行数:12,代码来源:wps.c
示例16: initialize_console
void initialize_console()
{
/* Disable buffering on stdin */
setvbuf(stdin, NULL, _IONBF, 0);
/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */
esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
/* Configure UART. Note that REF_TICK is used so that the baud rate remains
* correct while APB frequency is changing in light sleep mode.
*/
uart_config_t uart_config;
memset(&uart_config, 0, sizeof(uart_config));
uart_config.baud_rate = CONFIG_CONSOLE_UART_BAUDRATE;
uart_config.data_bits = UART_DATA_8_BITS;
uart_config.parity = UART_PARITY_DISABLE;
uart_config.stop_bits = UART_STOP_BITS_1;
uart_config.use_ref_tick = true;
ESP_ERROR_CHECK(uart_param_config((uart_port_t) CONFIG_CONSOLE_UART_NUM, &uart_config));
/* Install UART driver for interrupt-driven reads and writes */
ESP_ERROR_CHECK(uart_driver_install((uart_port_t) CONFIG_CONSOLE_UART_NUM,
256, 0, 0, NULL, 0));
/* Tell VFS to use UART driver */
esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM);
/* Initialize the console */
esp_console_config_t console_config;
memset(&console_config, 0, sizeof(console_config));
console_config.max_cmdline_args = 8;
console_config.max_cmdline_length = 256;
#if CONFIG_LOG_COLORS
console_config.hint_color = atoi(LOG_COLOR_CYAN);
#endif
ESP_ERROR_CHECK(esp_console_init(&console_config));
/* Configure linenoise line completion library */
/* Enable multiline editing. If not set, long commands will scroll within
* single line.
*/
linenoiseSetMultiLine(1);
/* Tell linenoise where to get command completions and hints */
linenoiseSetCompletionCallback(&esp_console_get_completion);
linenoiseSetHintsCallback((linenoiseHintsCallback*) &esp_console_get_hint);
/* Set command history size */
linenoiseHistorySetMaxLen(100);
}
开发者ID:bullestock,项目名称:chairbot,代码行数:52,代码来源:console.cpp
示例17: app_main
void app_main()
{
// Initialize NVS.
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK( err );
initialise_wifi();
xTaskCreate(&aws_iot_task, "aws_iot_task", 9216, NULL, 5, NULL);
}
开发者ID:espressif,项目名称:ESP8266_RTOS_SDK,代码行数:13,代码来源:subscribe_publish_sample.c
示例18: app_main
int app_main(void)
{
nvs_flash_init();
system_init();
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) );
I2CScanner();
return 0;
}
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:13,代码来源:main.c
示例19: app_main
void app_main()
{
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK( err );
initialise_wifi();
/* Temporarily pin task to core, due to FPU uncertainty */
xTaskCreatePinnedToCore(&aws_iot_task, "aws_iot_task", 16384+1024, NULL, 5, NULL, 1);
}
开发者ID:danathughes,项目名称:esp-idf,代码行数:13,代码来源:thing_shadow_sample.c
示例20: bootWiFi
/**
* Main entry into bootWiFi
*/
void bootWiFi(bootwifi_callback_t callback) {
ESP_LOGD(tag, ">> bootWiFi");
g_callback = callback;
nvs_flash_init();
tcpip_adapter_init();
ESP_ERROR_CHECK(esp_event_loop_init(esp32_wifi_eventHandler, 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));
bootWiFi2();
ESP_LOGD(tag, "<< bootWiFi");
} // bootWiFi
开发者ID:EdWeller,项目名称:esp32-snippets,代码行数:17,代码来源:bootwifi.c
注:本文中的ESP_ERROR_CHECK函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论