lib_Transmission_TCP_example
Dependencies: lib_Transmission
Revision 0:bfe0a20512f3, committed 2021-10-06
- Comitter:
- YSI
- Date:
- Wed Oct 06 09:20:05 2021 +0000
- Child:
- 1:b9a16f894120
- Commit message:
- up
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Wed Oct 06 09:20:05 2021 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/develop_NaN.json Wed Oct 06 09:20:05 2021 +0000
@@ -0,0 +1,60 @@
+{
+ "GCC_ARM": {
+ "common": ["-Wall", "-Wextra",
+ "-Wno-unused-parameter", "-Wno-missing-field-initializers",
+ "-fmessage-length=0", "-fno-exceptions",
+ "-ffunction-sections", "-fdata-sections", "-funsigned-char",
+ "-MMD",
+ "-fomit-frame-pointer", "-Os", "-g", "-DMBED_TRAP_ERRORS_ENABLED=1"],
+ "asm": ["-c", "-x", "assembler-with-cpp"],
+ "c": ["-c", "-std=gnu11"],
+ "cxx": ["-c", "-std=gnu++14", "-fno-rtti", "-Wvla"],
+ "ld": ["-Wl,--gc-sections", "-Wl,--wrap,main", "-Wl,--wrap,_malloc_r",
+ "-Wl,--wrap,_free_r", "-Wl,--wrap,_realloc_r", "-Wl,--wrap,_memalign_r",
+ "-Wl,--wrap,_calloc_r", "-Wl,--wrap,exit", "-Wl,--wrap,atexit",
+ "-Wl,-n"]
+ },
+ "ARMC6": {
+ "common": ["-c", "--target=arm-arm-none-eabi", "-mthumb", "-Os",
+ "-Wno-armcc-pragma-push-pop", "-Wno-armcc-pragma-anon-unions",
+ "-Wno-reserved-user-defined-literal", "-Wno-deprecated-register",
+ "-DMULADDC_CANNOT_USE_R7", "-fdata-sections",
+ "-fno-exceptions", "-MMD", "-fshort-enums", "-fshort-wchar",
+ "-DMBED_TRAP_ERRORS_ENABLED=1", "-fhonor-nans"],
+ "asm": [],
+ "c": ["-D__ASSERT_MSG", "-std=gnu11"],
+ "cxx": ["-fno-rtti", "-fno-c++-static-destructors", "-std=gnu++14"],
+ "ld": ["--show_full_path", "--legacyalign", "--inline", "--any_contingency",
+ "--keep=os_cb_sections"]
+ },
+ "ARM": {
+ "common": ["-c", "--gnu", "-Ospace", "--split_sections",
+ "--apcs=interwork", "--brief_diagnostics", "--restrict",
+ "--multibyte_chars", "-O3", "-DMBED_TRAP_ERRORS_ENABLED=1"],
+ "asm": [],
+ "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
+ "cxx": ["--cpp11", "--no_rtti", "--no_vla"],
+ "ld": ["--show_full_path", "--any_contingency", "--inline", "--keep=os_cb_sections"]
+ },
+ "uARM": {
+ "common": ["-c", "--gnu", "-Ospace", "--split_sections",
+ "--apcs=interwork", "--brief_diagnostics", "--restrict",
+ "--multibyte_chars", "-O3", "-D__MICROLIB",
+ "--library_type=microlib", "-DMBED_RTOS_SINGLE_THREAD",
+ "-DMBED_TRAP_ERRORS_ENABLED=1"],
+ "asm": [],
+ "c": ["--md", "--no_depend_system_headers", "--c99", "-D__ASSERT_MSG"],
+ "cxx": ["--cpp11", "--no_rtti", "--no_vla"],
+ "ld": ["--inline", "--library_type=microlib"]
+ },
+ "IAR": {
+ "common": [
+ "--no_wrap_diagnostics", "-e",
+ "--diag_suppress=Pa050,Pa084,Pa093,Pa082,Pe540", "-Ohz", "--enable_restrict",
+ "-DMBED_TRAP_ERRORS_ENABLED=1"],
+ "asm": [],
+ "c": ["--vla", "--diag_suppress=Pe546"],
+ "cxx": ["--guard_calls", "--no_static_destruction"],
+ "ld": ["--skip_dynamic_initialization", "--threaded_lib", "--inline"]
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib_Transmission.lib Wed Oct 06 09:20:05 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/YSI/code/lib_Transmission/#24f7e0ddf6f5
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Oct 06 09:20:05 2021 +0000
@@ -0,0 +1,39 @@
+#include "main.h"
+
+int main(void)
+{
+ transmission.ip(true);
+ while(1) Led = transmission.recv();
+}
+
+void ethernet_up(void)
+{
+ transmission.smtp("yannic.simon@u-psud.fr", transmission.ip().c_str(), "CONNECTION", transmission_processing("*IDN?").c_str());
+ char timeLogs[22] = {0};
+ time_t ntpTimeStamp = transmission.ntp();
+ if(ntpTimeStamp > 0) set_time(ntpTimeStamp);
+ strftime(timeLogs, 21, "%F;%T;", localtime(&ntpTimeStamp));
+}
+
+string transmission_processing(string cmd)
+{
+ ostringstream ssend;
+ ssend << fixed;
+ ssend.precision(2);
+ if(cmd.empty());
+ else if(cmd == "*IDN?")
+ ssend << MBED_PROJECT << ", Mbed OS " << MBED_VERSION << ", Version dated, " << __DATE__ << ", " << __TIME__;
+ else if(cmd == "IP?")
+ ssend << "IP(" << transmission.ip() << ")";
+ else if(cmd == "IP:ALL?")
+ ssend << "IP(" << transmission.ip(transmission.ip()) << ")";
+ else if(cmd.find("HEAD /") != string::npos)
+ ssend << transmission.http.RETURN_OK << "Content-Type: text/html; charset=utf-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n";
+ else if(cmd.find("GET / HTTP") != string::npos)
+ ssend << transmission.http.RETURN_OK << "Content-Type: text/html; charset=utf-8\r\nAccess-Control-Allow-Origin: *\r\n\r\n<!DOCTYPE html>\r\n<html>\r\n\t<head>\r\n\t\t<title>" << MBED_PROJECT << "</title>\r\n\t\t<meta http-equiv=refresh content=10>\r\n\t</head>\r\n\t<body style=background-color:dimgray>\r\n\t\t<center>\r\n\t\t\t<h1>" << MBED_PROJECT << "</h1>\r\n\t\t\t<p>" << time(NULL) << "</p>\r\n\t\t</center>\r\n\t</body>\r\n</html>";
+ else if(cmd.find("GET /FAVICON.ICO HTTP") != string::npos)
+ ssend << transmission.http.RETURN_OK << "Content-Type: image/svg+xml\r\nAccess-Control-Allow-Origin: *\r\n\r\n<svg width=\"100%\" height=\"100%\" viewBox=\"0 0 100 100\" style=\"background-color:steelblue\" xmlns=\"http://www.w3.org/2000/svg\"><title>" << MBED_PROJECT << "</title><text x=\"0\" y=\"85\" textLength=\"100\" font-weight=\"bold\" font-size=\"110\" lengthAdjust=\"spacingAndGlyphs\" fill=\"white\" stroke=\"skyblue\">EL</text></svg>";
+ else if(cmd[cmd.size()-1] == '?')
+ ssend << "incorrect requeste [" << cmd << "]";
+ return ssend.str();
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.h Wed Oct 06 09:20:05 2021 +0000 @@ -0,0 +1,18 @@ +#ifndef MAIN_H +#define MAIN_H +#define MBED_PROJECT "Transmission TCP" + +#include "lib_Transmission.h" + +BusOut Led(LED1, LED2, LED3); +#if MBED_MAJOR_VERSION > 5 +UnbufferedSerial pc(USBTX, USBRX, 230400); +#else +Serial pc(USBTX, USBRX, 230400); +#endif +EthernetInterface eth; + +void ethernet_up(void); +string transmission_processing(string); +Transmission transmission(&pc, ð, &transmission_processing, ðernet_up); +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Wed Oct 06 09:20:05 2021 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#b1796dedeb8accde1cbaecf136fab96895e23d81
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_app.json Wed Oct 06 09:20:05 2021 +0000
@@ -0,0 +1,10 @@
+{
+ "target_overrides": {
+ "*": {
+ "target.c_lib": "std",
+ "target.printf_lib": "std",
+ "storage.storage_type":"TDB_INTERNAL",
+ "platform.callback-nontrivial": true
+ }
+ }
+}
\ No newline at end of file
Y SI