2022-01-10 03:56:21 -05:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2016-11-21 09:56:11 -05:00
|
|
|
|
2016-11-22 23:55:49 -05:00
|
|
|
/**
|
|
|
|
* @file lib_printf.c
|
|
|
|
*
|
|
|
|
* This file contains library-specific printf functions
|
|
|
|
* used by WiFi libraries in the `lib` directory.
|
|
|
|
* These function are used to catch any output which gets printed
|
|
|
|
* by libraries, and redirect it to ESP_LOG macros.
|
|
|
|
*
|
|
|
|
* Eventually WiFi libraries will use ESP_LOG functions internally
|
|
|
|
* and these definitions will be removed.
|
|
|
|
*/
|
|
|
|
|
2016-11-21 09:56:11 -05:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "esp_log.h"
|
|
|
|
#include "esp_attr.h"
|
|
|
|
|
|
|
|
#define VPRINTF_STACK_BUFFER_SIZE 80
|
|
|
|
|
|
|
|
static int lib_printf(const char* tag, const char* format, va_list arg)
|
|
|
|
{
|
|
|
|
char temp[VPRINTF_STACK_BUFFER_SIZE];
|
|
|
|
int len = vsnprintf(temp, sizeof(temp) - 1, format, arg);
|
|
|
|
temp[sizeof(temp) - 1] = 0;
|
|
|
|
int i;
|
|
|
|
for (i = len - 1; i >= 0; --i) {
|
|
|
|
if (temp[i] != '\n' && temp[i] != '\r' && temp[i] != ' ') {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
temp[i] = 0;
|
|
|
|
}
|
|
|
|
if (i > 0) {
|
2021-01-10 03:16:28 -05:00
|
|
|
ESP_LOGI(tag, "%s", temp);
|
2016-11-21 09:56:11 -05:00
|
|
|
}
|
|
|
|
va_end(arg);
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
int phy_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("phy", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int rtc_printf(const char* format, ...)
|
|
|
|
{
|
2016-12-07 12:37:07 -05:00
|
|
|
// librtc.a printf temporary disabled due to UART baud rate switching bug.
|
|
|
|
return 0;
|
2016-11-21 09:56:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
int wpa_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("wpa", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-11-24 23:03:58 -05:00
|
|
|
int wpa2_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("wpa2", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2016-11-21 09:56:11 -05:00
|
|
|
int wps_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("wps", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int pp_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("pp", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int sc_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("smartconfig", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int core_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("core", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
int net80211_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("net80211", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
2018-04-03 03:37:28 -04:00
|
|
|
|
|
|
|
int coexist_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("coexist", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
2020-10-23 11:55:29 -04:00
|
|
|
|
2021-01-23 05:15:07 -05:00
|
|
|
int wapi_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
2022-01-10 03:56:21 -05:00
|
|
|
int res = lib_printf("wapi", format, arg);
|
2021-01-23 05:15:07 -05:00
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2020-10-23 11:55:29 -04:00
|
|
|
int mesh_printf(const char* format, ...)
|
|
|
|
{
|
|
|
|
va_list arg;
|
|
|
|
va_start(arg, format);
|
|
|
|
int res = lib_printf("mesh", format, arg);
|
|
|
|
va_end(arg);
|
|
|
|
return res;
|
|
|
|
}
|