mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'master' into feature/esp32s2beta_update
This commit is contained in:
commit
04ae56806c
6
.gitignore
vendored
6
.gitignore
vendored
@ -63,8 +63,12 @@ test_multi_heap_host
|
||||
# VS Code Settings
|
||||
.vscode/
|
||||
|
||||
# Clion IDE CMake build & config
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
|
||||
# Results for the checking of the Python coding style
|
||||
flake8_output.txt
|
||||
|
||||
# ESP-IDF library
|
||||
# ESP-IDF default build directory name
|
||||
build
|
||||
|
@ -360,7 +360,7 @@ static esp_apptrace_hw_t s_trace_hw[ESP_APPTRACE_HW_MAX] = {
|
||||
}
|
||||
};
|
||||
|
||||
static inline int esp_apptrace_log_lock()
|
||||
static inline int esp_apptrace_log_lock(void)
|
||||
{
|
||||
#if ESP_APPTRACE_PRINT_LOCK
|
||||
esp_apptrace_tmo_t tmo;
|
||||
@ -372,22 +372,22 @@ static inline int esp_apptrace_log_lock()
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void esp_apptrace_log_unlock()
|
||||
static inline void esp_apptrace_log_unlock(void)
|
||||
{
|
||||
#if ESP_APPTRACE_PRINT_LOCK
|
||||
esp_apptrace_lock_give(&s_log_lock);
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline esp_err_t esp_apptrace_lock_initialize()
|
||||
static inline esp_err_t esp_apptrace_lock_initialize(esp_apptrace_lock_t *lock)
|
||||
{
|
||||
#if CONFIG_ESP32_APPTRACE_LOCK_ENABLE
|
||||
esp_apptrace_lock_init(&s_trace_buf.lock);
|
||||
esp_apptrace_lock_init(lock);
|
||||
#endif
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static inline esp_err_t esp_apptrace_lock_cleanup()
|
||||
static inline esp_err_t esp_apptrace_lock_cleanup(void)
|
||||
{
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -403,7 +403,7 @@ esp_err_t esp_apptrace_lock(esp_apptrace_tmo_t *tmo)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_apptrace_unlock()
|
||||
esp_err_t esp_apptrace_unlock(void)
|
||||
{
|
||||
esp_err_t ret = ESP_OK;
|
||||
#if CONFIG_ESP32_APPTRACE_LOCK_ENABLE
|
||||
@ -413,7 +413,7 @@ esp_err_t esp_apptrace_unlock()
|
||||
}
|
||||
|
||||
#if CONFIG_ESP32_APPTRACE_DEST_TRAX
|
||||
static void esp_apptrace_trax_init()
|
||||
static void esp_apptrace_trax_init(void)
|
||||
{
|
||||
// Stop trace, if any (on the current CPU)
|
||||
eri_write(ERI_TRAX_TRAXCTRL, TRAXCTRL_TRSTP);
|
||||
@ -449,7 +449,7 @@ static void esp_apptrace_trax_pend_chunk_sz_update(uint16_t size)
|
||||
}
|
||||
}
|
||||
|
||||
static uint16_t esp_apptrace_trax_pend_chunk_sz_get()
|
||||
static uint16_t esp_apptrace_trax_pend_chunk_sz_get(void)
|
||||
{
|
||||
uint16_t ch_sz;
|
||||
ESP_APPTRACE_LOGD("Get chunk enter %d w-r-s %d-%d-%d", s_trace_buf.trax.cur_pending_chunk_sz,
|
||||
@ -467,7 +467,7 @@ static uint16_t esp_apptrace_trax_pend_chunk_sz_get()
|
||||
#endif
|
||||
|
||||
// assumed to be protected by caller from multi-core/thread access
|
||||
static esp_err_t esp_apptrace_trax_block_switch()
|
||||
static esp_err_t esp_apptrace_trax_block_switch(void)
|
||||
{
|
||||
int prev_block_num = s_trace_buf.trax.state.in_block % 2;
|
||||
int new_block_num = prev_block_num ? (0) : (1);
|
||||
@ -845,7 +845,7 @@ static esp_err_t esp_apptrace_trax_status_reg_get(uint32_t *val)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t esp_apptrace_trax_dest_init()
|
||||
static esp_err_t esp_apptrace_trax_dest_init(void)
|
||||
{
|
||||
for (int i = 0; i < ESP_APPTRACE_TRAX_BLOCKS_NUM; i++) {
|
||||
s_trace_buf.trax.blocks[i].start = (uint8_t *)s_trax_blocks[i];
|
||||
@ -874,7 +874,7 @@ static esp_err_t esp_apptrace_trax_dest_init()
|
||||
}
|
||||
#endif
|
||||
|
||||
esp_err_t esp_apptrace_init()
|
||||
esp_err_t esp_apptrace_init(void)
|
||||
{
|
||||
int res;
|
||||
|
||||
|
@ -114,7 +114,7 @@ static int esp_dbg_stub_gcov_entry(void)
|
||||
#endif
|
||||
}
|
||||
|
||||
void esp_gcov_dump()
|
||||
void esp_gcov_dump(void)
|
||||
{
|
||||
// disable IRQs on this CPU, other CPU is halted by OpenOCD
|
||||
unsigned irq_state = portENTER_CRITICAL_NESTED();
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
static bool s_tracing;
|
||||
|
||||
esp_err_t heap_trace_init_tohost()
|
||||
esp_err_t heap_trace_init_tohost(void)
|
||||
{
|
||||
if (s_tracing) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
|
@ -33,7 +33,7 @@ typedef enum {
|
||||
*
|
||||
* @return ESP_OK on success, otherwise see esp_err_t
|
||||
*/
|
||||
esp_err_t esp_apptrace_init();
|
||||
esp_err_t esp_apptrace_init(void);
|
||||
|
||||
/**
|
||||
* @brief Configures down buffer.
|
||||
|
@ -285,12 +285,12 @@ Revision: $Rev: 5626 $
|
||||
* RTT lock configuration fallback
|
||||
*/
|
||||
#ifndef SEGGER_RTT_LOCK
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock();
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock(void);
|
||||
#define SEGGER_RTT_LOCK() SEGGER_SYSVIEW_X_RTT_Lock() // Lock RTT (nestable) (i.e. disable interrupts)
|
||||
#endif
|
||||
|
||||
#ifndef SEGGER_RTT_UNLOCK
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock();
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock(void);
|
||||
#define SEGGER_RTT_UNLOCK() SEGGER_SYSVIEW_X_RTT_Unlock() // Unlock RTT (nestable) (i.e. enable previous interrupt lock state)
|
||||
#endif
|
||||
|
||||
|
@ -168,7 +168,7 @@ Revision: $Rev: 5927 $
|
||||
#define SEGGER_SYSVIEW_GET_INTERRUPT_ID() SEGGER_SYSVIEW_X_GetInterruptId() // Get the currently active interrupt Id from the user-provided function.
|
||||
#endif
|
||||
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock();
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void);
|
||||
void SEGGER_SYSVIEW_X_SysView_Unlock(unsigned int_state);
|
||||
// to be recursive save IRQ status on the stack of the caller
|
||||
#define SEGGER_SYSVIEW_LOCK() unsigned _SYSVIEW_int_state = SEGGER_SYSVIEW_X_SysView_Lock()
|
||||
|
@ -245,7 +245,7 @@ static void _cbSendSystemDesc(void) {
|
||||
*
|
||||
**********************************************************************
|
||||
*/
|
||||
static void SEGGER_SYSVIEW_TS_Init()
|
||||
static void SEGGER_SYSVIEW_TS_Init(void)
|
||||
{
|
||||
/* We only need to initialize something if we use Timer Group.
|
||||
* esp_timer and ccount can be used as is.
|
||||
@ -317,7 +317,7 @@ void SEGGER_SYSVIEW_Conf(void) {
|
||||
SEGGER_SYSVIEW_DisableEvents(disable_evts);
|
||||
}
|
||||
|
||||
U32 SEGGER_SYSVIEW_X_GetTimestamp()
|
||||
U32 SEGGER_SYSVIEW_X_GetTimestamp(void)
|
||||
{
|
||||
#if TS_USE_TIMERGROUP
|
||||
uint64_t ts = 0;
|
||||
@ -330,15 +330,15 @@ U32 SEGGER_SYSVIEW_X_GetTimestamp()
|
||||
#endif
|
||||
}
|
||||
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock()
|
||||
void SEGGER_SYSVIEW_X_RTT_Lock(void)
|
||||
{
|
||||
}
|
||||
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock()
|
||||
void SEGGER_SYSVIEW_X_RTT_Unlock(void)
|
||||
{
|
||||
}
|
||||
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock()
|
||||
unsigned SEGGER_SYSVIEW_X_SysView_Lock(void)
|
||||
{
|
||||
esp_apptrace_tmo_t tmo;
|
||||
esp_apptrace_tmo_init(&tmo, SEGGER_LOCK_WAIT_TMO);
|
||||
|
@ -125,7 +125,7 @@ typedef struct {
|
||||
static SemaphoreHandle_t s_print_lock;
|
||||
#endif
|
||||
|
||||
static uint64_t esp_apptrace_test_ts_get();
|
||||
static uint64_t esp_apptrace_test_ts_get(void);
|
||||
|
||||
static void esp_apptrace_test_timer_isr(void *arg)
|
||||
{
|
||||
@ -383,7 +383,7 @@ static void esp_apptrace_test_task_crash(void *p)
|
||||
|
||||
static int s_ts_timer_group, s_ts_timer_idx;
|
||||
|
||||
static uint64_t esp_apptrace_test_ts_get()
|
||||
static uint64_t esp_apptrace_test_ts_get(void)
|
||||
{
|
||||
uint64_t ts = 0;
|
||||
timer_get_counter_value(s_ts_timer_group, s_ts_timer_idx, &ts);
|
||||
@ -413,7 +413,7 @@ static void esp_apptrace_test_ts_init(int timer_group, int timer_idx)
|
||||
timer_start(timer_group, timer_idx);
|
||||
}
|
||||
|
||||
static void esp_apptrace_test_ts_cleanup()
|
||||
static void esp_apptrace_test_ts_cleanup(void)
|
||||
{
|
||||
timer_config_t config;
|
||||
|
||||
|
@ -689,12 +689,12 @@ static esp_err_t esp_ota_current_ota_is_workable(bool valid)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback()
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback(void)
|
||||
{
|
||||
return esp_ota_current_ota_is_workable(true);
|
||||
}
|
||||
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot()
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void)
|
||||
{
|
||||
return esp_ota_current_ota_is_workable(false);
|
||||
}
|
||||
@ -717,7 +717,7 @@ static int get_last_invalid_otadata(const esp_ota_select_entry_t *two_otadata)
|
||||
return num_invalid_otadata;
|
||||
}
|
||||
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition()
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition(void)
|
||||
{
|
||||
esp_ota_select_entry_t otadata[2];
|
||||
if (read_otadata(otadata) == NULL) {
|
||||
|
@ -221,7 +221,7 @@ esp_err_t esp_ota_get_partition_description(const esp_partition_t *partition, es
|
||||
* @return
|
||||
* - ESP_OK: if successful.
|
||||
*/
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback();
|
||||
esp_err_t esp_ota_mark_app_valid_cancel_rollback(void);
|
||||
|
||||
/**
|
||||
* @brief This function is called to roll back to the previously workable app with reboot.
|
||||
@ -233,14 +233,14 @@ esp_err_t esp_ota_mark_app_valid_cancel_rollback();
|
||||
* - ESP_FAIL: if not successful.
|
||||
* - ESP_ERR_OTA_ROLLBACK_FAILED: The rollback is not possible due to flash does not have any apps.
|
||||
*/
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot();
|
||||
esp_err_t esp_ota_mark_app_invalid_rollback_and_reboot(void);
|
||||
|
||||
/**
|
||||
* @brief Returns last partition with invalid state (ESP_OTA_IMG_INVALID or ESP_OTA_IMG_ABORTED).
|
||||
*
|
||||
* @return partition.
|
||||
*/
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition();
|
||||
const esp_partition_t* esp_ota_get_last_invalid_partition(void);
|
||||
|
||||
/**
|
||||
* @brief Returns state for given partition.
|
||||
|
@ -118,7 +118,7 @@ static void reboot_as_deep_sleep(void)
|
||||
|
||||
/* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx.
|
||||
*/
|
||||
static void copy_current_app_to_next_part_and_reboot()
|
||||
static void copy_current_app_to_next_part_and_reboot(void)
|
||||
{
|
||||
const esp_partition_t *cur_app = esp_ota_get_running_partition();
|
||||
copy_current_app_to_next_part(cur_app, get_next_update_partition());
|
||||
@ -264,19 +264,19 @@ static void test_flow1(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 4:
|
||||
ESP_LOGI(TAG, "OTA1");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 5:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
@ -307,7 +307,7 @@ static void test_flow2(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
@ -344,13 +344,13 @@ static void test_flow3(void)
|
||||
case 2:
|
||||
ESP_LOGI(TAG, "Factory");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
|
||||
mark_app_valid();
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 4:
|
||||
ESP_LOGI(TAG, "OTA1");
|
||||
@ -402,7 +402,7 @@ static void test_flow4(void)
|
||||
nvs_close(handle);
|
||||
nvs_flash_deinit();
|
||||
|
||||
copy_current_app_to_next_part_and_reboot(cur_app);
|
||||
copy_current_app_to_next_part_and_reboot();
|
||||
break;
|
||||
case 3:
|
||||
ESP_LOGI(TAG, "OTA0");
|
||||
|
@ -38,7 +38,7 @@ static int selected_boot_partition(const bootloader_state_t *bs);
|
||||
* The hardware is mostly uninitialized, flash cache is down and the app CPU is in reset.
|
||||
* We do have a stack, so we can do the initialization in C.
|
||||
*/
|
||||
void __attribute__((noreturn)) call_start_cpu0()
|
||||
void __attribute__((noreturn)) call_start_cpu0(void)
|
||||
{
|
||||
// 1. Hardware initialization
|
||||
if (bootloader_init() != ESP_OK) {
|
||||
@ -117,7 +117,7 @@ static int selected_boot_partition(const bootloader_state_t *bs)
|
||||
}
|
||||
|
||||
// Return global reent struct if any newlib functions are linked to bootloader
|
||||
struct _reent* __getreent() {
|
||||
struct _reent* __getreent(void) {
|
||||
return _GLOBAL_REENT;
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,16 @@ set(srcs
|
||||
"src/bootloader_random.c"
|
||||
"src/bootloader_utility.c"
|
||||
"src/esp_image_format.c"
|
||||
"src/flash_encrypt.c"
|
||||
"src/flash_partitions.c"
|
||||
"src/flash_qio_mode.c"
|
||||
"src/${IDF_TARGET}/bootloader_flash_config_${IDF_TARGET}.c"
|
||||
)
|
||||
|
||||
if(CONFIG_IDF_TARGET_ESP32)
|
||||
# Not supported on ESP32S2Beta yet
|
||||
list(APPEND srcs "src/flash_encrypt.c")
|
||||
endif()
|
||||
|
||||
if(BOOTLOADER_BUILD)
|
||||
set(include_dirs "include" "include_bootloader")
|
||||
set(priv_requires micro-ecc spi_flash efuse)
|
||||
|
@ -151,7 +151,7 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
/**
|
||||
* @brief Configure VDDSDIO, call this API to rise VDDSDIO to 1.9V when VDDSDIO regulator is enabled as 1.8V mode.
|
||||
*/
|
||||
void bootloader_common_vddsdio_configure();
|
||||
void bootloader_common_vddsdio_configure(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ extern "C" {
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_update_id();
|
||||
void bootloader_flash_update_id(void);
|
||||
|
||||
/**
|
||||
* @brief Set the flash CS setup and hold time.
|
||||
@ -35,7 +35,7 @@ void bootloader_flash_update_id();
|
||||
*
|
||||
* @return None
|
||||
*/
|
||||
void bootloader_flash_cs_timing_config();
|
||||
void bootloader_flash_cs_timing_config(void);
|
||||
|
||||
/**
|
||||
* @brief Configure SPI flash clock.
|
||||
|
@ -129,7 +129,7 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length);
|
||||
* serial re-flashing of an unauthorised code in absence of secure boot.
|
||||
*
|
||||
*/
|
||||
void esp_flash_write_protect_crypt_cnt();
|
||||
void esp_flash_write_protect_crypt_cnt(void);
|
||||
|
||||
/** @brief Return the flash encryption mode
|
||||
*
|
||||
@ -138,7 +138,7 @@ void esp_flash_write_protect_crypt_cnt();
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode();
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
uint32_t bootloader_mmap_get_free_pages(void);
|
||||
|
||||
/**
|
||||
* @brief Map a region of flash to data memory
|
||||
|
@ -25,4 +25,4 @@
|
||||
* @return ESP_OK - If the setting is successful.
|
||||
* ESP_FAIL - If the setting is not successful.
|
||||
*/
|
||||
esp_err_t bootloader_init();
|
||||
esp_err_t bootloader_init(void);
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
typedef void *bootloader_sha256_handle_t;
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start();
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void);
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);
|
||||
|
||||
|
@ -30,7 +30,7 @@ void bootloader_enable_qio_mode(void);
|
||||
* mfg_id = (ID >> 16) & 0xFF;
|
||||
flash_id = ID & 0xffff;
|
||||
*/
|
||||
uint32_t bootloader_read_flash_id();
|
||||
uint32_t bootloader_read_flash_id(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "soc/dport_reg.h"
|
||||
#include "soc/efuse_periph.h"
|
||||
|
||||
void bootloader_clock_configure()
|
||||
void bootloader_clock_configure(void)
|
||||
{
|
||||
// ROM bootloader may have put a lot of text into UART0 FIFO.
|
||||
// Wait for it to be printed.
|
||||
|
@ -263,7 +263,7 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
void bootloader_common_vddsdio_configure()
|
||||
void bootloader_common_vddsdio_configure(void)
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V
|
||||
rtc_vddsdio_config_t cfg = rtc_vddsdio_get_config();
|
||||
|
@ -28,7 +28,7 @@ static const char *TAG = "bootloader_mmap";
|
||||
|
||||
static spi_flash_mmap_handle_t map;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
uint32_t bootloader_mmap_get_free_pages(void)
|
||||
{
|
||||
return spi_flash_mmap_get_free_pages(SPI_FLASH_MMAP_DATA);
|
||||
}
|
||||
@ -127,7 +127,7 @@ static bool mapped;
|
||||
// Current bootloader mapping (ab)used for bootloader_read()
|
||||
static uint32_t current_read_mapping = UINT32_MAX;
|
||||
|
||||
uint32_t bootloader_mmap_get_free_pages()
|
||||
uint32_t bootloader_mmap_get_free_pages(void)
|
||||
{
|
||||
/**
|
||||
* Allow mapping up to 50 of the 51 available MMU blocks (last one used for reads)
|
||||
|
@ -81,15 +81,15 @@ extern int _data_end;
|
||||
|
||||
static const char *TAG = "boot";
|
||||
|
||||
static esp_err_t bootloader_main();
|
||||
static void print_flash_info(const esp_image_header_t *pfhdr);
|
||||
static void update_flash_config(const esp_image_header_t *pfhdr);
|
||||
static esp_err_t bootloader_main(void);
|
||||
static void print_flash_info(const esp_image_header_t* pfhdr);
|
||||
static void update_flash_config(const esp_image_header_t* pfhdr);
|
||||
static void bootloader_init_flash_configure(const esp_image_header_t* pfhdr);
|
||||
static void uart_console_configure(void);
|
||||
static void wdt_reset_check(void);
|
||||
|
||||
|
||||
esp_err_t bootloader_init()
|
||||
esp_err_t bootloader_init(void)
|
||||
{
|
||||
cpu_configure_region_protection();
|
||||
cpu_init_memctl();
|
||||
@ -150,9 +150,6 @@ esp_err_t bootloader_init()
|
||||
#endif
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
DPORT_REG_CLR_BIT(DPORT_PRO_ICACHE_CTRL1_REG, DPORT_PRO_ICACHE_MASK_DROM0);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
DPORT_REG_CLR_BIT(DPORT_APP_ICACHE_CTRL1_REG, DPORT_APP_ICACHE_MASK_DROM0);
|
||||
#endif
|
||||
#endif
|
||||
if (bootloader_main() != ESP_OK) {
|
||||
return ESP_FAIL;
|
||||
@ -160,7 +157,7 @@ esp_err_t bootloader_init()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t bootloader_main()
|
||||
static esp_err_t bootloader_main(void)
|
||||
{
|
||||
bootloader_common_vddsdio_configure();
|
||||
/* Read and keep flash ID, for further use. */
|
||||
@ -537,7 +534,7 @@ void __assert_func(const char *file, int line, const char *func, const char *exp
|
||||
while (1) {}
|
||||
}
|
||||
|
||||
void abort()
|
||||
void abort(void)
|
||||
{
|
||||
#if !(CONFIG_ESP32_PANIC_SILENT_REBOOT || CONFIG_ESP32S2_PANIC_SILENT_REBOOT)
|
||||
ets_printf("abort() was called at PC 0x%08x\r\n", (intptr_t)__builtin_return_address(0) - 3);
|
||||
|
@ -680,7 +680,7 @@ static void set_cache_and_start_app(
|
||||
64, drom_page_count, 0);
|
||||
#endif
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
#if CONFIG_IDF_TARGET_ESP32 && !CONFIG_FREERTOS_UNICORE
|
||||
rc = cache_flash_mmu_set(1, 0, drom_load_addr_aligned, drom_addr & MMU_FLASH_MASK, 64, drom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#endif
|
||||
@ -713,11 +713,11 @@ static void set_cache_and_start_app(
|
||||
rc = Cache_Ibus_MMU_Set(DPORT_MMU_ACCESS_FLASH, irom_load_addr & 0xffff0000, irom_addr & 0xffff0000, 64, irom_page_count, 0);
|
||||
#endif
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
rc = cache_flash_mmu_set(1, 0, irom_load_addr_aligned, irom_addr & MMU_FLASH_MASK, 64, irom_page_count);
|
||||
ESP_LOGV(TAG, "rc=%d", rc);
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_CACHE_CTRL1_REG,
|
||||
(DPORT_PRO_CACHE_MASK_IRAM0) | (DPORT_PRO_CACHE_MASK_IRAM1 & 0) |
|
||||
(DPORT_PRO_CACHE_MASK_IROM0 & 0) | DPORT_PRO_CACHE_MASK_DROM0 |
|
||||
@ -730,9 +730,6 @@ static void set_cache_and_start_app(
|
||||
#endif
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
DPORT_REG_CLR_BIT( DPORT_PRO_ICACHE_CTRL1_REG, (DPORT_PRO_ICACHE_MASK_IRAM0) | (DPORT_PRO_ICACHE_MASK_IRAM1 & 0) | (DPORT_PRO_ICACHE_MASK_IROM0 & 0) | DPORT_PRO_ICACHE_MASK_DROM0 );
|
||||
#if !CONFIG_FREERTOS_UNICORE
|
||||
DPORT_REG_CLR_BIT( DPORT_APP_ICACHE_CTRL1_REG, (DPORT_APP_ICACHE_MASK_IRAM0) | (DPORT_APP_ICACHE_MASK_IRAM1 & 0) | (DPORT_APP_ICACHE_MASK_IROM0 & 0) | DPORT_APP_ICACHE_MASK_DROM0 );
|
||||
#endif
|
||||
#endif
|
||||
#if CONFIG_IDF_TARGET_ESP32
|
||||
Cache_Read_Enable(0);
|
||||
|
@ -27,12 +27,12 @@
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
void bootloader_flash_update_id()
|
||||
void bootloader_flash_update_id(void)
|
||||
{
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config(void)
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
|
@ -28,7 +28,7 @@ static const size_t BLOCK_WORDS = (64 / sizeof(uint32_t));
|
||||
// Words in final SHA256 digest
|
||||
static const size_t DIGEST_WORDS = (32 / sizeof(uint32_t));
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
|
@ -38,7 +38,7 @@ static const char *TAG = "flash_encrypt";
|
||||
/* Static functions for stages of flash encryption */
|
||||
static esp_err_t initialise_flash_encryption(void);
|
||||
static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_crypt_wr_dis);
|
||||
static esp_err_t encrypt_bootloader();
|
||||
static esp_err_t encrypt_bootloader(void);
|
||||
static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions);
|
||||
static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition);
|
||||
|
||||
@ -223,7 +223,7 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t encrypt_bootloader()
|
||||
static esp_err_t encrypt_bootloader(void)
|
||||
{
|
||||
esp_err_t err;
|
||||
uint32_t image_length;
|
||||
|
@ -95,7 +95,7 @@ static bool secure_boot_generate(uint32_t image_len){
|
||||
}
|
||||
|
||||
/* Burn values written to the efuse write registers */
|
||||
static inline void burn_efuses()
|
||||
static inline void burn_efuses(void)
|
||||
{
|
||||
esp_efuse_burn_new_values();
|
||||
}
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_mem_reg.h"
|
||||
#include "soc/spi_caps.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
@ -35,11 +36,11 @@ void bootloader_flash_update_id()
|
||||
void IRAM_ATTR bootloader_flash_cs_timing_config()
|
||||
{
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(0), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_CS_HOLD_TIME_V, 1, SPI_CS_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(0), SPI_CS_SETUP_TIME_V, 0, SPI_CS_SETUP_TIME_S);
|
||||
SET_PERI_REG_MASK(SPI_USER_REG(1), SPI_CS_HOLD_M | SPI_CS_SETUP_M);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_HOLD_TIME_V, 1, SPI_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_SETUP_TIME_V, 0, SPI_SETUP_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_CS_HOLD_TIME_V, 1, SPI_CS_HOLD_TIME_S);
|
||||
SET_PERI_REG_BITS(SPI_CTRL2_REG(1), SPI_CS_SETUP_TIME_V, 0, SPI_CS_SETUP_TIME_S);
|
||||
}
|
||||
|
||||
void IRAM_ATTR bootloader_flash_clock_config(const esp_image_header_t* pfhdr)
|
||||
@ -73,10 +74,10 @@ void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
|
||||
{
|
||||
int spi_cache_dummy = 0;
|
||||
uint32_t modebit = READ_PERI_REG(SPI_CTRL_REG(0));
|
||||
if (modebit & SPI_FASTRD_MODE) {
|
||||
if (modebit & SPI_FREAD_QIO) { //SPI mode is QIO
|
||||
if (modebit & SPI_FAST_RD_MODE) {
|
||||
if (modebit & SPI_FREAD_QUAD) { //SPI mode is QIO
|
||||
spi_cache_dummy = SPI0_R_QIO_DUMMY_CYCLELEN;
|
||||
} else if (modebit & SPI_FREAD_DIO) { //SPI mode is DIO
|
||||
} else if (modebit & SPI_FREAD_DUAL) { //SPI mode is DIO
|
||||
spi_cache_dummy = SPI0_R_DIO_DUMMY_CYCLELEN;
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_ADDR_BITLEN_V, SPI0_R_DIO_ADDR_BITSLEN, SPI_USR_ADDR_BITLEN_S);
|
||||
} else if(modebit & (SPI_FREAD_QUAD | SPI_FREAD_DUAL)) { //SPI mode is QOUT or DIO
|
||||
@ -103,7 +104,11 @@ void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
|
||||
break;
|
||||
}
|
||||
|
||||
SET_PERI_REG_BITS(SPI_MEM_USER1_REG(0), SPI_MEM_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M,
|
||||
SPI_MEM_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
|
||||
#define FLASH_IO_MATRIX_DUMMY_40M 0
|
||||
#define FLASH_IO_MATRIX_DUMMY_80M 0
|
||||
|
||||
SET_PERI_REG_BITS(SPI_MEM_USER1_REG(0), SPI_MEM_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + FLASH_IO_MATRIX_DUMMY_80M,
|
||||
SPI_MEM_USR_DUMMY_CYCLELEN_S); //DUMMY
|
||||
|
||||
}
|
@ -17,7 +17,7 @@
|
||||
#include "esp_efuse_table.h"
|
||||
#include "esp_flash_encrypt.h"
|
||||
|
||||
void esp_flash_write_protect_crypt_cnt()
|
||||
void esp_flash_write_protect_crypt_cnt(void)
|
||||
{
|
||||
uint8_t flash_crypt_cnt_wr_dis = 0;
|
||||
esp_efuse_read_field_blob(ESP_EFUSE_WR_DIS_FLASH_CRYPT_CNT, &flash_crypt_cnt_wr_dis, 1);
|
||||
@ -26,7 +26,7 @@ void esp_flash_write_protect_crypt_cnt()
|
||||
}
|
||||
}
|
||||
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode()
|
||||
esp_flash_enc_mode_t esp_get_flash_encryption_mode(void)
|
||||
{
|
||||
uint8_t efuse_flash_crypt_cnt_wr_protected = 0;
|
||||
uint8_t dis_dl_enc = 0, dis_dl_dec = 0, dis_dl_cache = 0;
|
||||
|
@ -53,7 +53,7 @@
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
|
||||
typedef unsigned (*read_status_fn_t)();
|
||||
typedef unsigned (*read_status_fn_t)(void);
|
||||
typedef void (*write_status_fn_t)(unsigned);
|
||||
|
||||
typedef struct __attribute__((packed))
|
||||
@ -68,11 +68,11 @@ typedef struct __attribute__((packed))
|
||||
} qio_info_t;
|
||||
|
||||
/* Read 8 bit status using RDSR command */
|
||||
static unsigned read_status_8b_rdsr();
|
||||
static unsigned read_status_8b_rdsr(void);
|
||||
/* Read 8 bit status (second byte) using RDSR2 command */
|
||||
static unsigned read_status_8b_rdsr2();
|
||||
static unsigned read_status_8b_rdsr2(void);
|
||||
/* read 16 bit status using RDSR & RDSR2 (low and high bytes) */
|
||||
static unsigned read_status_16b_rdsr_rdsr2();
|
||||
static unsigned read_status_16b_rdsr_rdsr2(void);
|
||||
|
||||
/* Write 8 bit status using WRSR */
|
||||
static void write_status_8b_wrsr(unsigned new_status);
|
||||
@ -82,7 +82,7 @@ static void write_status_8b_wrsr2(unsigned new_status);
|
||||
static void write_status_16b_wrsr(unsigned new_status);
|
||||
|
||||
/* Read 8 bit status of XM25QU64A */
|
||||
static unsigned read_status_8b_xmc25qu64a();
|
||||
static unsigned read_status_8b_xmc25qu64a(void);
|
||||
/* Write 8 bit status of XM25QU64A */
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status);
|
||||
|
||||
@ -136,7 +136,7 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
uint32_t bootloader_read_flash_id()
|
||||
uint32_t bootloader_read_flash_id(void)
|
||||
{
|
||||
uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
@ -289,17 +289,17 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr()
|
||||
static unsigned read_status_8b_rdsr(void)
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_rdsr2()
|
||||
static unsigned read_status_8b_rdsr2(void)
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR2, 0, 0, 8);
|
||||
}
|
||||
|
||||
static unsigned read_status_16b_rdsr_rdsr2()
|
||||
static unsigned read_status_16b_rdsr_rdsr2(void)
|
||||
{
|
||||
return execute_flash_command(CMD_RDSR, 0, 0, 8) | (execute_flash_command(CMD_RDSR2, 0, 0, 8) << 8);
|
||||
}
|
||||
@ -319,7 +319,7 @@ static void write_status_16b_wrsr(unsigned new_status)
|
||||
execute_flash_command(CMD_WRSR, new_status, 16, 0);
|
||||
}
|
||||
|
||||
static unsigned read_status_8b_xmc25qu64a()
|
||||
static unsigned read_status_8b_xmc25qu64a(void)
|
||||
{
|
||||
execute_flash_command(CMD_OTPEN, 0, 0, 0); /* Enter OTP mode */
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <sys/param.h>
|
||||
#include <mbedtls/sha256.h>
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
|
||||
if (!ctx) {
|
||||
|
@ -203,7 +203,8 @@ extern void btdm_controller_enable_sleep(bool enable);
|
||||
extern void btdm_controller_set_sleep_mode(uint8_t mode);
|
||||
extern uint8_t btdm_controller_get_sleep_mode(void);
|
||||
extern bool btdm_power_state_active(void);
|
||||
extern void btdm_wakeup_request(void);
|
||||
extern void btdm_wakeup_request(bool request_lock);
|
||||
extern void btdm_wakeup_request_end(void);
|
||||
/* Low Power Clock */
|
||||
extern bool btdm_lpclk_select_src(uint32_t sel);
|
||||
extern bool btdm_lpclk_set_div(uint32_t div);
|
||||
@ -893,6 +894,8 @@ bool esp_vhci_host_check_send_available(void)
|
||||
|
||||
void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
{
|
||||
bool do_wakeup_request = false;
|
||||
|
||||
if (!btdm_power_state_active()) {
|
||||
#if CONFIG_PM_ENABLE
|
||||
if (semphr_take_wrapper(s_pm_lock_sem, 0)) {
|
||||
@ -900,9 +903,15 @@ void esp_vhci_host_send_packet(uint8_t *data, uint16_t len)
|
||||
}
|
||||
esp_timer_stop(s_btdm_slp_tmr);
|
||||
#endif
|
||||
btdm_wakeup_request();
|
||||
do_wakeup_request = true;
|
||||
btdm_wakeup_request(true);
|
||||
}
|
||||
|
||||
API_vhci_host_send_packet(data, len);
|
||||
|
||||
if (do_wakeup_request) {
|
||||
btdm_wakeup_request_end();
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback)
|
||||
@ -1328,7 +1337,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (btdm_controller_get_sleep_mode() == BTDM_MODEM_SLEEP_MODE_ORIG) {
|
||||
btdm_controller_enable_sleep(false);
|
||||
if (!btdm_power_state_active()) {
|
||||
btdm_wakeup_request();
|
||||
btdm_wakeup_request(false);
|
||||
}
|
||||
while (!btdm_power_state_active()) {
|
||||
ets_delay_us(1000);
|
||||
@ -1466,7 +1475,7 @@ void esp_bt_controller_wakeup_request(void)
|
||||
return;
|
||||
}
|
||||
|
||||
btdm_wakeup_request();
|
||||
btdm_wakeup_request(false);
|
||||
}
|
||||
|
||||
esp_err_t esp_bredr_sco_datapath_set(esp_sco_data_path_t data_path)
|
||||
|
@ -54,7 +54,7 @@ esp_err_t esp_spp_init(esp_spp_mode_t mode)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_deinit()
|
||||
esp_err_t esp_spp_deinit(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
@ -164,7 +164,7 @@ esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), btc_spp_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_vfs_register()
|
||||
esp_err_t esp_spp_vfs_register(void)
|
||||
{
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
|
@ -205,7 +205,7 @@ esp_err_t esp_spp_init(esp_spp_mode_t mode);
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_deinit();
|
||||
esp_err_t esp_spp_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -360,7 +360,7 @@ const tBTA_DM_ST_TBL bta_dm_search_st_tbl[] = {
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sm_disable( )
|
||||
void bta_dm_sm_disable(void)
|
||||
{
|
||||
bta_sys_deregister( BTA_ID_DM );
|
||||
}
|
||||
@ -412,7 +412,7 @@ BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_search_sm_disable( )
|
||||
void bta_dm_search_sm_disable(void)
|
||||
{
|
||||
bta_sys_deregister( BTA_ID_DM_SEARCH );
|
||||
|
||||
|
@ -46,7 +46,7 @@ static void bta_dm_pm_timer_cback(void *p_tle);
|
||||
static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 value, UINT8 hci_status);
|
||||
static BOOLEAN bta_dm_pm_park(BD_ADDR peer_addr);
|
||||
static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index);
|
||||
static BOOLEAN bta_dm_pm_is_sco_active ();
|
||||
static BOOLEAN bta_dm_pm_is_sco_active (void);
|
||||
static void bta_dm_pm_hid_check(BOOLEAN bScoActive);
|
||||
static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable);
|
||||
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
@ -1001,7 +1001,7 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data)
|
||||
** Returns BOOLEAN. TRUE if SCO active, else FALSE
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_dm_pm_is_sco_active ()
|
||||
static BOOLEAN bta_dm_pm_is_sco_active (void)
|
||||
{
|
||||
int j;
|
||||
BOOLEAN bScoActive = FALSE;
|
||||
|
@ -48,7 +48,7 @@ static void getFilename(char *buffer, BD_ADDR bda)
|
||||
, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
}
|
||||
|
||||
static void cacheClose()
|
||||
static void cacheClose(void)
|
||||
{
|
||||
if (sCacheFD != 0) {
|
||||
fclose(sCacheFD);
|
||||
|
@ -94,7 +94,7 @@ UINT32 service_index = 0;
|
||||
BOOLEAN service_availability = TRUE;
|
||||
/* helper functions for handling AT commands queueing */
|
||||
|
||||
static void bta_hf_client_handle_ok();
|
||||
static void bta_hf_client_handle_ok(void);
|
||||
|
||||
static void bta_hf_client_clear_queued_at(void)
|
||||
{
|
||||
@ -268,7 +268,7 @@ static void bta_hf_client_start_at_hold_timer(void)
|
||||
** No buffer parsing is being done here.
|
||||
*******************************************************************************/
|
||||
|
||||
static void bta_hf_client_handle_ok()
|
||||
static void bta_hf_client_handle_ok(void)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
|
||||
@ -342,7 +342,7 @@ static void bta_hf_client_handle_error(tBTA_HF_CLIENT_AT_RESULT_TYPE type, UINT1
|
||||
bta_hf_client_send_queued_at();
|
||||
}
|
||||
|
||||
static void bta_hf_client_handle_ring()
|
||||
static void bta_hf_client_handle_ring(void)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s", __FUNCTION__);
|
||||
bta_hf_client_evt_val(BTA_HF_CLIENT_RING_INDICATION, 0);
|
||||
|
@ -212,7 +212,7 @@ extern void bta_hf_client_sm_execute(UINT16 event,
|
||||
extern void bta_hf_client_slc_seq(BOOLEAN error);
|
||||
extern void bta_hf_client_collision_cback (tBTA_SYS_CONN_STATUS status, UINT8 id,
|
||||
UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_hf_client_resume_open ();
|
||||
extern void bta_hf_client_resume_open (void);
|
||||
|
||||
/* SDP functions */
|
||||
extern BOOLEAN bta_hf_client_add_record(char *p_service_name,
|
||||
|
@ -1205,7 +1205,7 @@ extern void BTA_GATTC_ConfigureMTU (UINT16 conn_id);
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTS_Init();
|
||||
extern void BTA_GATTS_Init(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -683,7 +683,7 @@ void bta_jv_disable (tBTA_JV_MSG *p_data)
|
||||
* list.
|
||||
* If no free PSMs exist, 0 will be returned.
|
||||
*/
|
||||
static UINT16 bta_jv_get_free_psm()
|
||||
static UINT16 bta_jv_get_free_psm(void)
|
||||
{
|
||||
const int cnt = sizeof(bta_jv_cb.free_psm_list) / sizeof(bta_jv_cb.free_psm_list[0]);
|
||||
for (int i = 0; i < cnt; i++) {
|
||||
|
@ -60,7 +60,7 @@ static void queue_int_add(connect_node_t *p_param)
|
||||
list_append(connect_queue, p_node);
|
||||
}
|
||||
|
||||
static void queue_int_advance()
|
||||
static void queue_int_advance(void)
|
||||
{
|
||||
if (connect_queue && !list_is_empty(connect_queue)) {
|
||||
list_remove(connect_queue, list_front(connect_queue));
|
||||
|
@ -424,7 +424,7 @@ static void btc_a2dp_source_data_post(void)
|
||||
osi_thread_post(a2dp_source_local_param.btc_aa_src_task_hdl, btc_a2dp_source_handle_timer, NULL, 2, OSI_THREAD_MAX_TIMEOUT);
|
||||
}
|
||||
|
||||
static UINT64 time_now_us()
|
||||
static UINT64 time_now_us(void)
|
||||
{
|
||||
#if _POSIX_TIMERS
|
||||
struct timespec ts_now;
|
||||
|
@ -79,7 +79,7 @@ void app_ble_sec_gen_ltk(UINT8 key_size)
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
void app_ble_sec_init()
|
||||
void app_ble_sec_init(void)
|
||||
{
|
||||
// Reset Security Environment
|
||||
memset(&app_sec_env, 0, sizeof(app_sec_env));
|
||||
|
@ -837,7 +837,7 @@ static ssize_t spp_vfs_read(int fd, void * dst, size_t size)
|
||||
return item_size;
|
||||
}
|
||||
|
||||
esp_err_t btc_spp_vfs_register()
|
||||
esp_err_t btc_spp_vfs_register(void)
|
||||
{
|
||||
esp_vfs_t vfs = {
|
||||
.flags = ESP_VFS_FLAG_DEFAULT,
|
||||
|
@ -544,7 +544,7 @@ static const controller_t interface = {
|
||||
#endif /* (BTM_SCO_HCI_INCLUDED == TRUE) */
|
||||
};
|
||||
|
||||
const controller_t *controller_get_interface()
|
||||
const controller_t *controller_get_interface(void)
|
||||
{
|
||||
static bool loaded = false;
|
||||
if (!loaded) {
|
||||
|
@ -86,6 +86,6 @@ typedef struct controller_t {
|
||||
#endif /* #if (BTM_SCO_HCI_INCLUDED == TRUE) */
|
||||
} controller_t;
|
||||
|
||||
const controller_t *controller_get_interface();
|
||||
const controller_t *controller_get_interface(void);
|
||||
|
||||
#endif /*_CONTROLLER_H_*/
|
||||
|
@ -121,7 +121,7 @@ static bool hal_open(const hci_hal_callbacks_t *upper_callbacks, void *task_thre
|
||||
return true;
|
||||
}
|
||||
|
||||
static void hal_close()
|
||||
static void hal_close(void)
|
||||
{
|
||||
hci_hal_env_deinit();
|
||||
|
||||
@ -367,7 +367,7 @@ static const hci_hal_t interface = {
|
||||
transmit_data,
|
||||
};
|
||||
|
||||
const hci_hal_t *hci_hal_h4_get_interface()
|
||||
const hci_hal_t *hci_hal_h4_get_interface(void)
|
||||
{
|
||||
return &interface;
|
||||
}
|
||||
|
@ -535,7 +535,7 @@ static waiting_command_t *get_waiting_command(command_opcode_t opcode)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void init_layer_interface()
|
||||
static void init_layer_interface(void)
|
||||
{
|
||||
if (!interface_created) {
|
||||
interface.transmit_command = transmit_command;
|
||||
@ -555,7 +555,7 @@ static const packet_fragmenter_callbacks_t packet_fragmenter_callbacks = {
|
||||
fragmenter_transmit_finished
|
||||
};
|
||||
|
||||
const hci_t *hci_layer_get_interface()
|
||||
const hci_t *hci_layer_get_interface(void)
|
||||
{
|
||||
hal = hci_hal_h4_get_interface();
|
||||
packet_fragmenter = packet_fragmenter_get_interface();
|
||||
|
@ -273,7 +273,7 @@ static const hci_packet_factory_t interface = {
|
||||
make_write_default_erroneous_data_report,
|
||||
};
|
||||
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface()
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface(void)
|
||||
{
|
||||
return &interface;
|
||||
}
|
||||
|
@ -250,7 +250,7 @@ static const hci_packet_parser_t interface = {
|
||||
parse_ble_read_suggested_default_data_length_response
|
||||
};
|
||||
|
||||
const hci_packet_parser_t *hci_packet_parser_get_interface()
|
||||
const hci_packet_parser_t *hci_packet_parser_get_interface(void)
|
||||
{
|
||||
return &interface;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ typedef struct hci_t {
|
||||
void (*transmit_downward)(uint16_t type, void *data);
|
||||
} hci_t;
|
||||
|
||||
const hci_t *hci_layer_get_interface();
|
||||
const hci_t *hci_layer_get_interface(void);
|
||||
|
||||
int hci_start_up(void);
|
||||
void hci_shut_down(void);
|
||||
|
@ -48,6 +48,6 @@ typedef struct {
|
||||
BT_HDR *(*make_write_default_erroneous_data_report)(uint8_t enable);
|
||||
} hci_packet_factory_t;
|
||||
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface();
|
||||
const hci_packet_factory_t *hci_packet_factory_get_interface(void);
|
||||
|
||||
#endif /*_HCI_PACKET_FACTORY_H_*/
|
||||
|
@ -97,6 +97,6 @@ typedef struct {
|
||||
);
|
||||
} hci_packet_parser_t;
|
||||
|
||||
const hci_packet_parser_t *hci_packet_parser_get_interface();
|
||||
const hci_packet_parser_t *hci_packet_parser_get_interface(void);
|
||||
|
||||
#endif /*_HCI_PACKET_PARSER_H_*/
|
||||
|
@ -57,6 +57,6 @@ typedef struct packet_fragmenter_t {
|
||||
void (*reassemble_and_dispatch)(BT_HDR *packet);
|
||||
} packet_fragmenter_t;
|
||||
|
||||
const packet_fragmenter_t *packet_fragmenter_get_interface();
|
||||
const packet_fragmenter_t *packet_fragmenter_get_interface(void);
|
||||
|
||||
#endif /* _PACKET_FRAGMENTER_H_ */
|
||||
|
@ -55,14 +55,14 @@ static void init(const packet_fragmenter_callbacks_t *result_callbacks)
|
||||
partial_packets = hash_map_new(NUMBER_OF_BUCKETS, hash_function_naive, NULL, NULL, NULL);
|
||||
}
|
||||
|
||||
static void cleanup()
|
||||
static void cleanup(void)
|
||||
{
|
||||
if (partial_packets) {
|
||||
hash_map_free(partial_packets);
|
||||
}
|
||||
}
|
||||
|
||||
static BT_HDR *fragment_get_current_packet()
|
||||
static BT_HDR *fragment_get_current_packet(void)
|
||||
{
|
||||
return current_fragment_packet;
|
||||
}
|
||||
@ -224,7 +224,7 @@ static const packet_fragmenter_t interface = {
|
||||
reassemble_and_dispatch
|
||||
};
|
||||
|
||||
const packet_fragmenter_t *packet_fragmenter_get_interface()
|
||||
const packet_fragmenter_t *packet_fragmenter_get_interface(void)
|
||||
{
|
||||
controller = controller_get_interface();
|
||||
return &interface;
|
||||
|
@ -195,7 +195,7 @@ void bte_main_enable_lpm(BOOLEAN enable)
|
||||
** Returns None
|
||||
**
|
||||
******************************************************************************/
|
||||
void bte_main_lpm_allow_bt_device_sleep()
|
||||
void bte_main_lpm_allow_bt_device_sleep(void)
|
||||
{
|
||||
/**/
|
||||
//hci->send_low_power_command(LPM_WAKE_DEASSERT);
|
||||
@ -210,7 +210,7 @@ void bte_main_lpm_allow_bt_device_sleep()
|
||||
** Returns None
|
||||
**
|
||||
******************************************************************************/
|
||||
void bte_main_lpm_wake_bt_device()
|
||||
void bte_main_lpm_wake_bt_device(void)
|
||||
{
|
||||
//hci->send_low_power_command(LPM_WAKE_ASSERT);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ void AVDT_Deregister(void)
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void AVDT_SINK_Activate()
|
||||
void AVDT_SINK_Activate(void)
|
||||
{
|
||||
tAVDT_SCB *p_scb = &avdt_cb.scb[0];
|
||||
int i;
|
||||
@ -200,7 +200,7 @@ void AVDT_SINK_Activate()
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void AVDT_SINK_Deactivate()
|
||||
void AVDT_SINK_Deactivate(void)
|
||||
{
|
||||
tAVDT_SCB *p_scb = &avdt_cb.scb[0];
|
||||
int i;
|
||||
|
@ -90,7 +90,7 @@ static UINT8 btm_ble_cs_update_pf_counter(tBTM_BLE_SCAN_COND_OP action,
|
||||
** Returns status
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTM_STATUS btm_ble_obtain_vsc_details()
|
||||
tBTM_STATUS btm_ble_obtain_vsc_details(void)
|
||||
{
|
||||
tBTM_STATUS st = BTM_SUCCESS;
|
||||
|
||||
|
@ -60,7 +60,7 @@ static bool bdaddr_equality_fn(const void *x, const void *y)
|
||||
return bdaddr_equals((bt_bdaddr_t *)x, (bt_bdaddr_t *)y);
|
||||
}
|
||||
|
||||
static void background_connections_lazy_init()
|
||||
static void background_connections_lazy_init(void)
|
||||
{
|
||||
if (!background_connections) {
|
||||
background_connections = hash_map_new(background_connection_buckets,
|
||||
@ -91,7 +91,7 @@ static BOOLEAN background_connection_remove(bt_bdaddr_t *address)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void background_connections_clear()
|
||||
static void background_connections_clear(void)
|
||||
{
|
||||
if (background_connections) {
|
||||
hash_map_clear(background_connections);
|
||||
@ -110,7 +110,7 @@ static bool background_connections_pending_cb(hash_map_entry_t *hash_entry, void
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool background_connections_pending()
|
||||
static bool background_connections_pending(void)
|
||||
{
|
||||
bool pending_connections = false;
|
||||
if (background_connections) {
|
||||
|
@ -2017,7 +2017,7 @@ UINT8 *BTM_CheckAdvData( UINT8 *p_adv, UINT8 type, UINT8 *p_length)
|
||||
** BTM_BLE_GENRAL_DISCOVERABLE
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 BTM_BleReadDiscoverability()
|
||||
UINT16 BTM_BleReadDiscoverability(void)
|
||||
{
|
||||
BTM_TRACE_API("%s\n", __FUNCTION__);
|
||||
|
||||
@ -2034,7 +2034,7 @@ UINT16 BTM_BleReadDiscoverability()
|
||||
** Returns BTM_BLE_NON_CONNECTABLE or BTM_BLE_CONNECTABLE
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 BTM_BleReadConnectability()
|
||||
UINT16 BTM_BleReadConnectability(void)
|
||||
{
|
||||
BTM_TRACE_API ("%s\n", __FUNCTION__);
|
||||
|
||||
|
@ -769,7 +769,7 @@ void btm_ble_multi_adv_vse_cback(UINT8 len, UINT8 *p)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void btm_ble_multi_adv_init()
|
||||
void btm_ble_multi_adv_init(void)
|
||||
{
|
||||
#if BTM_DYNAMIC_MEMORY == TRUE
|
||||
btm_multi_adv_cb_ptr = (tBTM_BLE_MULTI_ADV_CB *)osi_malloc(sizeof(tBTM_BLE_MULTI_ADV_CB));
|
||||
|
@ -1626,7 +1626,7 @@ BOOLEAN BTM_BleGetCurrentAddress(BD_ADDR addr, uint8_t *addr_type);
|
||||
** BTM_BLE_GENRAL_DISCOVERABLE
|
||||
**
|
||||
*******************************************************************************/
|
||||
UINT16 BTM_BleReadDiscoverability();
|
||||
UINT16 BTM_BleReadDiscoverability(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1639,7 +1639,7 @@ UINT16 BTM_BleReadDiscoverability();
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
UINT16 BTM_BleReadConnectability ();
|
||||
UINT16 BTM_BleReadConnectability (void);
|
||||
|
||||
void BTM_Recovery_Pre_State(void);
|
||||
|
||||
@ -1755,7 +1755,7 @@ void BTM_BleEnableMixedPrivacyMode(BOOLEAN mixed_on);
|
||||
**
|
||||
*******************************************************************************/
|
||||
//extern
|
||||
UINT8 BTM_BleMaxMultiAdvInstanceCount();
|
||||
UINT8 BTM_BleMaxMultiAdvInstanceCount(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
@ -8,7 +8,7 @@ set(srcs
|
||||
"libcoap/src/coap_hashkey.c"
|
||||
"libcoap/src/coap_session.c"
|
||||
"libcoap/src/coap_time.c"
|
||||
"libcoap/src/coap_debug.c"
|
||||
"port/coap_debug.c"
|
||||
"libcoap/src/encode.c"
|
||||
"libcoap/src/mem.c"
|
||||
"libcoap/src/net.c"
|
||||
@ -18,17 +18,15 @@ set(srcs
|
||||
"libcoap/src/str.c"
|
||||
"libcoap/src/subscribe.c"
|
||||
"libcoap/src/uri.c"
|
||||
"libcoap/src/coap_notls.c"
|
||||
"port/coap_io.c")
|
||||
|
||||
set(COMPONENT_REQUIRES lwip)
|
||||
"libcoap/src/coap_io.c"
|
||||
"port/coap_mbedtls.c")
|
||||
|
||||
idf_component_register(SRCS "${srcs}"
|
||||
INCLUDE_DIRS "${include_dirs}"
|
||||
REQUIRES lwip)
|
||||
REQUIRES lwip mbedtls)
|
||||
|
||||
# Silence format truncation warning, until it is fixed upstream
|
||||
set_source_files_properties(libcoap/src/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation)
|
||||
set_source_files_properties(port/coap_debug.c PROPERTIES COMPILE_FLAGS -Wno-format-truncation)
|
||||
|
||||
# Needed for coap headers in public builds, also.
|
||||
#
|
||||
|
74
components/coap/Kconfig
Normal file
74
components/coap/Kconfig
Normal file
@ -0,0 +1,74 @@
|
||||
menu "CoAP Configuration"
|
||||
|
||||
choice COAP_MBEDTLS_ENCRYPTION_MODE
|
||||
prompt "CoAP Encryption method"
|
||||
default COAP_MBEDTLS_PSK
|
||||
help
|
||||
If the CoAP information is to be encrypted, the encryption environment
|
||||
can be set up in one of two ways (default being Pre-Shared key mode)
|
||||
|
||||
- Encrypt using defined Pre-Shared Keys (PSK if uri includes coaps://)
|
||||
- Encrypt using defined Public Key Infrastructure (PKI if uri includes coaps://)
|
||||
|
||||
config COAP_MBEDTLS_PSK
|
||||
select MBEDTLS_SSL_PROTO_DTLS
|
||||
select MBEDTLS_PSK_MODES
|
||||
select MBEDTLS_KEY_EXCHANGE_PSK
|
||||
bool "Pre-Shared Keys"
|
||||
|
||||
config COAP_MBEDTLS_PKI
|
||||
select MBEDTLS_SSL_PROTO_DTLS
|
||||
select MBEDTLS_PSK_MODES
|
||||
select MBEDTLS_KEY_EXCHANGE_PSK
|
||||
bool "PKI Certificates"
|
||||
|
||||
endchoice #COAP_MBEDTLS_ENCRYPTION_MODE
|
||||
|
||||
config COAP_MBEDTLS_DEBUG
|
||||
bool "Enable CoAP debugging"
|
||||
default n
|
||||
help
|
||||
Enable CoAP debugging functions at compile time for the example code.
|
||||
|
||||
If this option is enabled, call coap_set_log_level()
|
||||
at runtime in order to enable CoAP debug output via the ESP
|
||||
log mechanism.
|
||||
|
||||
choice COAP_MBEDTLS_DEBUG_LEVEL
|
||||
bool "Set CoAP debugging level"
|
||||
depends on COAP_MBEDTLS_DEBUG
|
||||
default COAP_LOG_WARNING
|
||||
help
|
||||
Set CoAP debugging level
|
||||
|
||||
config COAP_LOG_EMERG
|
||||
bool "Emergency"
|
||||
config COAP_LOG_ALERT
|
||||
bool "Alert"
|
||||
config COAP_LOG_CRIT
|
||||
bool "Critical"
|
||||
config COAP_LOG_ERROR
|
||||
bool "Error"
|
||||
config COAP_LOG_WARNING
|
||||
bool "Warning"
|
||||
config COAP_LOG_NOTICE
|
||||
bool "Notice"
|
||||
config COAP_LOG_INFO
|
||||
bool "Info"
|
||||
config COAP_LOG_DEBUG
|
||||
bool "Debug"
|
||||
endchoice
|
||||
|
||||
config COAP_LOG_DEFAULT_LEVEL
|
||||
int
|
||||
default 0 if !COAP_MBEDTLS_DEBUG
|
||||
default 0 if COAP_LOG_EMERG
|
||||
default 1 if COAP_LOG_ALERT
|
||||
default 2 if COAP_LOG_CRIT
|
||||
default 3 if COAP_LOG_ERROR
|
||||
default 4 if COAP_LOG_WARNING
|
||||
default 5 if COAP_LOG_NOTICE
|
||||
default 6 if COAP_LOG_INFO
|
||||
default 7 if COAP_LOG_DEBUG
|
||||
|
||||
endmenu
|
@ -4,11 +4,11 @@
|
||||
|
||||
COMPONENT_ADD_INCLUDEDIRS := port/include port/include/coap libcoap/include libcoap/include/coap2
|
||||
|
||||
COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o libcoap/src/coap_event.o libcoap/src/coap_hashkey.o libcoap/src/coap_session.o libcoap/src/coap_time.o libcoap/src/coap_debug.o libcoap/src/encode.o libcoap/src/mem.o libcoap/src/net.o libcoap/src/option.o libcoap/src/pdu.o libcoap/src/resource.o libcoap/src/str.o libcoap/src/subscribe.o libcoap/src/uri.o libcoap/src/coap_notls.o port/coap_io.o
|
||||
COMPONENT_OBJS = libcoap/src/address.o libcoap/src/async.o libcoap/src/block.o libcoap/src/coap_event.o libcoap/src/coap_hashkey.o libcoap/src/coap_session.o libcoap/src/coap_time.o port/coap_debug.o libcoap/src/encode.o libcoap/src/mem.o libcoap/src/net.o libcoap/src/option.o libcoap/src/pdu.o libcoap/src/resource.o libcoap/src/str.o libcoap/src/subscribe.o libcoap/src/uri.o port/coap_mbedtls.o libcoap/src/coap_io.o
|
||||
|
||||
COMPONENT_SRCDIRS := libcoap/src libcoap port
|
||||
|
||||
COMPONENT_SUBMODULES += libcoap
|
||||
|
||||
# Silence format truncation warning, until it is fixed upstream
|
||||
libcoap/src/coap_debug.o: CFLAGS += -Wno-format-truncation
|
||||
port/coap_debug.o: CFLAGS += -Wno-format-truncation
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit cfec0d072c5b99ed3e54828ca50ea2f6b91e1f50
|
||||
Subproject commit 98954eb30a2e728e172a6cd29430ae5bc999b585
|
888
components/coap/port/coap_debug.c
Normal file
888
components/coap/port/coap_debug.c
Normal file
@ -0,0 +1,888 @@
|
||||
/* debug.c -- debug utilities
|
||||
*
|
||||
* Copyright (C) 2010--2012,2014--2019 Olaf Bergmann <bergmann@tzi.org> and others
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see
|
||||
* README for terms of use.
|
||||
*/
|
||||
|
||||
#include "coap_config.h"
|
||||
|
||||
#if defined(HAVE_STRNLEN) && defined(__GNUC__) && !defined(_GNU_SOURCE)
|
||||
#define _GNU_SOURCE 1
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_ASSERT_H) && !defined(assert)
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#ifdef HAVE_ARPA_INET_H
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
#ifdef HAVE_WS2TCPIP_H
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
||||
#include "libcoap.h"
|
||||
#include "coap_dtls.h"
|
||||
#include "block.h"
|
||||
#include "coap_debug.h"
|
||||
#include "encode.h"
|
||||
#include "net.h"
|
||||
#include "coap_mutex.h"
|
||||
|
||||
#ifdef WITH_LWIP
|
||||
# define fprintf(fd, ...) LWIP_PLATFORM_DIAG((__VA_ARGS__))
|
||||
# define fflush(...)
|
||||
#endif
|
||||
|
||||
#ifdef WITH_CONTIKI
|
||||
# ifndef DEBUG
|
||||
# define DEBUG DEBUG_PRINT
|
||||
# endif /* DEBUG */
|
||||
#include "net/ip/uip-debug.h"
|
||||
#endif
|
||||
|
||||
static coap_log_t maxlog = LOG_WARNING; /* default maximum log level */
|
||||
|
||||
static int use_fprintf_for_show_pdu = 1; /* non zero to output with fprintf */
|
||||
|
||||
const char *coap_package_name(void) {
|
||||
return PACKAGE_NAME;
|
||||
}
|
||||
|
||||
const char *coap_package_version(void) {
|
||||
return PACKAGE_STRING;
|
||||
}
|
||||
|
||||
void
|
||||
coap_set_show_pdu_output(int use_fprintf) {
|
||||
use_fprintf_for_show_pdu = use_fprintf;
|
||||
}
|
||||
|
||||
coap_log_t
|
||||
coap_get_log_level(void) {
|
||||
return maxlog;
|
||||
}
|
||||
|
||||
void
|
||||
coap_set_log_level(coap_log_t level) {
|
||||
maxlog = level;
|
||||
}
|
||||
|
||||
/* this array has the same order as the type log_t */
|
||||
static const char *loglevels[] = {
|
||||
"EMRG", "ALRT", "CRIT", "ERR ", "WARN", "NOTE", "INFO", "DEBG"
|
||||
};
|
||||
|
||||
#ifdef HAVE_TIME_H
|
||||
|
||||
COAP_STATIC_INLINE size_t
|
||||
print_timestamp(char *s, size_t len, coap_tick_t t) {
|
||||
struct tm *tmp;
|
||||
time_t now = coap_ticks_to_rt(t);
|
||||
tmp = localtime(&now);
|
||||
return strftime(s, len, "%b %d %H:%M:%S", tmp);
|
||||
}
|
||||
|
||||
#else /* alternative implementation: just print the timestamp */
|
||||
|
||||
COAP_STATIC_INLINE size_t
|
||||
print_timestamp(char *s, size_t len, coap_tick_t t) {
|
||||
#ifdef HAVE_SNPRINTF
|
||||
return snprintf(s, len, "%u.%03u",
|
||||
(unsigned int)coap_ticks_to_rt(t),
|
||||
(unsigned int)(t % COAP_TICKS_PER_SECOND));
|
||||
#else /* HAVE_SNPRINTF */
|
||||
/* @todo do manual conversion of timestamp */
|
||||
return 0;
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
}
|
||||
|
||||
#endif /* HAVE_TIME_H */
|
||||
|
||||
#ifndef HAVE_STRNLEN
|
||||
/**
|
||||
* A length-safe strlen() fake.
|
||||
*
|
||||
* @param s The string to count characters != 0.
|
||||
* @param maxlen The maximum length of @p s.
|
||||
*
|
||||
* @return The length of @p s.
|
||||
*/
|
||||
static inline size_t
|
||||
strnlen(const char *s, size_t maxlen) {
|
||||
size_t n = 0;
|
||||
while(*s++ && n < maxlen)
|
||||
++n;
|
||||
return n;
|
||||
}
|
||||
#endif /* HAVE_STRNLEN */
|
||||
|
||||
static size_t
|
||||
print_readable( const uint8_t *data, size_t len,
|
||||
unsigned char *result, size_t buflen, int encode_always ) {
|
||||
const uint8_t hex[] = "0123456789ABCDEF";
|
||||
size_t cnt = 0;
|
||||
assert(data || len == 0);
|
||||
|
||||
if (buflen == 0) { /* there is nothing we can do here but return */
|
||||
return 0;
|
||||
}
|
||||
|
||||
while (len) {
|
||||
if (!encode_always && isprint(*data)) {
|
||||
if (cnt+1 < buflen) { /* keep one byte for terminating zero */
|
||||
*result++ = *data;
|
||||
++cnt;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (cnt+4 < buflen) { /* keep one byte for terminating zero */
|
||||
*result++ = '\\';
|
||||
*result++ = 'x';
|
||||
*result++ = hex[(*data & 0xf0) >> 4];
|
||||
*result++ = hex[*data & 0x0f];
|
||||
cnt += 4;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
|
||||
++data; --len;
|
||||
}
|
||||
|
||||
*result = '\0'; /* add a terminating zero */
|
||||
return cnt;
|
||||
}
|
||||
|
||||
#ifndef min
|
||||
#define min(a,b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
size_t
|
||||
coap_print_addr(const struct coap_address_t *addr, unsigned char *buf, size_t len) {
|
||||
#if defined( HAVE_ARPA_INET_H ) || defined( HAVE_WS2TCPIP_H )
|
||||
const void *addrptr = NULL;
|
||||
in_port_t port;
|
||||
unsigned char *p = buf;
|
||||
size_t need_buf;
|
||||
|
||||
switch (addr->addr.sa.sa_family) {
|
||||
case AF_INET:
|
||||
addrptr = &addr->addr.sin.sin_addr;
|
||||
port = ntohs(addr->addr.sin.sin_port);
|
||||
need_buf = INET_ADDRSTRLEN;
|
||||
break;
|
||||
case AF_INET6:
|
||||
if (len < 7) /* do not proceed if buffer is even too short for [::]:0 */
|
||||
return 0;
|
||||
|
||||
*p++ = '[';
|
||||
|
||||
addrptr = &addr->addr.sin6.sin6_addr;
|
||||
port = ntohs(addr->addr.sin6.sin6_port);
|
||||
need_buf = INET6_ADDRSTRLEN;
|
||||
|
||||
break;
|
||||
default:
|
||||
memcpy(buf, "(unknown address type)", min(22, len));
|
||||
return min(22, len);
|
||||
}
|
||||
|
||||
/* Cast needed for Windows, since it doesn't have the correct API signature. */
|
||||
if (inet_ntop(addr->addr.sa.sa_family, addrptr, (char *)p,
|
||||
min(len, need_buf)) == 0) {
|
||||
perror("coap_print_addr");
|
||||
return 0;
|
||||
}
|
||||
|
||||
p += strnlen((char *)p, len);
|
||||
|
||||
if (addr->addr.sa.sa_family == AF_INET6) {
|
||||
if (p < buf + len) {
|
||||
*p++ = ']';
|
||||
} else
|
||||
return 0;
|
||||
}
|
||||
|
||||
p += snprintf((char *)p, buf + len - p + 1, ":%d", port);
|
||||
|
||||
return buf + len - p;
|
||||
#else /* HAVE_ARPA_INET_H */
|
||||
# if WITH_CONTIKI
|
||||
unsigned char *p = buf;
|
||||
uint8_t i;
|
||||
# if NETSTACK_CONF_WITH_IPV6
|
||||
const uint8_t hex[] = "0123456789ABCDEF";
|
||||
|
||||
if (len < 41)
|
||||
return 0;
|
||||
|
||||
*p++ = '[';
|
||||
|
||||
for (i=0; i < 16; i += 2) {
|
||||
if (i) {
|
||||
*p++ = ':';
|
||||
}
|
||||
*p++ = hex[(addr->addr.u8[i] & 0xf0) >> 4];
|
||||
*p++ = hex[(addr->addr.u8[i] & 0x0f)];
|
||||
*p++ = hex[(addr->addr.u8[i+1] & 0xf0) >> 4];
|
||||
*p++ = hex[(addr->addr.u8[i+1] & 0x0f)];
|
||||
}
|
||||
*p++ = ']';
|
||||
# else /* WITH_UIP6 */
|
||||
# warning "IPv4 network addresses will not be included in debug output"
|
||||
|
||||
if (len < 21)
|
||||
return 0;
|
||||
# endif /* WITH_UIP6 */
|
||||
if (buf + len - p < 6)
|
||||
return 0;
|
||||
|
||||
#ifdef HAVE_SNPRINTF
|
||||
p += snprintf((char *)p, buf + len - p + 1, ":%d", uip_htons(addr->port));
|
||||
#else /* HAVE_SNPRINTF */
|
||||
/* @todo manual conversion of port number */
|
||||
#endif /* HAVE_SNPRINTF */
|
||||
|
||||
return p - buf;
|
||||
# else /* WITH_CONTIKI */
|
||||
/* TODO: output addresses manually */
|
||||
# warning "inet_ntop() not available, network addresses will not be included in debug output"
|
||||
# endif /* WITH_CONTIKI */
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef WITH_CONTIKI
|
||||
# define fprintf(fd, ...) PRINTF(__VA_ARGS__)
|
||||
# define fflush(...)
|
||||
|
||||
# ifdef HAVE_VPRINTF
|
||||
# define vfprintf(fd, ...) vprintf(__VA_ARGS__)
|
||||
# else /* HAVE_VPRINTF */
|
||||
# define vfprintf(fd, ...) PRINTF(__VA_ARGS__)
|
||||
# endif /* HAVE_VPRINTF */
|
||||
#endif /* WITH_CONTIKI */
|
||||
|
||||
/** Returns a textual description of the message type @p t. */
|
||||
static const char *
|
||||
msg_type_string(uint16_t t) {
|
||||
static const char *types[] = { "CON", "NON", "ACK", "RST", "???" };
|
||||
|
||||
return types[min(t, sizeof(types)/sizeof(char *) - 1)];
|
||||
}
|
||||
|
||||
/** Returns a textual description of the method or response code. */
|
||||
static const char *
|
||||
msg_code_string(uint16_t c) {
|
||||
static const char *methods[] = { "0.00", "GET", "POST", "PUT", "DELETE",
|
||||
"FETCH", "PATCH", "iPATCH" };
|
||||
static const char *signals[] = { "7.00", "CSM", "Ping", "Pong", "Release",
|
||||
"Abort" };
|
||||
static char buf[5];
|
||||
|
||||
if (c < sizeof(methods)/sizeof(const char *)) {
|
||||
return methods[c];
|
||||
} else if (c >= 224 && c - 224 < (int)(sizeof(signals)/sizeof(const char *))) {
|
||||
return signals[c-224];
|
||||
} else {
|
||||
snprintf(buf, sizeof(buf), "%u.%02u", (c >> 5) & 0x7, c & 0x1f);
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
|
||||
/** Returns a textual description of the option name. */
|
||||
static const char *
|
||||
msg_option_string(uint8_t code, uint16_t option_type) {
|
||||
struct option_desc_t {
|
||||
uint16_t type;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static struct option_desc_t options[] = {
|
||||
{ COAP_OPTION_IF_MATCH, "If-Match" },
|
||||
{ COAP_OPTION_URI_HOST, "Uri-Host" },
|
||||
{ COAP_OPTION_ETAG, "ETag" },
|
||||
{ COAP_OPTION_IF_NONE_MATCH, "If-None-Match" },
|
||||
{ COAP_OPTION_OBSERVE, "Observe" },
|
||||
{ COAP_OPTION_URI_PORT, "Uri-Port" },
|
||||
{ COAP_OPTION_LOCATION_PATH, "Location-Path" },
|
||||
{ COAP_OPTION_URI_PATH, "Uri-Path" },
|
||||
{ COAP_OPTION_CONTENT_FORMAT, "Content-Format" },
|
||||
{ COAP_OPTION_MAXAGE, "Max-Age" },
|
||||
{ COAP_OPTION_URI_QUERY, "Uri-Query" },
|
||||
{ COAP_OPTION_ACCEPT, "Accept" },
|
||||
{ COAP_OPTION_LOCATION_QUERY, "Location-Query" },
|
||||
{ COAP_OPTION_BLOCK2, "Block2" },
|
||||
{ COAP_OPTION_BLOCK1, "Block1" },
|
||||
{ COAP_OPTION_PROXY_URI, "Proxy-Uri" },
|
||||
{ COAP_OPTION_PROXY_SCHEME, "Proxy-Scheme" },
|
||||
{ COAP_OPTION_SIZE1, "Size1" },
|
||||
{ COAP_OPTION_SIZE2, "Size2" },
|
||||
{ COAP_OPTION_NORESPONSE, "No-Response" }
|
||||
};
|
||||
|
||||
static struct option_desc_t options_csm[] = {
|
||||
{ COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE, "Max-Message-Size" },
|
||||
{ COAP_SIGNALING_OPTION_BLOCK_WISE_TRANSFER, "Block-wise-Transfer" }
|
||||
};
|
||||
|
||||
static struct option_desc_t options_pingpong[] = {
|
||||
{ COAP_SIGNALING_OPTION_CUSTODY, "Custody" }
|
||||
};
|
||||
|
||||
static struct option_desc_t options_release[] = {
|
||||
{ COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS, "Alternative-Address" },
|
||||
{ COAP_SIGNALING_OPTION_HOLD_OFF, "Hold-Off" }
|
||||
};
|
||||
|
||||
static struct option_desc_t options_abort[] = {
|
||||
{ COAP_SIGNALING_OPTION_BAD_CSM_OPTION, "Bad-CSM-Option" }
|
||||
};
|
||||
|
||||
static char buf[6];
|
||||
size_t i;
|
||||
|
||||
if (code == COAP_SIGNALING_CSM) {
|
||||
for (i = 0; i < sizeof(options_csm)/sizeof(struct option_desc_t); i++) {
|
||||
if (option_type == options_csm[i].type) {
|
||||
return options_csm[i].name;
|
||||
}
|
||||
}
|
||||
} else if (code == COAP_SIGNALING_PING || code == COAP_SIGNALING_PONG) {
|
||||
for (i = 0; i < sizeof(options_pingpong)/sizeof(struct option_desc_t); i++) {
|
||||
if (option_type == options_pingpong[i].type) {
|
||||
return options_pingpong[i].name;
|
||||
}
|
||||
}
|
||||
} else if (code == COAP_SIGNALING_RELEASE) {
|
||||
for (i = 0; i < sizeof(options_release)/sizeof(struct option_desc_t); i++) {
|
||||
if (option_type == options_release[i].type) {
|
||||
return options_release[i].name;
|
||||
}
|
||||
}
|
||||
} else if (code == COAP_SIGNALING_ABORT) {
|
||||
for (i = 0; i < sizeof(options_abort)/sizeof(struct option_desc_t); i++) {
|
||||
if (option_type == options_abort[i].type) {
|
||||
return options_abort[i].name;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* search option_type in list of known options */
|
||||
for (i = 0; i < sizeof(options)/sizeof(struct option_desc_t); i++) {
|
||||
if (option_type == options[i].type) {
|
||||
return options[i].name;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* unknown option type, just print to buf */
|
||||
snprintf(buf, sizeof(buf), "%u", option_type);
|
||||
return buf;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
print_content_format(unsigned int format_type,
|
||||
unsigned char *result, unsigned int buflen) {
|
||||
struct desc_t {
|
||||
unsigned int type;
|
||||
const char *name;
|
||||
};
|
||||
|
||||
static struct desc_t formats[] = {
|
||||
{ COAP_MEDIATYPE_TEXT_PLAIN, "text/plain" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_LINK_FORMAT, "application/link-format" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_XML, "application/xml" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_OCTET_STREAM, "application/octet-stream" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_EXI, "application/exi" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_JSON, "application/json" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_CBOR, "application/cbor" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_SIGN, "application/cose; cose-type=\"cose-sign\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_SIGN1, "application/cose; cose-type=\"cose-sign1\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT, "application/cose; cose-type=\"cose-encrypt\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_ENCRYPT0, "application/cose; cose-type=\"cose-encrypt0\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_MAC, "application/cose; cose-type=\"cose-mac\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_MAC0, "application/cose; cose-type=\"cose-mac0\"" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_KEY, "application/cose-key" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_COSE_KEY_SET, "application/cose-key-set" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENML_JSON, "application/senml+json" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENSML_JSON, "application/sensml+json" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENML_CBOR, "application/senml+cbor" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENSML_CBOR, "application/sensml+cbor" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENML_EXI, "application/senml-exi" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENSML_EXI, "application/sensml-exi" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENML_XML, "application/senml+xml" },
|
||||
{ COAP_MEDIATYPE_APPLICATION_SENSML_XML, "application/sensml+xml" },
|
||||
{ 75, "application/dcaf+cbor" }
|
||||
};
|
||||
|
||||
size_t i;
|
||||
|
||||
/* search format_type in list of known content formats */
|
||||
for (i = 0; i < sizeof(formats)/sizeof(struct desc_t); i++) {
|
||||
if (format_type == formats[i].type) {
|
||||
return snprintf((char *)result, buflen, "%s", formats[i].name);
|
||||
}
|
||||
}
|
||||
|
||||
/* unknown content format, just print numeric value to buf */
|
||||
return snprintf((char *)result, buflen, "%d", format_type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 1 if the given @p content_format is either unknown or known
|
||||
* to carry binary data. The return value @c 0 hence indicates
|
||||
* printable data which is also assumed if @p content_format is @c 01.
|
||||
*/
|
||||
COAP_STATIC_INLINE int
|
||||
is_binary(int content_format) {
|
||||
return !(content_format == -1 ||
|
||||
content_format == COAP_MEDIATYPE_TEXT_PLAIN ||
|
||||
content_format == COAP_MEDIATYPE_APPLICATION_LINK_FORMAT ||
|
||||
content_format == COAP_MEDIATYPE_APPLICATION_XML ||
|
||||
content_format == COAP_MEDIATYPE_APPLICATION_JSON);
|
||||
}
|
||||
|
||||
#define COAP_DO_SHOW_OUTPUT_LINE \
|
||||
do { \
|
||||
if (use_fprintf_for_show_pdu) { \
|
||||
fprintf(COAP_DEBUG_FD, "%s", outbuf); \
|
||||
} \
|
||||
else { \
|
||||
coap_log(level, "%s", outbuf); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void
|
||||
coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu) {
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
static coap_mutex_t static_show_pdu_mutex = COAP_MUTEX_INITIALIZER;
|
||||
static unsigned char buf[1024]; /* need some space for output creation */
|
||||
static char outbuf[COAP_DEBUG_BUF_SIZE];
|
||||
#else /* ! COAP_CONSTRAINED_STACK */
|
||||
unsigned char buf[1024]; /* need some space for output creation */
|
||||
char outbuf[COAP_DEBUG_BUF_SIZE];
|
||||
#endif /* ! COAP_CONSTRAINED_STACK */
|
||||
size_t buf_len = 0; /* takes the number of bytes written to buf */
|
||||
int encode = 0, have_options = 0, i;
|
||||
coap_opt_iterator_t opt_iter;
|
||||
coap_opt_t *option;
|
||||
int content_format = -1;
|
||||
size_t data_len;
|
||||
unsigned char *data;
|
||||
int outbuflen = 0;
|
||||
|
||||
/* Save time if not needed */
|
||||
if (level > coap_get_log_level())
|
||||
return;
|
||||
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
coap_mutex_lock(&static_show_pdu_mutex);
|
||||
#endif /* COAP_CONSTRAINED_STACK */
|
||||
|
||||
snprintf(outbuf, sizeof(outbuf), "v:%d t:%s c:%s i:%04x {",
|
||||
COAP_DEFAULT_VERSION, msg_type_string(pdu->type),
|
||||
msg_code_string(pdu->code), pdu->tid);
|
||||
|
||||
for (i = 0; i < pdu->token_length; i++) {
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen,
|
||||
"%02x", pdu->token[i]);
|
||||
}
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "}");
|
||||
|
||||
/* show options, if any */
|
||||
coap_option_iterator_init(pdu, &opt_iter, COAP_OPT_ALL);
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " [");
|
||||
while ((option = coap_option_next(&opt_iter))) {
|
||||
if (!have_options) {
|
||||
have_options = 1;
|
||||
} else {
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ",");
|
||||
}
|
||||
|
||||
if (pdu->code == COAP_SIGNALING_CSM) switch(opt_iter.type) {
|
||||
case COAP_SIGNALING_OPTION_MAX_MESSAGE_SIZE:
|
||||
buf_len = snprintf((char *)buf, sizeof(buf), "%u",
|
||||
coap_decode_var_bytes(coap_opt_value(option),
|
||||
coap_opt_length(option)));
|
||||
break;
|
||||
default:
|
||||
buf_len = 0;
|
||||
break;
|
||||
} else if (pdu->code == COAP_SIGNALING_PING
|
||||
|| pdu->code == COAP_SIGNALING_PONG) {
|
||||
buf_len = 0;
|
||||
} else if (pdu->code == COAP_SIGNALING_RELEASE) switch(opt_iter.type) {
|
||||
case COAP_SIGNALING_OPTION_ALTERNATIVE_ADDRESS:
|
||||
buf_len = print_readable(coap_opt_value(option),
|
||||
coap_opt_length(option),
|
||||
buf, sizeof(buf), 0);
|
||||
break;
|
||||
case COAP_SIGNALING_OPTION_HOLD_OFF:
|
||||
buf_len = snprintf((char *)buf, sizeof(buf), "%u",
|
||||
coap_decode_var_bytes(coap_opt_value(option),
|
||||
coap_opt_length(option)));
|
||||
break;
|
||||
default:
|
||||
buf_len = 0;
|
||||
break;
|
||||
} else if (pdu->code == COAP_SIGNALING_ABORT) switch(opt_iter.type) {
|
||||
case COAP_SIGNALING_OPTION_BAD_CSM_OPTION:
|
||||
buf_len = snprintf((char *)buf, sizeof(buf), "%u",
|
||||
coap_decode_var_bytes(coap_opt_value(option),
|
||||
coap_opt_length(option)));
|
||||
break;
|
||||
default:
|
||||
buf_len = 0;
|
||||
break;
|
||||
} else switch (opt_iter.type) {
|
||||
case COAP_OPTION_CONTENT_FORMAT:
|
||||
content_format = (int)coap_decode_var_bytes(coap_opt_value(option),
|
||||
coap_opt_length(option));
|
||||
|
||||
buf_len = print_content_format(content_format, buf, sizeof(buf));
|
||||
break;
|
||||
|
||||
case COAP_OPTION_BLOCK1:
|
||||
case COAP_OPTION_BLOCK2:
|
||||
/* split block option into number/more/size where more is the
|
||||
* letter M if set, the _ otherwise */
|
||||
buf_len = snprintf((char *)buf, sizeof(buf), "%u/%c/%u",
|
||||
coap_opt_block_num(option), /* block number */
|
||||
COAP_OPT_BLOCK_MORE(option) ? 'M' : '_', /* M bit */
|
||||
(1 << (COAP_OPT_BLOCK_SZX(option) + 4))); /* block size */
|
||||
|
||||
break;
|
||||
|
||||
case COAP_OPTION_URI_PORT:
|
||||
case COAP_OPTION_MAXAGE:
|
||||
case COAP_OPTION_OBSERVE:
|
||||
case COAP_OPTION_SIZE1:
|
||||
case COAP_OPTION_SIZE2:
|
||||
/* show values as unsigned decimal value */
|
||||
buf_len = snprintf((char *)buf, sizeof(buf), "%u",
|
||||
coap_decode_var_bytes(coap_opt_value(option),
|
||||
coap_opt_length(option)));
|
||||
break;
|
||||
|
||||
default:
|
||||
/* generic output function for all other option types */
|
||||
if (opt_iter.type == COAP_OPTION_URI_PATH ||
|
||||
opt_iter.type == COAP_OPTION_PROXY_URI ||
|
||||
opt_iter.type == COAP_OPTION_URI_HOST ||
|
||||
opt_iter.type == COAP_OPTION_LOCATION_PATH ||
|
||||
opt_iter.type == COAP_OPTION_LOCATION_QUERY ||
|
||||
opt_iter.type == COAP_OPTION_URI_QUERY) {
|
||||
encode = 0;
|
||||
} else {
|
||||
encode = 1;
|
||||
}
|
||||
|
||||
buf_len = print_readable(coap_opt_value(option),
|
||||
coap_opt_length(option),
|
||||
buf, sizeof(buf), encode);
|
||||
}
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen,
|
||||
" %s:%.*s", msg_option_string(pdu->code, opt_iter.type),
|
||||
(int)buf_len, buf);
|
||||
}
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " ]");
|
||||
|
||||
if (coap_get_data(pdu, &data_len, &data)) {
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, " :: ");
|
||||
|
||||
if (is_binary(content_format)) {
|
||||
int keep_data_len = data_len;
|
||||
uint8_t *keep_data = data;
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen,
|
||||
"binary data length %zu\n", data_len);
|
||||
COAP_DO_SHOW_OUTPUT_LINE;
|
||||
/*
|
||||
* Output hex dump of binary data as a continuous entry
|
||||
*/
|
||||
outbuf[0] = '\000';
|
||||
snprintf(outbuf, sizeof(outbuf), "<<");
|
||||
while (data_len--) {
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen,
|
||||
"%02x", *data++);
|
||||
}
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ">>");
|
||||
data_len = keep_data_len;
|
||||
data = keep_data;
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "\n");
|
||||
COAP_DO_SHOW_OUTPUT_LINE;
|
||||
/*
|
||||
* Output ascii readable (if possible), immediately under the
|
||||
* hex value of the character output above to help binary debugging
|
||||
*/
|
||||
outbuf[0] = '\000';
|
||||
snprintf(outbuf, sizeof(outbuf), "<<");
|
||||
while (data_len--) {
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen,
|
||||
"%c ", isprint (*data) ? *data : '.');
|
||||
data++;
|
||||
}
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, ">>");
|
||||
} else {
|
||||
if (print_readable(data, data_len, buf, sizeof(buf), 0)) {
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "'%s'", buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
outbuflen = strlen(outbuf);
|
||||
snprintf(&outbuf[outbuflen], sizeof(outbuf)-outbuflen, "\n");
|
||||
COAP_DO_SHOW_OUTPUT_LINE;
|
||||
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
coap_mutex_unlock(&static_show_pdu_mutex);
|
||||
#endif /* COAP_CONSTRAINED_STACK */
|
||||
}
|
||||
|
||||
void coap_show_tls_version(coap_log_t level)
|
||||
{
|
||||
char buffer[64];
|
||||
coap_string_tls_version(buffer, sizeof(buffer));
|
||||
coap_log(level, "%s\n", buffer);
|
||||
}
|
||||
|
||||
char *coap_string_tls_version(char *buffer, size_t bufsize)
|
||||
{
|
||||
coap_tls_version_t *tls_version = coap_get_tls_library_version();
|
||||
char beta[8];
|
||||
char sub[2];
|
||||
char b_beta[8];
|
||||
char b_sub[2];
|
||||
|
||||
switch (tls_version->type) {
|
||||
case COAP_TLS_LIBRARY_NOTLS:
|
||||
snprintf(buffer, bufsize, "TLS Library: None");
|
||||
break;
|
||||
case COAP_TLS_LIBRARY_TINYDTLS:
|
||||
snprintf(buffer, bufsize, "TLS Library: TinyDTLS - runtime %lu.%lu.%lu, "
|
||||
"libcoap built for %lu.%lu.%lu",
|
||||
(unsigned long)(tls_version->version >> 16),
|
||||
(unsigned long)((tls_version->version >> 8) & 0xff),
|
||||
(unsigned long)(tls_version->version & 0xff),
|
||||
(unsigned long)(tls_version->built_version >> 16),
|
||||
(unsigned long)((tls_version->built_version >> 8) & 0xff),
|
||||
(unsigned long)(tls_version->built_version & 0xff));
|
||||
break;
|
||||
case COAP_TLS_LIBRARY_OPENSSL:
|
||||
switch (tls_version->version &0xf) {
|
||||
case 0:
|
||||
strcpy(beta, "-dev");
|
||||
break;
|
||||
case 0xf:
|
||||
strcpy(beta, "");
|
||||
break;
|
||||
default:
|
||||
strcpy(beta, "-beta");
|
||||
beta[5] = (tls_version->version &0xf) + '0';
|
||||
beta[6] = '\000';
|
||||
break;
|
||||
}
|
||||
sub[0] = ((tls_version->version >> 4) & 0xff) ?
|
||||
((tls_version->version >> 4) & 0xff) + 'a' -1 : '\000';
|
||||
sub[1] = '\000';
|
||||
switch (tls_version->built_version &0xf) {
|
||||
case 0:
|
||||
strcpy(b_beta, "-dev");
|
||||
break;
|
||||
case 0xf:
|
||||
strcpy(b_beta, "");
|
||||
break;
|
||||
default:
|
||||
strcpy(b_beta, "-beta");
|
||||
b_beta[5] = (tls_version->built_version &0xf) + '0';
|
||||
b_beta[6] = '\000';
|
||||
break;
|
||||
}
|
||||
b_sub[0] = ((tls_version->built_version >> 4) & 0xff) ?
|
||||
((tls_version->built_version >> 4) & 0xff) + 'a' -1 : '\000';
|
||||
b_sub[1] = '\000';
|
||||
snprintf(buffer, bufsize, "TLS Library: OpenSSL - runtime "
|
||||
"%lu.%lu.%lu%s%s, libcoap built for %lu.%lu.%lu%s%s",
|
||||
(unsigned long)(tls_version->version >> 28),
|
||||
(unsigned long)((tls_version->version >> 20) & 0xff),
|
||||
(unsigned long)((tls_version->version >> 12) & 0xff), sub, beta,
|
||||
(unsigned long)(tls_version->built_version >> 28),
|
||||
(unsigned long)((tls_version->built_version >> 20) & 0xff),
|
||||
(unsigned long)((tls_version->built_version >> 12) & 0xff),
|
||||
b_sub, b_beta);
|
||||
break;
|
||||
case COAP_TLS_LIBRARY_GNUTLS:
|
||||
snprintf(buffer, bufsize, "TLS Library: GnuTLS - runtime %lu.%lu.%lu, "
|
||||
"libcoap built for %lu.%lu.%lu",
|
||||
(unsigned long)(tls_version->version >> 16),
|
||||
(unsigned long)((tls_version->version >> 8) & 0xff),
|
||||
(unsigned long)(tls_version->version & 0xff),
|
||||
(unsigned long)(tls_version->built_version >> 16),
|
||||
(unsigned long)((tls_version->built_version >> 8) & 0xff),
|
||||
(unsigned long)(tls_version->built_version & 0xff));
|
||||
break;
|
||||
case COAP_TLS_LIBRARY_MBEDTLS:
|
||||
snprintf(buffer, bufsize, "TLS Library: MbedTLS - runtime %lu.%lu.%lu, "
|
||||
"libcoap built for %lu.%lu.%lu",
|
||||
(unsigned long)(tls_version->version >> 24),
|
||||
(unsigned long)((tls_version->version >> 16) & 0xff),
|
||||
(unsigned long)((tls_version->version >> 8) & 0xff),
|
||||
(unsigned long)(tls_version->built_version >> 24),
|
||||
(unsigned long)((tls_version->built_version >> 16) & 0xff),
|
||||
(unsigned long)((tls_version->built_version >> 8) & 0xff));
|
||||
break;
|
||||
default:
|
||||
snprintf(buffer, bufsize, "Library type %d unknown", tls_version->type);
|
||||
break;
|
||||
}
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static coap_log_handler_t log_handler = NULL;
|
||||
|
||||
void coap_set_log_handler(coap_log_handler_t handler) {
|
||||
log_handler = handler;
|
||||
}
|
||||
|
||||
void
|
||||
coap_log_impl(coap_log_t level, const char *format, ...) {
|
||||
|
||||
if (maxlog < level)
|
||||
return;
|
||||
|
||||
if (log_handler) {
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
static coap_mutex_t static_log_mutex = COAP_MUTEX_INITIALIZER;
|
||||
static char message[COAP_DEBUG_BUF_SIZE];
|
||||
#else /* ! COAP_CONSTRAINED_STACK */
|
||||
char message[COAP_DEBUG_BUF_SIZE];
|
||||
#endif /* ! COAP_CONSTRAINED_STACK */
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
coap_mutex_lock(&static_log_mutex);
|
||||
#endif /* COAP_CONSTRAINED_STACK */
|
||||
|
||||
vsnprintf( message, sizeof(message), format, ap);
|
||||
va_end(ap);
|
||||
log_handler(level, message);
|
||||
#if COAP_CONSTRAINED_STACK
|
||||
coap_mutex_unlock(&static_log_mutex);
|
||||
#endif /* COAP_CONSTRAINED_STACK */
|
||||
} else {
|
||||
char timebuf[32];
|
||||
coap_tick_t now;
|
||||
va_list ap;
|
||||
FILE *log_fd;
|
||||
|
||||
log_fd = level <= LOG_CRIT ? COAP_ERR_FD : COAP_DEBUG_FD;
|
||||
|
||||
coap_ticks(&now);
|
||||
if (print_timestamp(timebuf,sizeof(timebuf), now))
|
||||
fprintf(log_fd, "%s ", timebuf);
|
||||
|
||||
if (level <= LOG_DEBUG)
|
||||
fprintf(log_fd, "%s ", loglevels[level]);
|
||||
|
||||
va_start(ap, format);
|
||||
vfprintf(log_fd, format, ap);
|
||||
va_end(ap);
|
||||
fflush(log_fd);
|
||||
}
|
||||
}
|
||||
|
||||
static struct packet_num_interval {
|
||||
int start;
|
||||
int end;
|
||||
} packet_loss_intervals[10];
|
||||
static int num_packet_loss_intervals = 0;
|
||||
static int packet_loss_level = 0;
|
||||
static int send_packet_count = 0;
|
||||
|
||||
int coap_debug_set_packet_loss(const char *loss_level) {
|
||||
const char *p = loss_level;
|
||||
char *end = NULL;
|
||||
int n = (int)strtol(p, &end, 10), i = 0;
|
||||
if (end == p || n < 0)
|
||||
return 0;
|
||||
if (*end == '%') {
|
||||
if (n > 100)
|
||||
n = 100;
|
||||
packet_loss_level = n * 65536 / 100;
|
||||
coap_log(LOG_DEBUG, "packet loss level set to %d%%\n", n);
|
||||
} else {
|
||||
if (n <= 0)
|
||||
return 0;
|
||||
while (i < 10) {
|
||||
packet_loss_intervals[i].start = n;
|
||||
if (*end == '-') {
|
||||
p = end + 1;
|
||||
n = (int)strtol(p, &end, 10);
|
||||
if (end == p || n <= 0)
|
||||
return 0;
|
||||
}
|
||||
packet_loss_intervals[i++].end = n;
|
||||
if (*end == 0)
|
||||
break;
|
||||
if (*end != ',')
|
||||
return 0;
|
||||
p = end + 1;
|
||||
n = (int)strtol(p, &end, 10);
|
||||
if (end == p || n <= 0)
|
||||
return 0;
|
||||
}
|
||||
if (i == 10)
|
||||
return 0;
|
||||
num_packet_loss_intervals = i;
|
||||
}
|
||||
send_packet_count = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int coap_debug_send_packet(void) {
|
||||
++send_packet_count;
|
||||
if (num_packet_loss_intervals > 0) {
|
||||
int i;
|
||||
for (i = 0; i < num_packet_loss_intervals; i++) {
|
||||
if (send_packet_count >= packet_loss_intervals[i].start
|
||||
&& send_packet_count <= packet_loss_intervals[i].end)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
if ( packet_loss_level > 0 ) {
|
||||
uint16_t r = 0;
|
||||
prng( (uint8_t*)&r, 2 );
|
||||
if ( r < packet_loss_level )
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
File diff suppressed because it is too large
Load Diff
1796
components/coap/port/coap_mbedtls.c
Normal file
1796
components/coap/port/coap_mbedtls.c
Normal file
File diff suppressed because it is too large
Load Diff
631
components/coap/port/include/coap/coap_dtls.h
Normal file
631
components/coap/port/include/coap/coap_dtls.h
Normal file
@ -0,0 +1,631 @@
|
||||
/*
|
||||
* coap_dtls.h -- (Datagram) Transport Layer Support for libcoap
|
||||
*
|
||||
* Copyright (C) 2016 Olaf Bergmann <bergmann@tzi.org>
|
||||
* Copyright (C) 2017 Jean-Claude Michelou <jcm@spinetix.com>
|
||||
*
|
||||
* This file is part of the CoAP library libcoap. Please see README for terms
|
||||
* of use.
|
||||
*/
|
||||
|
||||
#ifndef COAP_DTLS_H_
|
||||
#define COAP_DTLS_H_
|
||||
|
||||
#include "coap_time.h"
|
||||
#include "str.h"
|
||||
|
||||
struct coap_context_t;
|
||||
struct coap_session_t;
|
||||
struct coap_dtls_pki_t;
|
||||
|
||||
/**
|
||||
* @defgroup dtls DTLS Support
|
||||
* API functions for interfacing with DTLS libraries.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check whether DTLS is available.
|
||||
*
|
||||
* @return @c 1 if support for DTLS is enabled, or @c 0 otherwise.
|
||||
*/
|
||||
int coap_dtls_is_supported(void);
|
||||
|
||||
/**
|
||||
* Check whether TLS is available.
|
||||
*
|
||||
* @return @c 1 if support for TLS is enabled, or @c 0 otherwise.
|
||||
*/
|
||||
int coap_tls_is_supported(void);
|
||||
|
||||
typedef enum coap_tls_library_t {
|
||||
COAP_TLS_LIBRARY_NOTLS = 0, /**< No DTLS library */
|
||||
COAP_TLS_LIBRARY_TINYDTLS, /**< Using TinyDTLS library */
|
||||
COAP_TLS_LIBRARY_OPENSSL, /**< Using OpenSSL library */
|
||||
COAP_TLS_LIBRARY_GNUTLS, /**< Using GnuTLS library */
|
||||
COAP_TLS_LIBRARY_MBEDTLS, /**< Using MbedTLS library */
|
||||
} coap_tls_library_t;
|
||||
|
||||
/**
|
||||
* The structure used for returning the underlying (D)TLS library
|
||||
* information.
|
||||
*/
|
||||
typedef struct coap_tls_version_t {
|
||||
uint64_t version; /**< (D)TLS runtime Library Version */
|
||||
coap_tls_library_t type; /**< Library type. One of COAP_TLS_LIBRARY_* */
|
||||
uint64_t built_version; /**< (D)TLS Built against Library Version */
|
||||
} coap_tls_version_t;
|
||||
|
||||
/**
|
||||
* Determine the type and version of the underlying (D)TLS library.
|
||||
*
|
||||
* @return The version and type of library libcoap was compiled against.
|
||||
*/
|
||||
coap_tls_version_t *coap_get_tls_library_version(void);
|
||||
|
||||
/**
|
||||
* Additional Security setup handler that can be set up by
|
||||
* coap_context_set_pki().
|
||||
* Invoked when libcoap has done the validation checks at the TLS level,
|
||||
* but the application needs to do some additional checks/changes/updates.
|
||||
*
|
||||
* @param tls_session The security session definition - e.g. SSL * for OpenSSL.
|
||||
* NULL if server call-back.
|
||||
* This will be dependent on the underlying TLS library -
|
||||
* see coap_get_tls_library_version()
|
||||
* @param setup_data A structure containing setup data originally passed into
|
||||
* coap_context_set_pki() or coap_new_client_session_pki().
|
||||
*
|
||||
* @return @c 1 if successful, else @c 0.
|
||||
*/
|
||||
typedef int (*coap_dtls_security_setup_t)(void* tls_session,
|
||||
struct coap_dtls_pki_t *setup_data);
|
||||
|
||||
/**
|
||||
* CN Validation call-back that can be set up by coap_context_set_pki().
|
||||
* Invoked when libcoap has done the validation checks at the TLS level,
|
||||
* but the application needs to check that the CN is allowed.
|
||||
* CN is the SubjectAltName in the cert, if not present, then the leftmost
|
||||
* Common Name (CN) component of the subject name.
|
||||
*
|
||||
* @param cn The determined CN from the certificate
|
||||
* @param asn1_public_cert The ASN.1 DER encoded X.509 certificate
|
||||
* @param asn1_length The ASN.1 length
|
||||
* @param coap_session The CoAP session associated with the certificate update
|
||||
* @param depth Depth in cert chain. If 0, then client cert, else a CA
|
||||
* @param validated TLS layer can find no issues if 1
|
||||
* @param arg The same as was passed into coap_context_set_pki()
|
||||
* in setup_data->cn_call_back_arg
|
||||
*
|
||||
* @return @c 1 if accepted, else @c 0 if to be rejected.
|
||||
*/
|
||||
typedef int (*coap_dtls_cn_callback_t)(const char *cn,
|
||||
const uint8_t *asn1_public_cert,
|
||||
size_t asn1_length,
|
||||
struct coap_session_t *coap_session,
|
||||
unsigned depth,
|
||||
int validated,
|
||||
void *arg);
|
||||
|
||||
/**
|
||||
* The enum used for determining the provided PKI ASN.1 (DER) Private Key
|
||||
* formats.
|
||||
*/
|
||||
typedef enum coap_asn1_privatekey_type_t {
|
||||
COAP_ASN1_PKEY_NONE, /**< NONE */
|
||||
COAP_ASN1_PKEY_RSA, /**< RSA type */
|
||||
COAP_ASN1_PKEY_RSA2, /**< RSA2 type */
|
||||
COAP_ASN1_PKEY_DSA, /**< DSA type */
|
||||
COAP_ASN1_PKEY_DSA1, /**< DSA1 type */
|
||||
COAP_ASN1_PKEY_DSA2, /**< DSA2 type */
|
||||
COAP_ASN1_PKEY_DSA3, /**< DSA3 type */
|
||||
COAP_ASN1_PKEY_DSA4, /**< DSA4 type */
|
||||
COAP_ASN1_PKEY_DH, /**< DH type */
|
||||
COAP_ASN1_PKEY_DHX, /**< DHX type */
|
||||
COAP_ASN1_PKEY_EC, /**< EC type */
|
||||
COAP_ASN1_PKEY_HMAC, /**< HMAC type */
|
||||
COAP_ASN1_PKEY_CMAC, /**< CMAC type */
|
||||
COAP_ASN1_PKEY_TLS1_PRF, /**< TLS1_PRF type */
|
||||
COAP_ASN1_PKEY_HKDF /**< HKDF type */
|
||||
} coap_asn1_privatekey_type_t;
|
||||
|
||||
/**
|
||||
* The enum used for determining the PKI key formats.
|
||||
*/
|
||||
typedef enum coap_pki_key_t {
|
||||
COAP_PKI_KEY_PEM = 0, /**< The PKI key type is PEM file */
|
||||
COAP_PKI_KEY_ASN1, /**< The PKI key type is ASN.1 (DER) */
|
||||
COAP_PKI_KEY_PEM_BUF, /**< The PKI key type is PEM buffer */
|
||||
} coap_pki_key_t;
|
||||
|
||||
/**
|
||||
* The structure that holds the PKI PEM definitions.
|
||||
*/
|
||||
typedef struct coap_pki_key_pem_t {
|
||||
const char *ca_file; /**< File location of Common CA in PEM format */
|
||||
const char *public_cert; /**< File location of Public Cert in PEM format */
|
||||
const char *private_key; /**< File location of Private Key in PEM format */
|
||||
} coap_pki_key_pem_t;
|
||||
|
||||
/**
|
||||
* The structure that holds the PKI PEM buffer definitions.
|
||||
*/
|
||||
typedef struct coap_pki_key_pem_buf_t {
|
||||
const uint8_t *ca_cert; /**< PEM buffer Common CA Cert */
|
||||
const uint8_t *public_cert; /**< PEM buffer Public Cert */
|
||||
const uint8_t *private_key; /**< PEM buffer Private Key */
|
||||
size_t ca_cert_len; /**< PEM buffer CA Cert length */
|
||||
size_t public_cert_len; /**< PEM buffer Public Cert length */
|
||||
size_t private_key_len; /**< PEM buffer Private Key length */
|
||||
} coap_pki_key_pem_buf_t;
|
||||
|
||||
/**
|
||||
* The structure that holds the PKI ASN.1 (DER) definitions.
|
||||
*/
|
||||
typedef struct coap_pki_key_asn1_t {
|
||||
const uint8_t *ca_cert; /**< ASN1 (DER) Common CA Cert */
|
||||
const uint8_t *public_cert; /**< ASN1 (DER) Public Cert */
|
||||
const uint8_t *private_key; /**< ASN1 (DER) Private Key */
|
||||
size_t ca_cert_len; /**< ASN1 CA Cert length */
|
||||
size_t public_cert_len; /**< ASN1 Public Cert length */
|
||||
size_t private_key_len; /**< ASN1 Private Key length */
|
||||
coap_asn1_privatekey_type_t private_key_type; /**< Private Key Type */
|
||||
} coap_pki_key_asn1_t;
|
||||
|
||||
/**
|
||||
* The structure that holds the PKI key information.
|
||||
*/
|
||||
typedef struct coap_dtls_key_t {
|
||||
coap_pki_key_t key_type; /**< key format type */
|
||||
union {
|
||||
coap_pki_key_pem_t pem; /**< for PEM file keys */
|
||||
coap_pki_key_pem_buf_t pem_buf; /**< for PEM memory keys */
|
||||
coap_pki_key_asn1_t asn1; /**< for ASN.1 (DER) file keys */
|
||||
} key;
|
||||
} coap_dtls_key_t;
|
||||
|
||||
/**
|
||||
* Server Name Indication (SNI) Validation call-back that can be set up by
|
||||
* coap_context_set_pki().
|
||||
* Invoked if the SNI is not previously seen and prior to sending a certificate
|
||||
* set back to the client so that the appropriate certificate set can be used
|
||||
* based on the requesting SNI.
|
||||
*
|
||||
* @param sni The requested SNI
|
||||
* @param arg The same as was passed into coap_context_set_pki()
|
||||
* in setup_data->sni_call_back_arg
|
||||
*
|
||||
* @return New set of certificates to use, or @c NULL if SNI is to be rejected.
|
||||
*/
|
||||
typedef coap_dtls_key_t *(*coap_dtls_sni_callback_t)(const char *sni,
|
||||
void* arg);
|
||||
|
||||
|
||||
#define COAP_DTLS_PKI_SETUP_VERSION 1 /**< Latest PKI setup version */
|
||||
|
||||
/**
|
||||
* The structure used for defining the PKI setup data to be used.
|
||||
*/
|
||||
typedef struct coap_dtls_pki_t {
|
||||
uint8_t version; /** Set to 1 to support this version of the struct */
|
||||
|
||||
/* Options to enable different TLS functionality in libcoap */
|
||||
uint8_t verify_peer_cert; /**< 1 if peer cert is to be verified */
|
||||
uint8_t require_peer_cert; /**< 1 if peer cert is required */
|
||||
uint8_t allow_self_signed; /**< 1 if self signed certs are allowed */
|
||||
uint8_t allow_expired_certs; /**< 1 if expired certs are allowed */
|
||||
uint8_t cert_chain_validation; /**< 1 if to check cert_chain_verify_depth */
|
||||
uint8_t cert_chain_verify_depth; /**< recommended depth is 3 */
|
||||
uint8_t check_cert_revocation; /**< 1 if revocation checks wanted */
|
||||
uint8_t allow_no_crl; /**< 1 ignore if CRL not there */
|
||||
uint8_t allow_expired_crl; /**< 1 if expired crl is allowed */
|
||||
uint8_t allow_bad_md_hash; /**< 1 if expired certs are allowed */
|
||||
uint8_t allow_short_rsa_length; /**< 1 if expired certs are allowed */
|
||||
uint8_t reserved[4]; /**< Reserved - must be set to 0 for
|
||||
future compatibility */
|
||||
/* Size of 4 chosen to align to next
|
||||
* parameter, so if newly defined option
|
||||
* it can use one of the reserverd slot so
|
||||
* no need to change
|
||||
* COAP_DTLS_PKI_SETUP_VERSION and just
|
||||
* decrement the reserved[] count.
|
||||
*/
|
||||
|
||||
/** CN check call-back function.
|
||||
* If not NULL, is called when the TLS connection has passed the configured
|
||||
* TLS options above for the application to verify if the CN is valid.
|
||||
*/
|
||||
coap_dtls_cn_callback_t validate_cn_call_back;
|
||||
void *cn_call_back_arg; /**< Passed in to the CN call-back function */
|
||||
|
||||
/** SNI check call-back function.
|
||||
* If not @p NULL, called if the SNI is not previously seen and prior to
|
||||
* sending a certificate set back to the client so that the appropriate
|
||||
* certificate set can be used based on the requesting SNI.
|
||||
*/
|
||||
coap_dtls_sni_callback_t validate_sni_call_back;
|
||||
void *sni_call_back_arg; /**< Passed in to the sni call-back function */
|
||||
|
||||
/** Additional Security call-back handler that is invoked when libcoap has
|
||||
* done the standerd, defined validation checks at the TLS level,
|
||||
* If not @p NULL, called from within the TLS Client Hello connection
|
||||
* setup.
|
||||
*/
|
||||
coap_dtls_security_setup_t additional_tls_setup_call_back;
|
||||
|
||||
char* client_sni; /**< If not NULL, SNI to use in client TLS setup.
|
||||
Owned by the client app and must remain valid
|
||||
during the call to coap_new_client_session_pki() */
|
||||
|
||||
coap_dtls_key_t pki_key; /**< PKI key definition */
|
||||
} coap_dtls_pki_t;
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup dtls_internal DTLS Support (Internal)
|
||||
* Internal API functions for interfacing with DTLS libraries.
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a new DTLS context for the given @p coap_context. This function
|
||||
* returns a pointer to a new DTLS context object or @c NULL on error.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_context The CoAP context where the DTLS object shall be used.
|
||||
*
|
||||
* @return A DTLS context object or @c NULL on error.
|
||||
*/
|
||||
void *
|
||||
coap_dtls_new_context(struct coap_context_t *coap_context);
|
||||
|
||||
typedef enum coap_dtls_role_t {
|
||||
COAP_DTLS_ROLE_CLIENT, /**< Internal function invoked for client */
|
||||
COAP_DTLS_ROLE_SERVER /**< Internal function invoked for server */
|
||||
} coap_dtls_role_t;
|
||||
|
||||
/**
|
||||
* Set the DTLS context's default PSK information.
|
||||
* This does the PSK specifics following coap_dtls_new_context().
|
||||
* If @p COAP_DTLS_ROLE_SERVER, then identity hint will also get set.
|
||||
* If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the
|
||||
* TLS library's context (from which sessions are derived).
|
||||
* If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the
|
||||
* TLS library's session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_context The CoAP context.
|
||||
* @param identity_hint The default PSK server identity hint sent to a client.
|
||||
* Required parameter. If @p NULL, will be set to "".
|
||||
* Empty string is a valid hint.
|
||||
* This parameter is ignored if COAP_DTLS_ROLE_CLIENT
|
||||
* @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER
|
||||
*
|
||||
* @return @c 1 if successful, else @c 0.
|
||||
*/
|
||||
|
||||
int
|
||||
coap_dtls_context_set_psk(struct coap_context_t *coap_context,
|
||||
const char *identity_hint,
|
||||
coap_dtls_role_t role);
|
||||
|
||||
/**
|
||||
* Set the DTLS context's default server PKI information.
|
||||
* This does the PKI specifics following coap_dtls_new_context().
|
||||
* If @p COAP_DTLS_ROLE_SERVER, then the information will get put into the
|
||||
* TLS library's context (from which sessions are derived).
|
||||
* If @p COAP_DTLS_ROLE_CLIENT, then the information will get put into the
|
||||
* TLS library's session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_context The CoAP context.
|
||||
* @param setup_data Setup information defining how PKI is to be setup.
|
||||
* Required parameter. If @p NULL, PKI will not be
|
||||
* set up.
|
||||
* @param role One of @p COAP_DTLS_ROLE_CLIENT or @p COAP_DTLS_ROLE_SERVER
|
||||
*
|
||||
* @return @c 1 if successful, else @c 0.
|
||||
*/
|
||||
|
||||
int
|
||||
coap_dtls_context_set_pki(struct coap_context_t *coap_context,
|
||||
coap_dtls_pki_t *setup_data,
|
||||
coap_dtls_role_t role);
|
||||
|
||||
/**
|
||||
* Set the dtls context's default Root CA information for a client or server.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_context The current coap_context_t object.
|
||||
* @param ca_file If not @p NULL, is the full path name of a PEM encoded
|
||||
* file containing all the Root CAs to be used.
|
||||
* @param ca_dir If not @p NULL, points to a directory containing PEM
|
||||
* encoded files containing all the Root CAs to be used.
|
||||
*
|
||||
* @return @c 1 if successful, else @c 0.
|
||||
*/
|
||||
|
||||
int
|
||||
coap_dtls_context_set_pki_root_cas(struct coap_context_t *coap_context,
|
||||
const char *ca_file,
|
||||
const char *ca_dir);
|
||||
|
||||
/**
|
||||
* Check whether one of the coap_dtls_context_set_{psk|pki}() functions have
|
||||
* been called.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_context The current coap_context_t object.
|
||||
*
|
||||
* @return @c 1 if coap_dtls_context_set_{psk|pki}() called, else @c 0.
|
||||
*/
|
||||
|
||||
int coap_dtls_context_check_keys_enabled(struct coap_context_t *coap_context);
|
||||
|
||||
/**
|
||||
* Releases the storage allocated for @p dtls_context.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param dtls_context The DTLS context as returned by coap_dtls_new_context().
|
||||
*/
|
||||
void coap_dtls_free_context(void *dtls_context);
|
||||
|
||||
/**
|
||||
* Create a new client-side session. This should send a HELLO to the server.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*
|
||||
* @return Opaque handle to underlying TLS library object containing security
|
||||
* parameters for the session.
|
||||
*/
|
||||
void *coap_dtls_new_client_session(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Create a new DTLS server-side session.
|
||||
* Called after coap_dtls_hello() has returned @c 1, signalling that a validated
|
||||
* HELLO was received from a client.
|
||||
* This should send a HELLO to the server.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*
|
||||
* @return Opaque handle to underlying TLS library object containing security
|
||||
* parameters for the DTLS session.
|
||||
*/
|
||||
void *coap_dtls_new_server_session(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Terminates the DTLS session (may send an ALERT if necessary) then frees the
|
||||
* underlying TLS library object containing security parameters for the session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*/
|
||||
void coap_dtls_free_session(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Notify of a change in the CoAP session's MTU, for example after
|
||||
* a PMTU update.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*/
|
||||
void coap_dtls_session_update_mtu(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Send data to a DTLS peer.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param data pointer to data.
|
||||
* @param data_len Number of bytes to send.
|
||||
*
|
||||
* @return @c 0 if this would be blocking, @c -1 if there is an error or the
|
||||
* number of cleartext bytes sent.
|
||||
*/
|
||||
int coap_dtls_send(struct coap_session_t *coap_session,
|
||||
const uint8_t *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* Check if timeout is handled per CoAP session or per CoAP context.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @return @c 1 of timeout and retransmit is per context, @c 0 if it is
|
||||
* per session.
|
||||
*/
|
||||
int coap_dtls_is_context_timeout(void);
|
||||
|
||||
/**
|
||||
* Do all pending retransmits and get next timeout
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param dtls_context The DTLS context.
|
||||
*
|
||||
* @return @c 0 if no event is pending or date of the next retransmit.
|
||||
*/
|
||||
coap_tick_t coap_dtls_get_context_timeout(void *dtls_context);
|
||||
|
||||
/**
|
||||
* Get next timeout for this session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param now The current time in ticks.
|
||||
*
|
||||
* @return @c 0 If no event is pending or ticks time of the next retransmit.
|
||||
*/
|
||||
coap_tick_t coap_dtls_get_timeout(struct coap_session_t *coap_session,
|
||||
coap_tick_t now);
|
||||
|
||||
/**
|
||||
* Handle a DTLS timeout expiration.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*/
|
||||
void coap_dtls_handle_timeout(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Handling incoming data from a DTLS peer.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param data Encrypted datagram.
|
||||
* @param data_len Encrypted datagram size.
|
||||
*
|
||||
* @return Result of coap_handle_dgram on the decrypted CoAP PDU
|
||||
* or @c -1 for error.
|
||||
*/
|
||||
int coap_dtls_receive(struct coap_session_t *coap_session,
|
||||
const uint8_t *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* Handling client HELLO messages from a new candiate peer.
|
||||
* Note that session->tls is empty.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param data Encrypted datagram.
|
||||
* @param data_len Encrypted datagram size.
|
||||
*
|
||||
* @return @c 0 if a cookie verification message has been sent, @c 1 if the
|
||||
* HELLO contains a valid cookie and a server session should be created,
|
||||
* @c -1 if the message is invalid.
|
||||
*/
|
||||
int coap_dtls_hello(struct coap_session_t *coap_session,
|
||||
const uint8_t *data,
|
||||
size_t data_len);
|
||||
|
||||
/**
|
||||
* Get DTLS overhead over cleartext PDUs.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*
|
||||
* @return Maximum number of bytes added by DTLS layer.
|
||||
*/
|
||||
unsigned int coap_dtls_get_overhead(struct coap_session_t *coap_session);
|
||||
|
||||
/**
|
||||
* Create a new TLS client-side session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param connected Updated with whether the connection is connected yet or not.
|
||||
* @c 0 is not connected, @c 1 is connected.
|
||||
*
|
||||
* @return Opaque handle to underlying TLS library object containing security
|
||||
* parameters for the session.
|
||||
*/
|
||||
void *coap_tls_new_client_session(struct coap_session_t *coap_session, int *connected);
|
||||
|
||||
/**
|
||||
* Create a TLS new server-side session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param connected Updated with whether the connection is connected yet or not.
|
||||
* @c 0 is not connected, @c 1 is connected.
|
||||
*
|
||||
* @return Opaque handle to underlying TLS library object containing security
|
||||
* parameters for the session.
|
||||
*/
|
||||
void *coap_tls_new_server_session(struct coap_session_t *coap_session, int *connected);
|
||||
|
||||
/**
|
||||
* Terminates the TLS session (may send an ALERT if necessary) then frees the
|
||||
* underlying TLS library object containing security parameters for the session.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
*/
|
||||
void coap_tls_free_session( struct coap_session_t *coap_session );
|
||||
|
||||
/**
|
||||
* Send data to a TLS peer, with implicit flush.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param data Pointer to data.
|
||||
* @param data_len Number of bytes to send.
|
||||
*
|
||||
* @return @c 0 if this should be retried, @c -1 if there is an error
|
||||
* or the number of cleartext bytes sent.
|
||||
*/
|
||||
ssize_t coap_tls_write(struct coap_session_t *coap_session,
|
||||
const uint8_t *data,
|
||||
size_t data_len
|
||||
);
|
||||
|
||||
/**
|
||||
* Read some data from a TLS peer.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
* @param coap_session The CoAP session.
|
||||
* @param data Pointer to data.
|
||||
* @param data_len Maximum number of bytes to read.
|
||||
*
|
||||
* @return @c 0 if this should be retried, @c -1 if there is an error
|
||||
* or the number of cleartext bytes read.
|
||||
*/
|
||||
ssize_t coap_tls_read(struct coap_session_t *coap_session,
|
||||
uint8_t *data,
|
||||
size_t data_len
|
||||
);
|
||||
|
||||
/**
|
||||
* Initialize the underlying (D)TLS Library layer.
|
||||
*
|
||||
* Internal function.
|
||||
*
|
||||
*/
|
||||
void coap_dtls_startup(void);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @ingroup logging
|
||||
* Sets the (D)TLS logging level to the specified @p level.
|
||||
* Note: coap_log_level() will influence output if at a specified level.
|
||||
*
|
||||
* @param level The logging level to use - LOG_*
|
||||
*/
|
||||
void coap_dtls_set_log_level(int level);
|
||||
|
||||
/**
|
||||
* @ingroup logging
|
||||
* Get the current (D)TLS logging.
|
||||
*
|
||||
* @return The current log level (one of LOG_*).
|
||||
*/
|
||||
int coap_dtls_get_log_level(void);
|
||||
|
||||
|
||||
#endif /* COAP_DTLS_H */
|
@ -21,18 +21,27 @@
|
||||
#ifdef WITH_POSIX
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <net/if.h>
|
||||
|
||||
#define HAVE_SYS_SOCKET_H
|
||||
#define HAVE_MALLOC
|
||||
#define HAVE_ARPA_INET_H
|
||||
#define HAVE_TIME_H
|
||||
#define HAVE_NETDB_H
|
||||
#define HAVE_NETINET_IN_H
|
||||
|
||||
#define IPV6_PKTINFO IPV6_V6ONLY
|
||||
|
||||
#define PACKAGE_NAME "libcoap-posix"
|
||||
#define PACKAGE_VERSION "?"
|
||||
|
||||
#define COAP_BAD_RECVMSG
|
||||
#define HAVE_MBEDTLS
|
||||
#define COAP_CONSTRAINED_STACK 1
|
||||
#define ESPIDF_VERSION
|
||||
|
||||
#define _POSIX_TIMERS 1
|
||||
|
||||
#define gai_strerror(x) "gai_strerror() not supported"
|
||||
|
||||
#endif /* WITH_POSIX */
|
||||
#endif /* COAP_CONFIG_POSIX_H_ */
|
||||
|
@ -70,7 +70,7 @@ esp_err_t esp_console_init(const esp_console_config_t *config)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_console_deinit()
|
||||
esp_err_t esp_console_deinit(void)
|
||||
{
|
||||
if (!s_tmp_line_buf) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
@ -232,7 +232,7 @@ static int help_command(int argc, char **argv)
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_console_register_help_command()
|
||||
esp_err_t esp_console_register_help_command(void)
|
||||
{
|
||||
esp_console_cmd_t command = {
|
||||
.command = "help",
|
||||
|
@ -52,7 +52,7 @@ esp_err_t esp_console_init(const esp_console_config_t* config);
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if not initialized yet
|
||||
*/
|
||||
esp_err_t esp_console_deinit();
|
||||
esp_err_t esp_console_deinit(void);
|
||||
|
||||
|
||||
/**
|
||||
@ -185,7 +185,7 @@ const char *esp_console_get_hint(const char *buf, int *color, int *bold);
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE, if esp_console_init wasn't called
|
||||
*/
|
||||
esp_err_t esp_console_register_help_command();
|
||||
esp_err_t esp_console_register_help_command(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ void linenoiseSetDumbMode(int set) {
|
||||
/* Use the ESC [6n escape sequence to query the horizontal cursor position
|
||||
* and return it. On error -1 is returned, on success the position of the
|
||||
* cursor. */
|
||||
static int getCursorPosition() {
|
||||
static int getCursorPosition(void) {
|
||||
char buf[32];
|
||||
int cols, rows;
|
||||
unsigned int i = 0;
|
||||
@ -228,7 +228,7 @@ static int getCursorPosition() {
|
||||
|
||||
/* Try to get the number of columns in the current terminal, or assume 80
|
||||
* if it fails. */
|
||||
static int getColumns() {
|
||||
static int getColumns(void) {
|
||||
int start, cols;
|
||||
|
||||
/* Get the initial position so we can restore it later. */
|
||||
@ -887,7 +887,7 @@ static int linenoiseEdit(char *buf, size_t buflen, const char *prompt)
|
||||
return l.len;
|
||||
}
|
||||
|
||||
int linenoiseProbe() {
|
||||
int linenoiseProbe(void) {
|
||||
/* Switch to non-blocking mode */
|
||||
int flags = fcntl(STDIN_FILENO, F_GETFL);
|
||||
flags |= O_NONBLOCK;
|
||||
@ -1000,7 +1000,7 @@ void linenoiseFree(void *ptr) {
|
||||
|
||||
/* ================================ History ================================= */
|
||||
|
||||
void linenoiseHistoryFree() {
|
||||
void linenoiseHistoryFree(void) {
|
||||
if (history) {
|
||||
for (int j = 0; j < history_len; j++) {
|
||||
free(history[j]);
|
||||
|
@ -63,7 +63,7 @@ int linenoiseHistoryAdd(const char *line);
|
||||
int linenoiseHistorySetMaxLen(int len);
|
||||
int linenoiseHistorySave(const char *filename);
|
||||
int linenoiseHistoryLoad(const char *filename);
|
||||
void linenoiseHistoryFree();
|
||||
void linenoiseHistoryFree(void);
|
||||
void linenoiseClearScreen(void);
|
||||
void linenoiseSetMultiLine(int ml);
|
||||
void linenoiseSetDumbMode(int set);
|
||||
|
@ -36,7 +36,7 @@ static size_t s_static_init_max_waiting_count = 0; //!< maximum ever va
|
||||
extern "C" int __cxa_guard_acquire(__guard* pg);
|
||||
extern "C" void __cxa_guard_release(__guard* pg);
|
||||
extern "C" void __cxa_guard_abort(__guard* pg);
|
||||
extern "C" void __cxa_guard_dummy();
|
||||
extern "C" void __cxa_guard_dummy(void);
|
||||
|
||||
/**
|
||||
* Layout of the guard object (defined by the ABI).
|
||||
@ -215,6 +215,6 @@ extern "C" void __cxa_guard_abort(__guard* pg)
|
||||
* Dummy function used to force linking this file instead of the same one in libstdc++.
|
||||
* This works via -u __cxa_guard_dummy flag in component.mk
|
||||
*/
|
||||
extern "C" void __cxa_guard_dummy()
|
||||
extern "C" void __cxa_guard_dummy(void)
|
||||
{
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ extern "C" {
|
||||
* This is an internal API for I2S module to call to enable I2S-ADC function.
|
||||
* Note that adc_power_off() can still power down ADC.
|
||||
*/
|
||||
void adc_power_always_on();
|
||||
void adc_power_always_on(void);
|
||||
|
||||
/**
|
||||
* @brief For I2S dma to claim the usage of ADC1.
|
||||
@ -41,7 +41,7 @@ void adc_power_always_on();
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success.
|
||||
*/
|
||||
esp_err_t adc1_i2s_mode_acquire();
|
||||
esp_err_t adc1_i2s_mode_acquire(void);
|
||||
|
||||
/**
|
||||
* @brief For ADC1 to claim the usage of ADC1.
|
||||
@ -53,7 +53,7 @@ esp_err_t adc1_i2s_mode_acquire();
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success.
|
||||
*/
|
||||
esp_err_t adc1_adc_mode_acquire();
|
||||
esp_err_t adc1_adc_mode_acquire(void);
|
||||
|
||||
/**
|
||||
* @brief to let other tasks use the ADC1 when I2S is not work.
|
||||
@ -63,7 +63,7 @@ esp_err_t adc1_adc_mode_acquire();
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t adc1_lock_release();
|
||||
esp_err_t adc1_lock_release(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ static portMUX_TYPE can_spinlock = portMUX_INITIALIZER_UNLOCKED;
|
||||
|
||||
/* ------------------- Configuration Register Functions---------------------- */
|
||||
|
||||
static inline esp_err_t can_enter_reset_mode()
|
||||
static inline esp_err_t can_enter_reset_mode(void)
|
||||
{
|
||||
/* Enter reset mode (required to write to configuration registers). Reset mode
|
||||
also prevents all CAN activity on the current module and is automatically
|
||||
@ -152,7 +152,7 @@ static inline esp_err_t can_enter_reset_mode()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static inline esp_err_t can_exit_reset_mode()
|
||||
static inline esp_err_t can_exit_reset_mode(void)
|
||||
{
|
||||
/* Exiting reset mode will return the CAN module to operating mode. Reset mode
|
||||
must also be exited in order to trigger BUS-OFF recovery sequence. */
|
||||
@ -161,7 +161,7 @@ static inline esp_err_t can_exit_reset_mode()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static inline void can_config_pelican()
|
||||
static inline void can_config_pelican(void)
|
||||
{
|
||||
//Use PeliCAN address layout. Exposes extra registers
|
||||
CAN.clock_divider_reg.can_mode = 1;
|
||||
@ -287,23 +287,23 @@ static void can_set_tx_buffer_and_transmit(can_frame_t *frame)
|
||||
can_set_command(command);
|
||||
}
|
||||
|
||||
static inline uint32_t can_get_status()
|
||||
static inline uint32_t can_get_status(void)
|
||||
{
|
||||
return CAN.status_reg.val;
|
||||
}
|
||||
|
||||
static inline uint32_t can_get_interrupt_reason()
|
||||
static inline uint32_t can_get_interrupt_reason(void)
|
||||
{
|
||||
return CAN.interrupt_reg.val;
|
||||
}
|
||||
|
||||
static inline uint32_t can_get_arbitration_lost_capture()
|
||||
static inline uint32_t can_get_arbitration_lost_capture(void)
|
||||
{
|
||||
return CAN.arbitration_lost_captue_reg.val;
|
||||
//Todo: ALC read only to re-arm arb lost interrupt. Add function to decode ALC
|
||||
}
|
||||
|
||||
static inline uint32_t can_get_error_code_capture()
|
||||
static inline uint32_t can_get_error_code_capture(void)
|
||||
{
|
||||
return CAN.error_code_capture_reg.val;
|
||||
//Todo: ECC read only to re-arm bus error interrupt. Add function to decode ECC
|
||||
@ -329,7 +329,7 @@ static inline void can_get_rx_buffer_and_clear(can_frame_t *frame)
|
||||
can_set_command(CMD_RELEASE_RX_BUFF);
|
||||
}
|
||||
|
||||
static inline uint32_t can_get_rx_message_counter()
|
||||
static inline uint32_t can_get_rx_message_counter(void)
|
||||
{
|
||||
return CAN.rx_message_counter_reg.val;
|
||||
}
|
||||
@ -726,7 +726,7 @@ esp_err_t can_driver_install(const can_general_config_t *g_config, const can_tim
|
||||
return ret;
|
||||
}
|
||||
|
||||
esp_err_t can_driver_uninstall()
|
||||
esp_err_t can_driver_uninstall(void)
|
||||
{
|
||||
can_obj_t *p_can_obj_dummy;
|
||||
|
||||
@ -762,7 +762,7 @@ esp_err_t can_driver_uninstall()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t can_start()
|
||||
esp_err_t can_start(void)
|
||||
{
|
||||
//Check state
|
||||
CAN_ENTER_CRITICAL();
|
||||
@ -792,7 +792,7 @@ esp_err_t can_start()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t can_stop()
|
||||
esp_err_t can_stop(void)
|
||||
{
|
||||
//Check state
|
||||
CAN_ENTER_CRITICAL();
|
||||
@ -929,7 +929,7 @@ esp_err_t can_reconfigure_alerts(uint32_t alerts_enabled, uint32_t *current_aler
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t can_initiate_recovery()
|
||||
esp_err_t can_initiate_recovery(void)
|
||||
{
|
||||
CAN_ENTER_CRITICAL();
|
||||
//Check state
|
||||
@ -983,7 +983,7 @@ esp_err_t can_get_status_info(can_status_info_t *status_info)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t can_clear_transmit_queue()
|
||||
esp_err_t can_clear_transmit_queue(void)
|
||||
{
|
||||
//Check State
|
||||
CAN_CHECK(p_can_obj != NULL, ESP_ERR_INVALID_STATE);
|
||||
@ -998,7 +998,7 @@ esp_err_t can_clear_transmit_queue()
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t can_clear_receive_queue()
|
||||
esp_err_t can_clear_receive_queue(void)
|
||||
{
|
||||
//Check State
|
||||
CAN_CHECK(p_can_obj != NULL, ESP_ERR_INVALID_STATE);
|
||||
|
@ -396,14 +396,24 @@ static void IRAM_ATTR gpio_intr_service(void* arg)
|
||||
return;
|
||||
}
|
||||
//read status to get interrupt status for GPIO0-31
|
||||
const uint32_t gpio_intr_status = (isr_core_id == 0) ? GPIO.pcpu_int : GPIO.acpu_int;
|
||||
uint32_t gpio_intr_status;
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
gpio_intr_status = (isr_core_id == 0) ? GPIO.pcpu_int : GPIO.acpu_int;
|
||||
#else
|
||||
gpio_intr_status = GPIO.pcpu_int;
|
||||
#endif
|
||||
if (gpio_intr_status) {
|
||||
gpio_isr_loop(gpio_intr_status, 0);
|
||||
GPIO.status_w1tc = gpio_intr_status;
|
||||
}
|
||||
|
||||
//read status1 to get interrupt status for GPIO32-39
|
||||
const uint32_t gpio_intr_status_h = (isr_core_id == 0) ? GPIO.pcpu_int1.intr : GPIO.acpu_int1.intr;
|
||||
uint32_t gpio_intr_status_h;
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
gpio_intr_status_h = (isr_core_id == 0) ? GPIO.pcpu_int1.intr : GPIO.acpu_int1.intr;
|
||||
#else
|
||||
gpio_intr_status_h = GPIO.pcpu_int1.intr;
|
||||
#endif
|
||||
if (gpio_intr_status_h) {
|
||||
gpio_isr_loop(gpio_intr_status_h, 32);
|
||||
GPIO.status1_w1tc.intr_st = gpio_intr_status_h;
|
||||
@ -454,7 +464,7 @@ esp_err_t gpio_install_isr_service(int intr_alloc_flags)
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gpio_uninstall_isr_service()
|
||||
void gpio_uninstall_isr_service(void)
|
||||
{
|
||||
if (gpio_isr_func == NULL) {
|
||||
return;
|
||||
|
@ -985,7 +985,7 @@ esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num, gpio_p
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
i2c_cmd_handle_t i2c_cmd_link_create()
|
||||
i2c_cmd_handle_t i2c_cmd_link_create(void)
|
||||
{
|
||||
#if !CONFIG_SPIRAM_USE_MALLOC
|
||||
i2c_cmd_desc_t* cmd_desc = (i2c_cmd_desc_t*) calloc(1, sizeof(i2c_cmd_desc_t));
|
||||
|
@ -775,7 +775,7 @@ esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t _i2s_adc_mode_recover()
|
||||
static esp_err_t _i2s_adc_mode_recover(void)
|
||||
{
|
||||
I2S_CHECK(((_i2s_adc_unit != -1) && (_i2s_adc_channel != -1)), "i2s ADC recover error, not initialized...", ESP_ERR_INVALID_ARG);
|
||||
return adc_i2s_mode_init(_i2s_adc_unit, _i2s_adc_channel);
|
||||
@ -943,7 +943,7 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co
|
||||
I2S[i2s_num]->conf.rx_start = 0;
|
||||
|
||||
if (i2s_config->mode & I2S_MODE_TX) {
|
||||
I2S[i2s_num]->conf.tx_msb_right = 0;
|
||||
I2S[i2s_num]->conf.tx_msb_right = 1;
|
||||
I2S[i2s_num]->conf.tx_right_first = 0;
|
||||
|
||||
I2S[i2s_num]->conf.tx_slave_mod = 0; // Master
|
||||
@ -955,7 +955,7 @@ static esp_err_t i2s_param_config(i2s_port_t i2s_num, const i2s_config_t *i2s_co
|
||||
}
|
||||
|
||||
if (i2s_config->mode & I2S_MODE_RX) {
|
||||
I2S[i2s_num]->conf.rx_msb_right = 0;
|
||||
I2S[i2s_num]->conf.rx_msb_right = 1;
|
||||
I2S[i2s_num]->conf.rx_right_first = 0;
|
||||
I2S[i2s_num]->conf.rx_slave_mod = 0; // Master
|
||||
I2S[i2s_num]->fifo_conf.rx_fifo_mod_force_en = 1;
|
||||
|
@ -235,13 +235,13 @@ int adc1_get_voltage(adc1_channel_t channel) __attribute__((deprecated));
|
||||
/**
|
||||
* @brief Enable ADC power
|
||||
*/
|
||||
void adc_power_on();
|
||||
void adc_power_on(void);
|
||||
|
||||
/**
|
||||
* @brief Power off SAR ADC
|
||||
* This function will force power down for ADC
|
||||
*/
|
||||
void adc_power_off();
|
||||
void adc_power_off(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize ADC pad
|
||||
@ -298,7 +298,7 @@ esp_err_t adc_i2s_mode_init(adc_unit_t adc_unit, adc_channel_t channel);
|
||||
* Note that adc1_config_channel_atten, adc1_config_width functions need
|
||||
* to be called to configure ADC1 channels, before ADC1 is used by the ULP.
|
||||
*/
|
||||
void adc1_ulp_enable();
|
||||
void adc1_ulp_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Read Hall Sensor
|
||||
@ -319,7 +319,7 @@ void adc1_ulp_enable();
|
||||
*
|
||||
* @return The hall sensor reading.
|
||||
*/
|
||||
int hall_sensor_read();
|
||||
int hall_sensor_read(void);
|
||||
|
||||
/**
|
||||
* @brief Get the gpio number of a specific ADC2 channel.
|
||||
|
@ -31,7 +31,7 @@ extern "C" {
|
||||
* - ESP_OK success
|
||||
* - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success.
|
||||
*/
|
||||
esp_err_t adc2_wifi_acquire();
|
||||
esp_err_t adc2_wifi_acquire(void);
|
||||
|
||||
|
||||
/**
|
||||
@ -42,7 +42,7 @@ esp_err_t adc2_wifi_acquire();
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t adc2_wifi_release();
|
||||
esp_err_t adc2_wifi_release(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ esp_err_t can_driver_install(const can_general_config_t *g_config, const can_tim
|
||||
* - ESP_OK: Successfully uninstalled CAN driver
|
||||
* - ESP_ERR_INVALID_STATE: Driver is not in stopped/bus-off state, or is not installed
|
||||
*/
|
||||
esp_err_t can_driver_uninstall();
|
||||
esp_err_t can_driver_uninstall(void);
|
||||
|
||||
/**
|
||||
* @brief Start the CAN driver
|
||||
@ -253,7 +253,7 @@ esp_err_t can_driver_uninstall();
|
||||
* - ESP_OK: CAN driver is now running
|
||||
* - ESP_ERR_INVALID_STATE: Driver is not in stopped state, or is not installed
|
||||
*/
|
||||
esp_err_t can_start();
|
||||
esp_err_t can_start(void);
|
||||
|
||||
/**
|
||||
* @brief Stop the CAN driver
|
||||
@ -272,7 +272,7 @@ esp_err_t can_start();
|
||||
* - ESP_OK: CAN driver is now Stopped
|
||||
* - ESP_ERR_INVALID_STATE: Driver is not in running state, or is not installed
|
||||
*/
|
||||
esp_err_t can_stop();
|
||||
esp_err_t can_stop(void);
|
||||
|
||||
/**
|
||||
* @brief Transmit a CAN message
|
||||
@ -379,7 +379,7 @@ esp_err_t can_reconfigure_alerts(uint32_t alerts_enabled, uint32_t *current_aler
|
||||
* - ESP_OK: Bus recovery started
|
||||
* - ESP_ERR_INVALID_STATE: CAN driver is not in the bus-off state, or is not installed
|
||||
*/
|
||||
esp_err_t can_initiate_recovery();
|
||||
esp_err_t can_initiate_recovery(void);
|
||||
|
||||
/**
|
||||
* @brief Get current status information of the CAN driver
|
||||
@ -405,7 +405,7 @@ esp_err_t can_get_status_info(can_status_info_t *status_info);
|
||||
* - ESP_OK: Transmit queue cleared
|
||||
* - ESP_ERR_INVALID_STATE: CAN driver is not installed or TX queue is disabled
|
||||
*/
|
||||
esp_err_t can_clear_transmit_queue();
|
||||
esp_err_t can_clear_transmit_queue(void);
|
||||
|
||||
/**
|
||||
* @brief Clear the receive queue
|
||||
@ -419,7 +419,7 @@ esp_err_t can_clear_transmit_queue();
|
||||
* - ESP_OK: Transmit queue cleared
|
||||
* - ESP_ERR_INVALID_STATE: CAN driver is not installed
|
||||
*/
|
||||
esp_err_t can_clear_receive_queue();
|
||||
esp_err_t can_clear_receive_queue(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -99,12 +99,12 @@ esp_err_t dac_output_disable(dac_channel_t channel);
|
||||
/**
|
||||
* @brief Enable DAC output data from I2S
|
||||
*/
|
||||
esp_err_t dac_i2s_enable();
|
||||
esp_err_t dac_i2s_enable(void);
|
||||
|
||||
/**
|
||||
* @brief Disable DAC output data from I2S
|
||||
*/
|
||||
esp_err_t dac_i2s_disable();
|
||||
esp_err_t dac_i2s_disable(void);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -637,7 +637,7 @@ esp_err_t gpio_install_isr_service(int intr_alloc_flags);
|
||||
/**
|
||||
* @brief Uninstall the driver's GPIO ISR service, freeing related resources.
|
||||
*/
|
||||
void gpio_uninstall_isr_service();
|
||||
void gpio_uninstall_isr_service(void);
|
||||
|
||||
/**
|
||||
* @brief Add ISR handler for the corresponding GPIO pin.
|
||||
|
@ -224,7 +224,7 @@ esp_err_t i2c_set_pin(i2c_port_t i2c_num, int sda_io_num, int scl_io_num,
|
||||
*
|
||||
* @return i2c command link handler
|
||||
*/
|
||||
i2c_cmd_handle_t i2c_cmd_link_create();
|
||||
i2c_cmd_handle_t i2c_cmd_link_create(void);
|
||||
|
||||
/**
|
||||
* @brief Free I2C command link
|
||||
|
@ -439,7 +439,7 @@ esp_err_t ledc_fade_func_install(int intr_alloc_flags);
|
||||
* @brief Uninstall LEDC fade function.
|
||||
*
|
||||
*/
|
||||
void ledc_fade_func_uninstall();
|
||||
void ledc_fade_func_uninstall(void);
|
||||
|
||||
/**
|
||||
* @brief Start LEDC fading.
|
||||
|
@ -230,7 +230,7 @@ esp_err_t rtc_gpio_isolate(gpio_num_t gpio_num);
|
||||
* Force hold signal is enabled before going into deep sleep for pins which
|
||||
* are used for EXT1 wakeup.
|
||||
*/
|
||||
void rtc_gpio_force_hold_dis_all();
|
||||
void rtc_gpio_force_hold_dis_all(void);
|
||||
|
||||
/**
|
||||
* @brief Set RTC GPIO pad drive capability
|
||||
|
@ -111,7 +111,7 @@ esp_err_t sdio_slave_initialize(sdio_slave_config_t *config);
|
||||
|
||||
/** De-initialize the sdio slave driver to release the resources.
|
||||
*/
|
||||
void sdio_slave_deinit();
|
||||
void sdio_slave_deinit(void);
|
||||
|
||||
/** Start hardware for sending and receiving, as well as set the IOREADY1 to 1.
|
||||
*
|
||||
@ -122,19 +122,19 @@ void sdio_slave_deinit();
|
||||
* - ESP_ERR_INVALID_STATE if already started.
|
||||
* - ESP_OK otherwise.
|
||||
*/
|
||||
esp_err_t sdio_slave_start();
|
||||
esp_err_t sdio_slave_start(void);
|
||||
|
||||
/** Stop hardware from sending and receiving, also set IOREADY1 to 0.
|
||||
*
|
||||
* @note this will not clear the data already in the driver, and also not reset the PKT_LEN and TOKEN1 counting. Call ``sdio_slave_reset`` to do that.
|
||||
*/
|
||||
void sdio_slave_stop();
|
||||
void sdio_slave_stop(void);
|
||||
|
||||
/** Clear the data still in the driver, as well as reset the PKT_LEN and TOKEN1 counting.
|
||||
*
|
||||
* @return always return ESP_OK.
|
||||
*/
|
||||
esp_err_t sdio_slave_reset();
|
||||
esp_err_t sdio_slave_reset(void);
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
* Receive
|
||||
@ -263,7 +263,7 @@ esp_err_t sdio_slave_write_reg(int pos, uint8_t reg);
|
||||
*
|
||||
* @return the interrupt mask.
|
||||
*/
|
||||
sdio_slave_hostint_t sdio_slave_get_host_intena();
|
||||
sdio_slave_hostint_t sdio_slave_get_host_intena(void);
|
||||
|
||||
/** Set the interrupt enable for host.
|
||||
*
|
||||
|
@ -91,7 +91,7 @@ typedef struct {
|
||||
* - ESP_ERR_INVALID_STATE if sdmmc_host_init was already called
|
||||
* - ESP_ERR_NO_MEM if memory can not be allocated
|
||||
*/
|
||||
esp_err_t sdmmc_host_init();
|
||||
esp_err_t sdmmc_host_init(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize given slot of SDMMC peripheral
|
||||
@ -218,7 +218,7 @@ esp_err_t sdmmc_host_io_int_wait(int slot, TickType_t timeout_ticks);
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if sdmmc_host_init function has not been called
|
||||
*/
|
||||
esp_err_t sdmmc_host_deinit();
|
||||
esp_err_t sdmmc_host_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable the pull-ups of sd pins.
|
||||
|
@ -91,7 +91,7 @@ typedef struct {
|
||||
* - ESP_OK on success
|
||||
* - other error codes may be returned in future versions
|
||||
*/
|
||||
esp_err_t sdspi_host_init();
|
||||
esp_err_t sdspi_host_init(void);
|
||||
|
||||
/**
|
||||
* @brief Initialize SD SPI driver for the specific SPI controller
|
||||
@ -159,7 +159,7 @@ esp_err_t sdspi_host_set_card_clk(int slot, uint32_t freq_khz);
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_STATE if sdspi_host_init function has not been called
|
||||
*/
|
||||
esp_err_t sdspi_host_deinit();
|
||||
esp_err_t sdspi_host_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Enable SDIO interrupt.
|
||||
|
@ -143,18 +143,6 @@ esp_err_t spi_bus_free(spi_host_device_t host);
|
||||
*/
|
||||
bool spicommon_periph_claim(spi_host_device_t host, const char* source);
|
||||
|
||||
// The macro is to keep the back-compatibility of IDF v3.2 and before
|
||||
// In this way we can call spicommon_periph_claim with two arguments, or the host with the source set to the calling function name
|
||||
// When two arguments (host, func) are given, __spicommon_periph_claim2 is called
|
||||
// or if only one arguments (host) is given, __spicommon_periph_claim1 is called
|
||||
#define spicommon_periph_claim(host...) __spicommon_periph_claim(host, 2, 1)
|
||||
#define __spicommon_periph_claim(host, source, n, ...) __spicommon_periph_claim ## n(host, source)
|
||||
#define __spicommon_periph_claim1(host, _) ({ \
|
||||
char* warning_str = "calling spicommon_periph_claim without source string is deprecated.";\
|
||||
spicommon_periph_claim(host, __FUNCTION__); })
|
||||
|
||||
#define __spicommon_periph_claim2(host, func) spicommon_periph_claim(host, func)
|
||||
|
||||
/**
|
||||
* @brief Check whether the spi periph is in use.
|
||||
*
|
||||
@ -390,7 +378,7 @@ bool spicommon_dmaworkaround_req_reset(int dmachan, dmaworkaround_cb_t cb, void
|
||||
*
|
||||
* @return True when a DMA reset is requested but hasn't completed yet. False otherwise.
|
||||
*/
|
||||
bool spicommon_dmaworkaround_reset_in_progress();
|
||||
bool spicommon_dmaworkaround_reset_in_progress(void);
|
||||
|
||||
|
||||
/**
|
||||
|
@ -278,7 +278,7 @@ typedef intr_handle_t touch_isr_handle_t;
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_NO_MEM Touch pad init error
|
||||
*/
|
||||
esp_err_t touch_pad_init();
|
||||
esp_err_t touch_pad_init(void);
|
||||
|
||||
/**
|
||||
* @brief Un-install touch pad driver.
|
||||
@ -287,7 +287,7 @@ esp_err_t touch_pad_init();
|
||||
* - ESP_OK Success
|
||||
* - ESP_FAIL Touch pad driver not initialized
|
||||
*/
|
||||
esp_err_t touch_pad_deinit();
|
||||
esp_err_t touch_pad_deinit(void);
|
||||
|
||||
/**
|
||||
* @brief Deregister the handler previously registered using touch_pad_isr_handler_register
|
||||
@ -300,99 +300,6 @@ esp_err_t touch_pad_deinit();
|
||||
*/
|
||||
esp_err_t touch_pad_isr_deregister(void(*fn)(void *), void *arg);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor reference voltage, if the voltage gap between high and low reference voltage get less,
|
||||
* the charging and discharging time would be faster, accordingly, the counter value would be larger.
|
||||
* In the case of detecting very slight change of capacitance, we can narrow down the gap so as to increase
|
||||
* the sensitivity. On the other hand, narrow voltage gap would also introduce more noise, but we can use a
|
||||
* software filter to pre-process the counter value.
|
||||
* @param refh the value of DREFH
|
||||
* @param refl the value of DREFL
|
||||
* @param atten the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_voltage(touch_high_volt_t refh, touch_low_volt_t refl, touch_volt_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor reference voltage,
|
||||
* @param refh pointer to accept DREFH value
|
||||
* @param refl pointer to accept DREFL value
|
||||
* @param atten pointer to accept the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl, touch_volt_atten_t *atten);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor charge/discharge speed for each pad.
|
||||
* If the slope is 0, the counter would always be zero.
|
||||
* If the slope is 1, the charging and discharging would be slow, accordingly, the counter value would be small.
|
||||
* If the slope is set 7, which is the maximum value, the charging and discharging would be fast, accordingly, the
|
||||
* counter value would be larger.
|
||||
* @param touch_num touch pad index
|
||||
* @param slope touch pad charge/discharge speed
|
||||
* @param opt the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor charge/discharge speed for each pad
|
||||
* @param touch_num touch pad index
|
||||
* @param slope pointer to accept touch pad charge/discharge slope
|
||||
* @param opt pointer to accept the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt);
|
||||
|
||||
/**
|
||||
* @brief Initialize touch pad GPIO
|
||||
* @param touch_num touch pad index
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_io_init(touch_pad_t touch_num);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor FSM mode, the test action can be triggered by the timer,
|
||||
* as well as by the software.
|
||||
* @param mode FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_fsm_mode(touch_fsm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor FSM mode
|
||||
* @param mode pointer to accept FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Trigger a touch sensor measurement, only support in SW mode of FSM
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_sw_start();
|
||||
|
||||
/**
|
||||
* @brief Get the touch sensor status bit mask. usually used in ISR to decide which pads are 'touched'.
|
||||
* If status bit is 1, this pad is be touched, else, this pad is released.
|
||||
* @return
|
||||
* - touch status
|
||||
*/
|
||||
uint32_t touch_pad_get_status();
|
||||
|
||||
/**
|
||||
* @brief Get the touch pad which caused wakeup from sleep
|
||||
* @param pad_num pointer to touch pad which caused wakeup
|
||||
@ -546,6 +453,91 @@ esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle);
|
||||
*/
|
||||
esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor reference voltage, if the voltage gap between high and low reference voltage get less,
|
||||
* the charging and discharging time would be faster, accordingly, the counter value would be larger.
|
||||
* In the case of detecting very slight change of capacitance, we can narrow down the gap so as to increase
|
||||
* the sensitivity. On the other hand, narrow voltage gap would also introduce more noise, but we can use a
|
||||
* software filter to pre-process the counter value.
|
||||
* @param refh the value of DREFH
|
||||
* @param refl the value of DREFL
|
||||
* @param atten the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_voltage(touch_high_volt_t refh, touch_low_volt_t refl, touch_volt_atten_t atten);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor reference voltage,
|
||||
* @param refh pointer to accept DREFH value
|
||||
* @param refl pointer to accept DREFL value
|
||||
* @param atten pointer to accept the attenuation on DREFH
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_voltage(touch_high_volt_t *refh, touch_low_volt_t *refl, touch_volt_atten_t *atten);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor charge/discharge speed for each pad.
|
||||
* If the slope is 0, the counter would always be zero.
|
||||
* If the slope is 1, the charging and discharging would be slow, accordingly, the counter value would be small.
|
||||
* If the slope is set 7, which is the maximum value, the charging and discharging would be fast, accordingly, the
|
||||
* counter value would be larger.
|
||||
* @param touch_num touch pad index
|
||||
* @param slope touch pad charge/discharge speed
|
||||
* @param opt the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t slope, touch_tie_opt_t opt);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor charge/discharge speed for each pad
|
||||
* @param touch_num touch pad index
|
||||
* @param slope pointer to accept touch pad charge/discharge slope
|
||||
* @param opt pointer to accept the initial voltage
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_get_cnt_mode(touch_pad_t touch_num, touch_cnt_slope_t *slope, touch_tie_opt_t *opt);
|
||||
|
||||
/**
|
||||
* @brief Initialize touch pad GPIO
|
||||
* @param touch_num touch pad index
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_io_init(touch_pad_t touch_num);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor FSM mode, the test action can be triggered by the timer,
|
||||
* as well as by the software.
|
||||
* @param mode FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
* - ESP_ERR_INVALID_ARG if argument is wrong
|
||||
*/
|
||||
esp_err_t touch_pad_set_fsm_mode(touch_fsm_mode_t mode);
|
||||
|
||||
/**
|
||||
* @brief Get touch sensor FSM mode
|
||||
* @param mode pointer to accept FSM mode
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_get_fsm_mode(touch_fsm_mode_t *mode);
|
||||
|
||||
/**
|
||||
* @brief Trigger a touch sensor measurement, only support in SW mode of FSM
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_sw_start(void);
|
||||
|
||||
/**
|
||||
* @brief Set touch sensor interrupt threshold
|
||||
* @param touch_num touch pad index
|
||||
@ -648,21 +640,28 @@ esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uin
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_clear_status();
|
||||
esp_err_t touch_pad_clear_status(void);
|
||||
|
||||
/**
|
||||
* @brief Get the touch sensor status, usually used in ISR to decide which pads are 'touched'.
|
||||
* @return
|
||||
* - touch status
|
||||
*/
|
||||
uint32_t touch_pad_get_status(void);
|
||||
|
||||
/**
|
||||
* @brief To enable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_enable();
|
||||
esp_err_t touch_pad_intr_enable(void);
|
||||
|
||||
/**
|
||||
* @brief To disable touch pad interrupt
|
||||
* @return
|
||||
* - ESP_OK on success
|
||||
*/
|
||||
esp_err_t touch_pad_intr_disable();
|
||||
esp_err_t touch_pad_intr_disable(void);
|
||||
|
||||
/**
|
||||
* @brief set touch pad filter calibration period, in ms.
|
||||
@ -712,7 +711,7 @@ esp_err_t touch_pad_filter_start(uint32_t filter_period_ms);
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_stop();
|
||||
esp_err_t touch_pad_filter_stop(void);
|
||||
|
||||
/**
|
||||
* @brief delete touch pad filter driver and release the memory
|
||||
@ -721,7 +720,7 @@ esp_err_t touch_pad_filter_stop();
|
||||
* - ESP_OK Success
|
||||
* - ESP_ERR_INVALID_STATE driver state error
|
||||
*/
|
||||
esp_err_t touch_pad_filter_delete();
|
||||
esp_err_t touch_pad_filter_delete(void);
|
||||
|
||||
#elif CONFIG_IDF_TARGET_ESP32S2BETA
|
||||
|
||||
|
@ -40,7 +40,7 @@ void uart_set_select_notif_callback(uart_port_t uart_num, uart_select_notif_call
|
||||
/**
|
||||
* @brief Get mutex guarding select() notifications
|
||||
*/
|
||||
portMUX_TYPE *uart_get_selectlock();
|
||||
portMUX_TYPE *uart_get_selectlock(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -742,7 +742,7 @@ esp_err_t ledc_fade_func_install(int intr_alloc_flags)
|
||||
return ledc_isr_register(ledc_fade_isr, NULL, intr_alloc_flags | ESP_INTR_FLAG_IRAM, &s_ledc_fade_isr_handle);
|
||||
}
|
||||
|
||||
void ledc_fade_func_uninstall()
|
||||
void ledc_fade_func_uninstall(void)
|
||||
{
|
||||
if (s_ledc_fade_rec == NULL) {
|
||||
return;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user