Commit b96e3147 authored by Marcel Stör's avatar Marcel Stör Committed by GitHub
Browse files

Merge pull request #1774 from nodemcu/dev

2.0.0 master drop
parents 81ec3665 20a591f5
...@@ -5,13 +5,21 @@ addons: ...@@ -5,13 +5,21 @@ addons:
packages: packages:
- python-serial - python-serial
- srecord - srecord
- lua5.1
cache: cache:
directories: - pip
- directories:
- cache - cache
before_install:
- pip install --user hererocks esptool
- hererocks env --lua 5.1 -rlatest
- source env/bin/activate
- luarocks install luafilesystem
install: install:
- tar -zxvf tools/esp-open-sdk.tar.gz - tar -Jxvf tools/esp-open-sdk.tar.xz
- export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin - export PATH=$PATH:$PWD/esp-open-sdk/xtensa-lx106-elf/bin
script: script:
- lua tools/cross-lua.lua || exit 1
- export BUILD_DATE=$(date +%Y%m%d) - export BUILD_DATE=$(date +%Y%m%d)
- make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all - make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all
- cd bin/ - cd bin/
......
...@@ -15,7 +15,7 @@ It is appreciated if you raise an issue _before_ you start changing NodeMCU, dis ...@@ -15,7 +15,7 @@ It is appreciated if you raise an issue _before_ you start changing NodeMCU, dis
* [Keeping your fork in sync](#keeping-your-fork-in-sync) * [Keeping your fork in sync](#keeping-your-fork-in-sync)
* [Commit messages](#commit-messages) * [Commit messages](#commit-messages)
* [For collaborators](#for-collaborators) * [For collaborators](#for-collaborators)
* [Handling releases](#handling-release) * [Handling releases](#handling-releases)
## General remarks ## General remarks
We are a friendly and welcoming community and look forward to your contributions. Once your contribution is integrated into this repository we feel responsible for it. Therefore, be prepared for constructive feedback. Before we merge anything we need to ensure that it fits in and is consistent with the rest of NodeMCU. We are a friendly and welcoming community and look forward to your contributions. Once your contribution is integrated into this repository we feel responsible for it. Therefore, be prepared for constructive feedback. Before we merge anything we need to ensure that it fits in and is consistent with the rest of NodeMCU.
...@@ -105,6 +105,8 @@ Don't forget to [reference affected issues](https://help.github.com/articles/clo ...@@ -105,6 +105,8 @@ Don't forget to [reference affected issues](https://help.github.com/articles/clo
- Add notes to the description of the milestone in the course of the ~2 months it lives. - Add notes to the description of the milestone in the course of the ~2 months it lives.
- Be careful and reluctant to merge PRs once we're past the 6-weeks mark of a milestone. Ideally we don't merge anything in the last 2 weeks. - Be careful and reluctant to merge PRs once we're past the 6-weeks mark of a milestone. Ideally we don't merge anything in the last 2 weeks.
- Cutting a release - Cutting a release
- Create an annotated tag like so: `git tag -a <SDK-version>-master_<yyyyMMdd> -m ""`, `git push --tags` - Create a PR for the `master` branch for collaborators to approve.
- Create a new [release](https://github.com/nodemcu/nodemcu-firmware/releases) based on the tag you just pushed. The version name is the same as the tag name. - Once approved merge it. :exclamation::boom::exclamation: Make sure you do NOT "squash and merge" but make a regular merge commit!
- Write release notes. Mention breaking changes explicitly. Since every PR that went into this release is linked to from the milestone it should be fairly easy to include important changes in the release notes. - Fetch the changes into your local clone and create an annotated tag like so: `git tag -a <SDK-version>-master_<yyyyMMdd> -m ""`, `git push --tags`
- Create a new [release](https://github.com/nodemcu/nodemcu-firmware/releases) based on the tag you just pushed. The version name is the same as the tag name.
- Write release notes. Mention breaking changes explicitly. Since every PR that went into this release is linked to from the milestone it should be fairly easy to include important changes in the release notes.
...@@ -3,21 +3,19 @@ ...@@ -3,21 +3,19 @@
.NOTPARALLEL: .NOTPARALLEL:
# SDK version NodeMCU is locked to # SDK version NodeMCU is locked to
SDK_VER:=1.5.4.1 SDK_VER:=2.0.0
# no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted # no patch: SDK_BASE_VER equals SDK_VER and sdk dir depends on sdk_extracted
#SDK_BASE_VER:=SDK_VER SDK_BASE_VER:=$(SDK_VER)
#SDK_DIR_DEPENDS:=sdk_extracted SDK_DIR_DEPENDS:=sdk_extracted
# with patch: SDK_BASE_VER differs from SDK_VER and sdk dir depends on sdk_patched # with patch: SDK_BASE_VER differs from SDK_VER and sdk dir depends on sdk_patched
SDK_BASE_VER:=1.5.4 #SDK_BASE_VER:=1.5.4
SDK_DIR_DEPENDS:=sdk_patched #SDK_DIR_DEPENDS:=sdk_patched
SDK_FILE_VER:=$(SDK_BASE_VER)_16_05_20 SDK_FILE_VER:=$(SDK_BASE_VER)_16_08_10
SDK_FILE_ID:=1469 SDK_FILE_SHA1:=b0127a99b45b3778be4a752387ab8dc0f6dd7810
SDK_FILE_SHA1:=868784bd37d47f31d52b81f133aa1fb70c58e17d #SDK_PATCH_VER:=$(SDK_VER)_patch_20160704
SDK_PATCH_VER:=$(SDK_VER)_patch_20160704 #SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
SDK_PATCH_ID:=1572
SDK_PATCH_SHA1:=388d9e91df74e3b49fca126da482cf822cf1ebf1
# Ensure we search "our" SDK before the tool-chain's SDK (if any) # Ensure we search "our" SDK before the tool-chain's SDK (if any)
TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST)))) TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
SDK_DIR:=$(TOP_DIR)/sdk/esp_iot_sdk_v$(SDK_VER) SDK_DIR:=$(TOP_DIR)/sdk/esp_iot_sdk_v$(SDK_VER)
...@@ -221,12 +219,12 @@ $(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VE ...@@ -221,12 +219,12 @@ $(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VE
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_FILE_VER).zip: $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_FILE_VER).zip:
mkdir -p "$(dir $@)" mkdir -p "$(dir $@)"
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://bbs.espressif.com/download/file.php?id=$(SDK_FILE_ID) -O $@ || { rm -f "$@"; exit 1; } wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
(echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; } (echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
$(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip: $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip:
mkdir -p "$(dir $@)" mkdir -p "$(dir $@)"
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://bbs.espressif.com/download/file.php?id=$(SDK_PATCH_ID) -O $@ || { rm -f "$@"; exit 1; } wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused http://espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v$(SDK_PATCH_VER).zip -O $@ || { rm -f "$@"; exit 1; }
(echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; } (echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
clean: clean:
......
# **NodeMCU 1.5.4.1** # # **NodeMCU 2.0.0** #
[![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Join the chat at https://gitter.im/nodemcu/nodemcu-firmware](https://img.shields.io/gitter/room/badges/shields.svg)](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
[![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware) [![Build Status](https://travis-ci.org/nodemcu/nodemcu-firmware.svg)](https://travis-ci.org/nodemcu/nodemcu-firmware)
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
### A Lua based firmware for ESP8266 WiFi SOC ### A Lua based firmware for ESP8266 WiFi SOC
NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 1.5.4.1](http://bbs.espressif.com/viewtopic.php?f=46&t=2376) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK. NodeMCU is an [eLua](http://www.eluaproject.net/) based firmware for the [ESP8266 WiFi SOC from Espressif](http://espressif.com/en/products/esp8266/). The firmware is based on the [Espressif NON-OS SDK 2.0.0](https://espressif.com/sites/default/files/sdks/esp8266_nonos_sdk_v2.0.0_16_08_10.zip) and uses a file system based on [spiffs](https://github.com/pellepl/spiffs). The code repository consists of 98.1% C-code that glues the thin Lua veneer to the SDK.
The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](https://github.com/nodemcu/nodemcu-devkit-v1.0), ready-made open source development boards with ESP8266-12E chips. The NodeMCU *firmware* is a companion project to the popular [NodeMCU dev kits](https://github.com/nodemcu/nodemcu-devkit-v1.0), ready-made open source development boards with ESP8266-12E chips.
...@@ -90,7 +90,7 @@ Edit `app/include/user_modules.h` and comment-out the `#define` statement for mo ...@@ -90,7 +90,7 @@ Edit `app/include/user_modules.h` and comment-out the `#define` statement for mo
Identify your firmware builds by editing `app/include/user_version.h` Identify your firmware builds by editing `app/include/user_version.h`
```c ```c
#define NODE_VERSION "NodeMCU 1.5.4.1+myname" #define NODE_VERSION "NodeMCU 2.0.0+myname"
#ifndef BUILD_DATE #ifndef BUILD_DATE
#define BUILD_DATE "YYYYMMDD" #define BUILD_DATE "YYYYMMDD"
#endif #endif
......
...@@ -25,6 +25,7 @@ SUBDIRS= \ ...@@ -25,6 +25,7 @@ SUBDIRS= \
user \ user \
driver \ driver \
pcm \ pcm \
mbedtls \
platform \ platform \
libc \ libc \
lua \ lua \
...@@ -94,6 +95,7 @@ COMPONENTS_eagle.app.v6 = \ ...@@ -94,6 +95,7 @@ COMPONENTS_eagle.app.v6 = \
websocket/libwebsocket.a \ websocket/libwebsocket.a \
esp-gdbstub/libgdbstub.a \ esp-gdbstub/libgdbstub.a \
net/libnodemcu_net.a \ net/libnodemcu_net.a \
mbedtls/libmbedtls.a \
modules/libmodules.a \ modules/libmodules.a \
# Inspect the modules library and work out which modules need to be linked. # Inspect the modules library and work out which modules need to be linked.
...@@ -113,6 +115,7 @@ LINKFLAGS_eagle.app.v6 = \ ...@@ -113,6 +115,7 @@ LINKFLAGS_eagle.app.v6 = \
-Wl,-static \ -Wl,-static \
$(addprefix -u , $(SELECTED_MODULE_SYMS)) \ $(addprefix -u , $(SELECTED_MODULE_SYMS)) \
-Wl,--start-group \ -Wl,--start-group \
-lmain \
-lc \ -lc \
-lgcc \ -lgcc \
-lhal \ -lhal \
...@@ -121,10 +124,9 @@ LINKFLAGS_eagle.app.v6 = \ ...@@ -121,10 +124,9 @@ LINKFLAGS_eagle.app.v6 = \
-lnet80211 \ -lnet80211 \
-lwpa \ -lwpa \
-lwpa2 \ -lwpa2 \
-lmain \
-lsmartconfig \ -lsmartconfig \
-lssl \
-lcrypto \ -lcrypto \
-lwps \
$(DEP_LIBS_eagle.app.v6) \ $(DEP_LIBS_eagle.app.v6) \
-Wl,--end-group \ -Wl,--end-group \
-lm -lm
...@@ -154,6 +156,7 @@ CONFIGURATION_DEFINES = -D__ets__ \ ...@@ -154,6 +156,7 @@ CONFIGURATION_DEFINES = -D__ets__ \
-DLWIP_OPEN_SRC \ -DLWIP_OPEN_SRC \
-DPBUF_RSV_FOR_WLAN \ -DPBUF_RSV_FOR_WLAN \
-DEBUF_LWIP \ -DEBUF_LWIP \
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
DEFINES += \ DEFINES += \
$(UNIVERSAL_TARGET_DEFINES) \ $(UNIVERSAL_TARGET_DEFINES) \
......
...@@ -144,7 +144,9 @@ int ICACHE_FLASH_ATTR crypto_fhash (const digest_mech_info_t *mi, ...@@ -144,7 +144,9 @@ int ICACHE_FLASH_ATTR crypto_fhash (const digest_mech_info_t *mi,
int read_len = 0; int read_len = 0;
do { do {
read_len = read(readarg, buffer, mi->block_size); read_len = read(readarg, buffer, mi->block_size);
mi->update (ctx, buffer, read_len); if (read_len > 0) {
mi->update (ctx, buffer, read_len);
}
} while (read_len == mi->block_size); } while (read_len == mi->block_size);
// Finish up // Finish up
......
...@@ -180,7 +180,7 @@ pwm_start(void) ...@@ -180,7 +180,7 @@ pwm_start(void)
// yeah, if all channels' duty is 0 or 255, don't need to start timer, otherwise start... // yeah, if all channels' duty is 0 or 255, don't need to start timer, otherwise start...
if (*local_channel != 1) { if (*local_channel != 1) {
PWM_DBG("Need to setup timer\n"); PWM_DBG("Need to setup timer\n");
if (!platform_hw_timer_init(TIMER_OWNER, NMI_SOURCE, FALSE)) { if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, FALSE)) {
return FALSE; return FALSE;
} }
pwm_timer_down = 0; pwm_timer_down = 0;
......
...@@ -356,3 +356,18 @@ uart_setup(uint8 uart_no) ...@@ -356,3 +356,18 @@ uart_setup(uint8 uart_no)
void ICACHE_FLASH_ATTR uart_set_alt_output_uart0(void (*fn)(char)) { void ICACHE_FLASH_ATTR uart_set_alt_output_uart0(void (*fn)(char)) {
alt_uart0_tx = fn; alt_uart0_tx = fn;
} }
UartConfig ICACHE_FLASH_ATTR uart_get_config(uint8 uart_no) {
UartConfig config;
config.baut_rate = UART_CLK_FREQ / READ_PERI_REG(UART_CLKDIV(uart_no));
uint32_t conf = READ_PERI_REG(UART_CONF0(uart_no));
config.exist_parity = (conf >> UART_PARITY_EN_S) & UART_PARITY_EN_M;
config.parity = (conf >> UART_PARITY_S) & UART_PARITY_M;
config.stop_bits = (conf >> UART_STOP_BIT_NUM_S) & UART_STOP_BIT_NUM;
config.data_bits = (conf >> UART_BIT_NUM_S) & UART_BIT_NUM;
return config;
}
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
typedef struct request_args_t { typedef struct request_args_t {
char * hostname; char * hostname;
int port; int port;
#ifdef CLIENT_SSL_ENABLE
bool secure; bool secure;
#endif
char * method; char * method;
char * path; char * path;
char * headers; char * headers;
...@@ -140,9 +142,11 @@ static void ICACHE_FLASH_ATTR http_receive_callback( void * arg, char * buf, uns ...@@ -140,9 +142,11 @@ static void ICACHE_FLASH_ATTR http_receive_callback( void * arg, char * buf, uns
{ {
HTTPCLIENT_ERR( "Response too long (%d)", new_size ); HTTPCLIENT_ERR( "Response too long (%d)", new_size );
req->buffer[0] = '\0'; /* Discard the buffer to avoid using an incomplete response. */ req->buffer[0] = '\0'; /* Discard the buffer to avoid using an incomplete response. */
#ifdef CLIENT_SSL_ENABLE
if ( req->secure ) if ( req->secure )
espconn_secure_disconnect( conn ); espconn_secure_disconnect( conn );
else else
#endif
espconn_disconnect( conn ); espconn_disconnect( conn );
return; /* The disconnect callback will be called. */ return; /* The disconnect callback will be called. */
} }
...@@ -170,9 +174,11 @@ static void ICACHE_FLASH_ATTR http_send_callback( void * arg ) ...@@ -170,9 +174,11 @@ static void ICACHE_FLASH_ATTR http_send_callback( void * arg )
{ {
/* The headers were sent, now send the contents. */ /* The headers were sent, now send the contents. */
HTTPCLIENT_DEBUG( "Sending request body" ); HTTPCLIENT_DEBUG( "Sending request body" );
#ifdef CLIENT_SSL_ENABLE
if ( req->secure ) if ( req->secure )
espconn_secure_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) ); espconn_secure_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) );
else else
#endif
espconn_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) ); espconn_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) );
os_free( req->post_data ); os_free( req->post_data );
req->post_data = NULL; req->post_data = NULL;
...@@ -213,7 +219,11 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg ) ...@@ -213,7 +219,11 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
int host_len = 0; int host_len = 0;
if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL) if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL)
{ {
if ((req->port == 80) || ((req->port == 443) && ( req->secure ))) if ((req->port == 80)
#ifdef CLIENT_SSL_ENABLE
|| ((req->port == 443) && ( req->secure ))
#endif
)
{ {
os_sprintf( host_header, "Host: %s\r\n", req->hostname ); os_sprintf( host_header, "Host: %s\r\n", req->hostname );
} }
...@@ -236,11 +246,13 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg ) ...@@ -236,11 +246,13 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
"\r\n", "\r\n",
req->method, req->path, host_header, req->headers, ua_header, post_headers ); req->method, req->path, host_header, req->headers, ua_header, post_headers );
#ifdef CLIENT_SSL_ENABLE
if (req->secure) if (req->secure)
{ {
espconn_secure_send( conn, (uint8_t *) buf, len ); espconn_secure_send( conn, (uint8_t *) buf, len );
} }
else else
#endif
{ {
espconn_send( conn, (uint8_t *) buf, len ); espconn_send( conn, (uint8_t *) buf, len );
} }
...@@ -343,8 +355,13 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg ) ...@@ -343,8 +355,13 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
req->post_data, req->callback_handle, req->redirect_follow_count ); req->post_data, req->callback_handle, req->redirect_follow_count );
} else { } else {
if ( os_strncmp( locationOffset, "/", 1 ) == 0) { // relative and full path if ( os_strncmp( locationOffset, "/", 1 ) == 0) { // relative and full path
http_raw_request( req->hostname, req->port, req->secure, req->method, http_raw_request( req->hostname, req->port,
locationOffset, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count ); #ifdef CLIENT_SSL_ENABLE
req->secure,
#else
0,
#endif
req->method, locationOffset, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count );
} else { // relative and relative path } else { // relative and relative path
// find last / // find last /
...@@ -360,8 +377,13 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg ) ...@@ -360,8 +377,13 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
os_memcpy( completeRelativePath, req->path, pathFolderLength ); os_memcpy( completeRelativePath, req->path, pathFolderLength );
os_memcpy( completeRelativePath + pathFolderLength, locationOffset, locationLength); os_memcpy( completeRelativePath + pathFolderLength, locationOffset, locationLength);
http_raw_request( req->hostname, req->port, req->secure, req->method, http_raw_request( req->hostname, req->port,
completeRelativePath, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count ); #ifdef CLIENT_SSL_ENABLE
req->secure,
#else
0,
#endif
req->method, completeRelativePath, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count );
os_free( completeRelativePath ); os_free( completeRelativePath );
} }
...@@ -402,9 +424,20 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg ) ...@@ -402,9 +424,20 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
} }
if ( req->callback_handle != NULL ) /* Callback is optional. */ if ( req->callback_handle != NULL ) /* Callback is optional. */
{ {
req->callback_handle( body, http_status, req->buffer ); char *req_buffer = req->buffer;
} req->buffer = NULL;
http_free_req( req ); http_callback_t req_callback;
req_callback = req->callback_handle;
http_free_req( req );
req_callback( body, http_status, &req_buffer );
if (req_buffer) {
os_free(req_buffer);
}
} else {
http_free_req( req );
}
} }
/* Fix memory leak. */ /* Fix memory leak. */
espconn_delete( conn ); espconn_delete( conn );
...@@ -426,9 +459,11 @@ static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg ) ...@@ -426,9 +459,11 @@ static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg )
} }
request_args_t * req = (request_args_t *) conn->reverse; request_args_t * req = (request_args_t *) conn->reverse;
/* Call disconnect */ /* Call disconnect */
#ifdef CLIENT_SSL_ENABLE
if ( req->secure ) if ( req->secure )
espconn_secure_disconnect( conn ); espconn_secure_disconnect( conn );
else else
#endif
espconn_disconnect( conn ); espconn_disconnect( conn );
} }
...@@ -449,7 +484,7 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_ ...@@ -449,7 +484,7 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
HTTPCLIENT_ERR( "DNS failed for %s", hostname ); HTTPCLIENT_ERR( "DNS failed for %s", hostname );
if ( req->callback_handle != NULL ) if ( req->callback_handle != NULL )
{ {
req->callback_handle( "", -1, "" ); req->callback_handle( "", -1, NULL );
} }
http_free_req( req ); http_free_req( req );
} }
...@@ -476,11 +511,13 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_ ...@@ -476,11 +511,13 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
os_timer_setfn( &(req->timeout_timer), (os_timer_func_t *) http_timeout_callback, conn ); os_timer_setfn( &(req->timeout_timer), (os_timer_func_t *) http_timeout_callback, conn );
os_timer_arm( &(req->timeout_timer), req->timeout, false ); os_timer_arm( &(req->timeout_timer), req->timeout, false );
#ifdef CLIENT_SSL_ENABLE
if ( req->secure ) if ( req->secure )
{ {
espconn_secure_connect( conn ); espconn_secure_connect( conn );
} }
else else
#endif
{ {
espconn_connect( conn ); espconn_connect( conn );
} }
...@@ -495,7 +532,9 @@ void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool s ...@@ -495,7 +532,9 @@ void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool s
request_args_t * req = (request_args_t *) os_zalloc( sizeof(request_args_t) ); request_args_t * req = (request_args_t *) os_zalloc( sizeof(request_args_t) );
req->hostname = esp_strdup( hostname ); req->hostname = esp_strdup( hostname );
req->port = port; req->port = port;
#ifdef CLIENT_SSL_ENABLE
req->secure = secure; req->secure = secure;
#endif
req->method = esp_strdup( method ); req->method = esp_strdup( method );
req->path = esp_strdup( path ); req->path = esp_strdup( path );
req->headers = esp_strdup( headers ); req->headers = esp_strdup( headers );
......
...@@ -53,7 +53,7 @@ static const char log_prefix[] = "HTTP client: "; ...@@ -53,7 +53,7 @@ static const char log_prefix[] = "HTTP client: ";
* A successful request corresponds to an HTTP status code of 200 (OK). * A successful request corresponds to an HTTP status code of 200 (OK).
* More info at http://en.wikipedia.org/wiki/List_of_HTTP_status_codes * More info at http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
*/ */
typedef void (* http_callback_t)(char * response_body, int http_status, char * full_response); typedef void (* http_callback_t)(char * response_body, int http_status, char ** full_response_p);
/* /*
* Call this function to skip URL parsing if the arguments are already in separate variables. * Call this function to skip URL parsing if the arguments are already in separate variables.
......
...@@ -38,10 +38,7 @@ ...@@ -38,10 +38,7 @@
#include "c_types.h" #include "c_types.h"
#include "ets_sys.h" #include "ets_sys.h"
#include "osapi.h" #include "osapi.h"
#ifndef EFAULT
#define EFAULT 14 #define EFAULT 14
#endif
//#define LWIP_PROVIDE_ERRNO //#define LWIP_PROVIDE_ERRNO
...@@ -52,13 +49,13 @@ ...@@ -52,13 +49,13 @@
#endif #endif
typedef unsigned char u8_t; typedef uint8_t u8_t;
typedef signed char s8_t; typedef int8_t s8_t;
typedef unsigned short u16_t; typedef uint16_t u16_t;
typedef signed short s16_t; typedef int16_t s16_t;
typedef unsigned long u32_t; typedef uint32_t u32_t;
typedef signed long s32_t; typedef int32_t s32_t;
typedef unsigned long mem_ptr_t; typedef uint32_t mem_ptr_t;
#define S16_F "d" #define S16_F "d"
#define U16_F "d" #define U16_F "d"
......
...@@ -41,6 +41,7 @@ typedef enum { ...@@ -41,6 +41,7 @@ typedef enum {
BIT_RATE_4800 = 4800, BIT_RATE_4800 = 4800,
BIT_RATE_9600 = 9600, BIT_RATE_9600 = 9600,
BIT_RATE_19200 = 19200, BIT_RATE_19200 = 19200,
BIT_RATE_31250 = 31250,
BIT_RATE_38400 = 38400, BIT_RATE_38400 = 38400,
BIT_RATE_57600 = 57600, BIT_RATE_57600 = 57600,
BIT_RATE_74880 = 74880, BIT_RATE_74880 = 74880,
...@@ -101,7 +102,16 @@ typedef struct { ...@@ -101,7 +102,16 @@ typedef struct {
int buff_uart_no; //indicate which uart use tx/rx buffer int buff_uart_no; //indicate which uart use tx/rx buffer
} UartDevice; } UartDevice;
typedef struct {
UartBautRate baut_rate;
UartBitsNum4Char data_bits;
UartExistParity exist_parity;
UartParityMode parity;
UartStopBitsNum stop_bits;
} UartConfig;
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input, uint8 *flag_input); void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input, uint8 *flag_input);
UartConfig uart_get_config(uint8 uart_no);
void uart0_alt(uint8 on); void uart0_alt(uint8 on);
void uart0_sendStr(const char *str); void uart0_sendStr(const char *str);
void uart0_putc(const char c); void uart0_putc(const char c);
......
...@@ -40,10 +40,23 @@ enum dhcps_offer_option{ ...@@ -40,10 +40,23 @@ enum dhcps_offer_option{
}; };
#endif #endif
typedef enum {
DHCPS_TYPE_DYNAMIC,
DHCPS_TYPE_STATIC
} dhcps_type_t;
typedef enum {
DHCPS_STATE_ONLINE,
DHCPS_STATE_OFFLINE
} dhcps_state_t;
struct dhcps_pool{ struct dhcps_pool{
struct ip_addr ip; struct ip_addr ip;
uint8 mac[6]; uint8 mac[6];
uint32 lease_timer; uint32 lease_timer;
dhcps_type_t type;
dhcps_state_t state;
}; };
typedef struct _list_node{ typedef struct _list_node{
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "lwip/dns.h" #include "lwip/dns.h"
#include "os_type.h" #include "os_type.h"
#include "lwip/app/espconn_buf.h"
#if 0 #if 0
#define espconn_printf(fmt, args...) os_printf(fmt,## args) #define espconn_printf(fmt, args...) os_printf(fmt,## args)
...@@ -32,6 +33,8 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); ...@@ -32,6 +33,8 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err);
#define ESPCONN_ARG -12 /* Illegal argument. */ #define ESPCONN_ARG -12 /* Illegal argument. */
#define ESPCONN_IF -14 /* Low_level error */ #define ESPCONN_IF -14 /* Low_level error */
#define ESPCONN_ISCONN -15 /* Already connected. */ #define ESPCONN_ISCONN -15 /* Already connected. */
#define ESPCONN_TIME -16 /* Sync Time error */
#define ESPCONN_NODATA -17 /* No data can be read */
#define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */ #define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */
#define ESPCONN_RESP_TIMEOUT -29 /* ssl handshake no response*/ #define ESPCONN_RESP_TIMEOUT -29 /* ssl handshake no response*/
...@@ -127,6 +130,14 @@ enum espconn_level{ ...@@ -127,6 +130,14 @@ enum espconn_level{
ESPCONN_KEEPCNT ESPCONN_KEEPCNT
}; };
enum espconn_mode{
ESPCONN_NOMODE,
ESPCONN_TCPSERVER_MODE,
ESPCONN_TCPCLIENT_MODE,
ESPCONN_UDP_MODE,
ESPCONN_NUM_MODE
};
struct espconn_packet{ struct espconn_packet{
uint16 sent_length; /* sent length successful*/ uint16 sent_length; /* sent length successful*/
uint16 snd_buf_size; /* Available buffer size for sending */ uint16 snd_buf_size; /* Available buffer size for sending */
...@@ -169,6 +180,7 @@ typedef struct _espconn_msg{ ...@@ -169,6 +180,7 @@ typedef struct _espconn_msg{
struct espconn *pespconn; struct espconn *pespconn;
comon_pkt pcommon; comon_pkt pcommon;
uint8 count_opt; uint8 count_opt;
uint8 espconn_mode;
sint16_t hs_status; //the status of the handshake sint16_t hs_status; //the status of the handshake
void *preverse; void *preverse;
void *pssl; void *pssl;
...@@ -177,6 +189,8 @@ typedef struct _espconn_msg{ ...@@ -177,6 +189,8 @@ typedef struct _espconn_msg{
//***********Code for WIFI_BLOCK from upper************** //***********Code for WIFI_BLOCK from upper**************
uint8 recv_hold_flag; uint8 recv_hold_flag;
uint16 recv_holded_buf_Len; uint16 recv_holded_buf_Len;
//*******************************************************
ringbuf *readbuf;
}espconn_msg; }espconn_msg;
#ifndef _MDNS_INFO #ifndef _MDNS_INFO
......
/*
* ringbuf.h
*
* Created on: Apr 22, 2016
* Author: liuhan
*/
#ifndef _ESPCONN_BUF_H_
#define _ESPCONN_BUF_H_
/*
* ringbuffer.c
*
* Created on: Apr 22, 2016
* Author: liuhan
*/
#include "c_types.h"
#include "ets_sys.h"
#include "os_type.h"
typedef struct ringbuf_t {
uint8_t *buf;
uint8_t *head, *tail;
size_t size;
} ringbuf, *ringbuf_t;
ringbuf_t ringbuf_new(size_t capacity);
size_t ringbuf_buffer_size(const struct ringbuf_t *rb);
void ringbuf_reset(ringbuf_t rb);
void ringbuf_free(ringbuf_t *rb);
size_t ringbuf_capacity(const struct ringbuf_t *rb);
size_t ringbuf_bytes_free(const struct ringbuf_t *rb);
size_t ringbuf_bytes_used(const struct ringbuf_t *rb);
int ringbuf_is_full(const struct ringbuf_t *rb);
int ringbuf_is_empty(const struct ringbuf_t *rb);
const void* ringbuf_tail(const struct ringbuf_t *rb);
const void* ringbuf_head(const struct ringbuf_t *rb);
static uint8_t *ringbuf_nextp(ringbuf_t rb, const uint8_t *p);
size_t ringbuf_findchr(const struct ringbuf_t *rb, int c, size_t offset);
size_t ringbuf_memset(ringbuf_t dst, int c, size_t len);
void *ringbuf_memcpy_into(ringbuf_t dst, const void *src, size_t count);
void *ringbuf_memcpy_from(void *dst, ringbuf_t src, size_t count);
#endif /* RINGBUF_H_ */
/*
* time.h
*
* Created on: May 31, 2016
* Author: liuhan
*/
#ifndef TIME_H_
#define TIME_H_
#include "osapi.h"
#include "os_type.h"
#include "lwip/sntp.h"
struct timeval {
unsigned long tv_sec; /* seconds */
unsigned long tv_usec; /* and microseconds */
};
/***************************RTC TIME OPTION***************************************/
// daylight settings
// Base calculated with value obtained from NTP server (64 bits)
#define sntp_base (*((uint64_t*)RTC_STORE0))
// Timer value when base was obtained
#define TIM_REF_SET(value) WRITE_PERI_REG(RTC_STORE2, value)
#define TIM_REF_GET() READ_PERI_REG(RTC_STORE2)
// Setters and getters for CAL, TZ and DST.
#define RTC_CAL_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= ((val) & 0x0000FFFF);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_DST_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<16) & 0x00010000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_TZ_SET(val) do {uint32 value = READ_PERI_REG(RTC_STORE3);\
value |= (((val)<<24) & 0xFF000000);\
WRITE_PERI_REG(RTC_STORE3, value);\
}while(0)
#define RTC_CAL_GET() (READ_PERI_REG(RTC_STORE3) & 0x0000FFFF)
#define RTC_DST_GET() ((READ_PERI_REG(RTC_STORE3) & 0x00010000)>>16)
#define RTC_TZ_GET() ((((int)READ_PERI_REG(RTC_STORE3)) & ((int)0xFF000000))>>24)
void system_update_rtc(time_t t, uint32_t us);
time_t sntp_get_rtc_time(sint32_t *us);
int gettimeofday(struct timeval* t, void* timezone);
void updateTime(uint32 ms);
bool configTime(int timezone, int daylightOffset, char *server1, char *server2, char *server3, bool enable);
time_t time(time_t *t);
unsigned long millis(void);
unsigned long micros(void);
#endif /* TIME_H_ */
...@@ -32,8 +32,8 @@ ...@@ -32,8 +32,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
#ifndef __LWIP_DNS_H__ #ifndef __LWIP_MDNS_H__
#define __LWIP_DNS_H__ #define __LWIP_MDNS_H__
#include "lwip/opt.h" #include "lwip/opt.h"
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
extern "C" { extern "C" {
#endif #endif
typedef long time_t;
/** The maximum number of SNTP servers that can be set */ /** The maximum number of SNTP servers that can be set */
#ifndef SNTP_MAX_SERVERS #ifndef SNTP_MAX_SERVERS
#define SNTP_MAX_SERVERS 3 #define SNTP_MAX_SERVERS 3
...@@ -24,6 +26,8 @@ extern "C" { ...@@ -24,6 +26,8 @@ extern "C" {
#define SNTP_SERVER_DNS 1 #define SNTP_SERVER_DNS 1
#endif #endif
bool sntp_get_timetype(void);
void sntp_set_receive_time_size(void);
/** One server address/name can be defined as default if SNTP_SERVER_DNS == 1: /** One server address/name can be defined as default if SNTP_SERVER_DNS == 1:
* #define SNTP_SERVER_ADDRESS "pool.ntp.org" * #define SNTP_SERVER_ADDRESS "pool.ntp.org"
*/ */
......
...@@ -899,14 +899,6 @@ ...@@ -899,14 +899,6 @@
#define TCP_TTL (IP_DEFAULT_TTL) #define TCP_TTL (IP_DEFAULT_TTL)
#endif #endif
/**
* TCP_WND: The size of a TCP window. This must be at least
* (2 * TCP_MSS) for things to work well
*/
#ifndef TCP_WND
#define TCP_WND (*(volatile uint32*)0x600011F0)
#endif
/** /**
* TCP_MAXRTX: Maximum number of retransmissions of data segments. * TCP_MAXRTX: Maximum number of retransmissions of data segments.
*/ */
...@@ -956,6 +948,14 @@ ...@@ -956,6 +948,14 @@
#endif #endif
#endif #endif
/**
* TCP_WND: The size of a TCP window. This must be at least
* (2 * TCP_MSS) for things to work well
*/
#ifndef TCP_WND
#define TCP_WND (*(volatile uint32*)0x600011F0)
#endif
/** /**
* TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really * TCP_CALCULATE_EFF_SEND_MSS: "The maximum size of a segment that TCP really
* sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which * sends, the 'effective send MSS,' MUST be the smaller of the send MSS (which
......
/**
* \file aes.h
*
* \brief AES block cipher
*
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This file is part of mbed TLS (https://tls.mbed.org)
*/
#ifndef MBEDTLS_AES_H
#define MBEDTLS_AES_H
#if !defined(MBEDTLS_CONFIG_FILE)
#include "config.h"
#else
#include MBEDTLS_CONFIG_FILE
#endif
#include <stddef.h>
#include <stdint.h>
/* padlock.c and aesni.c rely on these values! */
#define MBEDTLS_AES_ENCRYPT 1
#define MBEDTLS_AES_DECRYPT 0
#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020 /**< Invalid key length. */
#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022 /**< Invalid data input length. */
#if !defined(MBEDTLS_AES_ALT)
// Regular implementation
//
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief AES context structure
*
* \note buf is able to hold 32 extra bytes, which can be used:
* - for alignment purposes if VIA padlock is used, and/or
* - to simplify key expansion in the 256-bit case by
* generating an extra round key
*/
typedef struct
{
int nr; /*!< number of rounds */
uint32_t *rk; /*!< AES round keys */
uint32_t buf[68]; /*!< unaligned data */
}
mbedtls_aes_context;
/**
* \brief Initialize AES context
*
* \param ctx AES context to be initialized
*/
void mbedtls_aes_init( mbedtls_aes_context *ctx );
/**
* \brief Clear AES context
*
* \param ctx AES context to be cleared
*/
void mbedtls_aes_free( mbedtls_aes_context *ctx );
/**
* \brief AES key schedule (encryption)
*
* \param ctx AES context to be initialized
* \param key encryption key
* \param keybits must be 128, 192 or 256
*
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
*/
int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits );
/**
* \brief AES key schedule (decryption)
*
* \param ctx AES context to be initialized
* \param key decryption key
* \param keybits must be 128, 192 or 256
*
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_KEY_LENGTH
*/
int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
unsigned int keybits );
/**
* \brief AES-ECB block encryption/decryption
*
* \param ctx AES context
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
* \param input 16-byte input block
* \param output 16-byte output block
*
* \return 0 if successful
*/
int mbedtls_aes_crypt_ecb( mbedtls_aes_context *ctx,
int mode,
const unsigned char input[16],
unsigned char output[16] );
#if defined(MBEDTLS_CIPHER_MODE_CBC)
/**
* \brief AES-CBC buffer encryption/decryption
* Length should be a multiple of the block
* size (16 bytes)
*
* \note Upon exit, the content of the IV is updated so that you can
* call the function same function again on the following
* block(s) of data and get the same result as if it was
* encrypted in one call. This allows a "streaming" usage.
* If on the other hand you need to retain the contents of the
* IV, you should either save it manually or use the cipher
* module instead.
*
* \param ctx AES context
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
* \param length length of the input data
* \param iv initialization vector (updated after use)
* \param input buffer holding the input data
* \param output buffer holding the output data
*
* \return 0 if successful, or MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH
*/
int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
int mode,
size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
#endif /* MBEDTLS_CIPHER_MODE_CBC */
#if defined(MBEDTLS_CIPHER_MODE_CFB)
/**
* \brief AES-CFB128 buffer encryption/decryption.
*
* Note: Due to the nature of CFB you should use the same key schedule for
* both encryption and decryption. So a context initialized with
* mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
*
* \note Upon exit, the content of the IV is updated so that you can
* call the function same function again on the following
* block(s) of data and get the same result as if it was
* encrypted in one call. This allows a "streaming" usage.
* If on the other hand you need to retain the contents of the
* IV, you should either save it manually or use the cipher
* module instead.
*
* \param ctx AES context
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
* \param length length of the input data
* \param iv_off offset in IV (updated after use)
* \param iv initialization vector (updated after use)
* \param input buffer holding the input data
* \param output buffer holding the output data
*
* \return 0 if successful
*/
int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
int mode,
size_t length,
size_t *iv_off,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
/**
* \brief AES-CFB8 buffer encryption/decryption.
*
* Note: Due to the nature of CFB you should use the same key schedule for
* both encryption and decryption. So a context initialized with
* mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
*
* \note Upon exit, the content of the IV is updated so that you can
* call the function same function again on the following
* block(s) of data and get the same result as if it was
* encrypted in one call. This allows a "streaming" usage.
* If on the other hand you need to retain the contents of the
* IV, you should either save it manually or use the cipher
* module instead.
*
* \param ctx AES context
* \param mode MBEDTLS_AES_ENCRYPT or MBEDTLS_AES_DECRYPT
* \param length length of the input data
* \param iv initialization vector (updated after use)
* \param input buffer holding the input data
* \param output buffer holding the output data
*
* \return 0 if successful
*/
int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
int mode,
size_t length,
unsigned char iv[16],
const unsigned char *input,
unsigned char *output );
#endif /*MBEDTLS_CIPHER_MODE_CFB */
#if defined(MBEDTLS_CIPHER_MODE_CTR)
/**
* \brief AES-CTR buffer encryption/decryption
*
* Warning: You have to keep the maximum use of your counter in mind!
*
* Note: Due to the nature of CTR you should use the same key schedule for
* both encryption and decryption. So a context initialized with
* mbedtls_aes_setkey_enc() for both MBEDTLS_AES_ENCRYPT and MBEDTLS_AES_DECRYPT.
*
* \param ctx AES context
* \param length The length of the data
* \param nc_off The offset in the current stream_block (for resuming
* within current cipher stream). The offset pointer to
* should be 0 at the start of a stream.
* \param nonce_counter The 128-bit nonce and counter.
* \param stream_block The saved stream-block for resuming. Is overwritten
* by the function.
* \param input The input data stream
* \param output The output data stream
*
* \return 0 if successful
*/
int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
size_t length,
size_t *nc_off,
unsigned char nonce_counter[16],
unsigned char stream_block[16],
const unsigned char *input,
unsigned char *output );
#endif /* MBEDTLS_CIPHER_MODE_CTR */
/**
* \brief Internal AES block encryption function
* (Only exposed to allow overriding it,
* see MBEDTLS_AES_ENCRYPT_ALT)
*
* \param ctx AES context
* \param input Plaintext block
* \param output Output (ciphertext) block
*/
void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
const unsigned char input[16],
unsigned char output[16] );
/**
* \brief Internal AES block decryption function
* (Only exposed to allow overriding it,
* see MBEDTLS_AES_DECRYPT_ALT)
*
* \param ctx AES context
* \param input Ciphertext block
* \param output Output (plaintext) block
*/
void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
const unsigned char input[16],
unsigned char output[16] );
#ifdef __cplusplus
}
#endif
#else /* MBEDTLS_AES_ALT */
#include "aes_alt.h"
#endif /* MBEDTLS_AES_ALT */
#ifdef __cplusplus
extern "C" {
#endif
/**
* \brief Checkup routine
*
* \return 0 if successful, or 1 if the test failed
*/
int mbedtls_aes_self_test( int verbose );
#ifdef __cplusplus
}
#endif
#endif /* aes.h */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment