-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Examples: add HTTPS and SMTPS examples (#28)
- Loading branch information
Showing
79 changed files
with
10,986 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/*------------------------------------------------------------------------------ | ||
* MDK Middleware - Component ::Network | ||
* Copyright (c) 2004-2024 Arm Limited (or its affiliates). All rights reserved. | ||
*------------------------------------------------------------------------------ | ||
* Name: HTTP_Server.c | ||
* Purpose: HTTP Server example | ||
*----------------------------------------------------------------------------*/ | ||
|
||
#include <stdio.h> | ||
|
||
#include "main.h" | ||
|
||
#include "cmsis_os2.h" // ::CMSIS:RTOS2 | ||
#include "cmsis_vio.h" // ::CMSIS Driver:VIO | ||
|
||
#include "rl_net.h" // Keil::Network&MDK:CORE | ||
|
||
bool LEDrun; | ||
|
||
static uint32_t analog_val; | ||
|
||
/* Thread declarations */ | ||
static void BlinkLed (void *argument); | ||
|
||
/* Read analog inputs */ | ||
int32_t analog_in (uint32_t ch) { | ||
int32_t val = 0; | ||
|
||
if (ch == 0) { | ||
val = analog_val & 0x3FF; | ||
} | ||
return (val); | ||
} | ||
|
||
/* IP address change notification */ | ||
void netDHCP_Notify (uint32_t if_id, uint8_t option, const uint8_t *val, uint32_t len) { | ||
char ip_ascii[16]; | ||
(void)len; | ||
|
||
if ((if_id == (NET_IF_CLASS_ETH | 0)) && (option == NET_DHCP_OPTION_IP_ADDRESS)) { | ||
netIP_ntoa (NET_ADDR_IP4, val, ip_ascii, sizeof(ip_ascii)); | ||
printf("IP4: %s\n",ip_ascii); | ||
} | ||
} | ||
|
||
/*----------------------------------------------------------------------------- | ||
Thread 'BlinkLed': Blink the LEDs on an eval board | ||
*----------------------------------------------------------------------------*/ | ||
static __NO_RETURN void BlinkLed (void *argument) { | ||
(void)argument; | ||
|
||
LEDrun = true; | ||
while(1) { | ||
if (LEDrun == true) { | ||
// Blink LED 0 | ||
vioSetSignal(vioLED0, vioLEDon); | ||
osDelay(100U); | ||
vioSetSignal(vioLED0, vioLEDoff); | ||
osDelay(400U); | ||
} | ||
osDelay(500U); | ||
analog_val += 10; | ||
} | ||
} | ||
|
||
/*----------------------------------------------------------------------------- | ||
Application Main Thread 'app_main_thread': Run Network | ||
*----------------------------------------------------------------------------*/ | ||
__NO_RETURN void app_main_thread (void *argument) { | ||
uint8_t ip_addr[NET_ADDR_IP6_LEN]; | ||
char ip_ascii[40]; | ||
(void)argument; | ||
|
||
printf("Network HTTP Server example\n"); | ||
|
||
netInitialize (); | ||
|
||
osThreadNew(BlinkLed, NULL, NULL); | ||
|
||
printf("IP4: Waiting for DHCP\n"); | ||
if (netIF_GetOption(NET_IF_CLASS_ETH | 0, | ||
netIF_OptionIP6_LinkLocalAddress, | ||
ip_addr, sizeof(ip_addr)) == netOK) { | ||
/* IPv6 enabled on ETH0, print Link-local address */ | ||
netIP_ntoa(NET_ADDR_IP6, ip_addr, ip_ascii, sizeof(ip_ascii)); | ||
printf("IP6: %s\n", ip_ascii); | ||
} | ||
|
||
osThreadExit(); | ||
} | ||
|
||
/*----------------------------------------------------------------------------- | ||
* Application main function | ||
*----------------------------------------------------------------------------*/ | ||
int app_main (void) { | ||
osKernelInitialize(); | ||
osThreadNew(app_main_thread, NULL, NULL); | ||
osKernelStart(); | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
project: | ||
description: HTTPS Web Server example | ||
|
||
packs: | ||
- pack: Keil::MDK-Middleware@>=8.0.0-0 | ||
- pack: ARM::CMSIS@>=6.1.0 | ||
- pack: ARM::CMSIS-RTX@>=5.9.0 | ||
- pack: ARM::mbedTLS@>=3.6.0 | ||
|
||
connections: | ||
- connect: HTTPS Server | ||
provides: | ||
- CMSIS-RTOS2 | ||
consumes: | ||
- CMSIS_ETH | ||
- CMSIS_VIO | ||
- STDOUT | ||
|
||
groups: | ||
- group: Documentation | ||
files: | ||
- file: README.md | ||
- group: Network | ||
files: | ||
- file: HTTPS_Server.c | ||
- file: HTTPS_Server_CGI.c | ||
- file: Web/Web.c | ||
# - group: Web files | ||
# files: | ||
# - file: Web/index.htm | ||
# - file: Web/pg_header.inc | ||
# - file: Web/pg_footer.inc | ||
# - file: Web/ad.cgi | ||
# - file: Web/ad.cgx | ||
# - file: Web/buttons.cgi | ||
# - file: Web/buttons.cgx | ||
# - file: Web/language.cgi | ||
# - file: Web/lcd.cgi | ||
# - file: Web/leds.cgi | ||
# - file: Web/network.cgi | ||
# - file: Web/system.cgi | ||
# - file: Web/tcp.cgi | ||
# - file: Web/xml_http.js | ||
# - file: Web/home.png | ||
# - file: Web/keil.gif | ||
# - file: Web/arm.png | ||
# - file: Web/llblue.jpg | ||
# - file: Web/pabb.gif | ||
|
||
components: | ||
- component: ARM::CMSIS:OS Tick:SysTick | ||
- component: ARM::CMSIS:RTOS2:Keil RTX5&Source | ||
- component: Keil::Network&MDK:CORE | ||
- component: Keil::Network&MDK:Interface:ETH | ||
- component: Keil::Network&MDK:Socket:TCP | ||
- component: Keil::Network&MDK:Socket:UDP | ||
- component: Keil::Network&MDK:Service:Web Server Compact&HTTPS | ||
- component: ARM::Security:mbed TLS | ||
|
||
layers: | ||
- layer: $Board-Layer$ | ||
type: Board |
Oops, something went wrong.