start:arduino:minitel:programme
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| start:arduino:minitel:programme [2022/07/25 18:06] – gerardadmin | start:arduino:minitel:programme [2023/01/27 16:08] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 15: | Ligne 15: | ||
| *prise Arduino GND sur 2 minitel (Masse) | *prise Arduino GND sur 2 minitel (Masse) | ||
| - | ==== ESP32-Minitel Demo==== | + | ==== Minitel Demo==== |
| - | <code c ESP32_Minitel-Demo.ino> | + | == Minitel-Esp32 Test Laison serie entre minitel et terminal arduino ou esp32=== |
| + | <code c ESP32_Minitel-Demo000.ino> | ||
| + | // OK apres test | ||
| + | |||
| + | void setup() { | ||
| + | Serial.begin(115200); | ||
| + | Serial2.begin(1200, | ||
| + | } | ||
| + | |||
| + | |||
| + | void loop() { | ||
| + | // redirection debug -> minitel | ||
| + | while (Serial.available() > 0) { | ||
| + | Serial2.write(Serial.read()); | ||
| + | } | ||
| + | // redirection minitel -> debug | ||
| + | while (Serial2.available() > 0) { | ||
| + | Serial.write(Serial2.read()); | ||
| + | } | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | == Minitel-ESP32 Test differant affichage== | ||
| + | |||
| + | <code c ESP32_Minitel-Demo001.ino> | ||
| // Code OK apres test | // Code OK apres test | ||
| //////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////// | ||
| Ligne 266: | Ligne 290: | ||
| <code c Esp32-Minitel_Pong.ino> | <code c Esp32-Minitel_Pong.ino> | ||
| + | |||
| + | //Programme OK | ||
| + | |||
| #include < | #include < | ||
| Ligne 966: | Ligne 993: | ||
| - | // programme | + | // programme |
| #include < | #include < | ||
| Ligne 1520: | Ligne 1547: | ||
| } | } | ||
| else return 0; | else return 0; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | === Minitel-ESP32 Demo Teaser === | ||
| + | |||
| + | <code c Minitel-ESP32-DEMO_TEASER.ino> | ||
| + | //Faire Reset de l' | ||
| + | |||
| + | /* | ||
| + | * Sample code for connexion to minitel videotex server via websocket | ||
| + | * Requirements: | ||
| + | | ||
| + | * created by iodeo - dec 2021 | ||
| + | */ | ||
| + | |||
| + | #include < | ||
| + | #include < | ||
| + | #include < | ||
| + | |||
| + | // --------------------------------------- | ||
| + | // ------ Minitel port configuration | ||
| + | |||
| + | #define MINITEL_PORT Serial2 | ||
| + | #define MINITEL_BAUD 4800 // 1200 / 4800 / 9600 depending on minitel type | ||
| + | #define MINITEL_DISABLE_ECHO true // true if characters are repeated when typing | ||
| + | |||
| + | // --------------------------------------- | ||
| + | // ------ Debug port configuration | ||
| + | |||
| + | #define DEBUG true | ||
| + | |||
| + | #if DEBUG | ||
| + | #define DEBUG_PORT Serial | ||
| + | #define DEBUG_BAUD 115200 | ||
| + | #define debugBegin(x) | ||
| + | #define debugPrintf(...) | ||
| + | #else // Empty macro functions | ||
| + | #define debugBegin(x) | ||
| + | #define debugPrintf(...) | ||
| + | #endif | ||
| + | |||
| + | // --------------------------------------- | ||
| + | // ------ WiFi credentials | ||
| + | |||
| + | const char* ssid = " | ||
| + | const char* password = " | ||
| + | |||
| + | // --------------------------------------- | ||
| + | // ------ Websocket server | ||
| + | |||
| + | / | ||
| + | *//* | ||
| + | // ws:// | ||
| + | char* host = " | ||
| + | int port = 9001; | ||
| + | char* path = "/"; | ||
| + | bool ssl = false; | ||
| + | int ping_ms = 0; | ||
| + | char* protocol = ""; | ||
| + | /**/ | ||
| + | |||
| + | /****** 3615 ----------------- | ||
| + | // wss:// | ||
| + | char* host = " | ||
| + | int port = 80; | ||
| + | char* path = "/ | ||
| + | bool ssl = false; | ||
| + | int ping_ms = 0; | ||
| + | char* protocol = ""; | ||
| + | /**/ | ||
| + | |||
| + | /****** AE ------------------- | ||
| + | // ws:// | ||
| + | // websocket payload length of 0 | ||
| + | char* host = " | ||
| + | int port = 80; | ||
| + | char* path = "/ | ||
| + | bool ssl = false; | ||
| + | int ping_ms = 0; | ||
| + | char* protocol = ""; | ||
| + | /**/ | ||
| + | |||
| + | / | ||
| + | // ws:// | ||
| + | // websocket payload length up to 873 | ||
| + | char* host = " | ||
| + | int port = 2018; | ||
| + | char* path = "/? | ||
| + | bool ssl = false; | ||
| + | int ping_ms = 0; | ||
| + | char* protocol = ""; | ||
| + | /**/ | ||
| + | |||
| + | /****** TEASER | ||
| + | // ws:// | ||
| + | char* host = " | ||
| + | int port = 8080; | ||
| + | char* path = "/ | ||
| + | bool ssl = false; | ||
| + | int ping_ms = 10000; | ||
| + | char* protocol = " | ||
| + | /**/ | ||
| + | |||
| + | /****** SM ------------------- | ||
| + | // wss:// | ||
| + | // websocket payload length up to 128 | ||
| + | char* host = " | ||
| + | int port = 9991; | ||
| + | char* path = "/? | ||
| + | bool ssl = true; | ||
| + | int ping_ms = 0; | ||
| + | char* protocol = ""; | ||
| + | /**/ | ||
| + | |||
| + | WiFiClient client; | ||
| + | WebSocketsClient webSocket; | ||
| + | Minitel minitel(MINITEL_PORT); | ||
| + | |||
| + | void setup() { | ||
| + | |||
| + | debugBegin(DEBUG_BAUD); | ||
| + | debugPrintf(" | ||
| + | debugPrintf(" | ||
| + | |||
| + | // We initiate minitel communication | ||
| + | debugPrintf(" | ||
| + | int baud = minitel.searchSpeed(); | ||
| + | if (baud != MINITEL_BAUD) baud = minitel.changeSpeed(MINITEL_BAUD); | ||
| + | debugPrintf(" | ||
| + | if (MINITEL_DISABLE_ECHO) { | ||
| + | minitel.echo(false); | ||
| + | debugPrintf(" | ||
| + | } | ||
| + | |||
| + | // We connect to WiFi network | ||
| + | debugPrintf(" | ||
| + | debugPrintf(" | ||
| + | WiFi.begin(ssid, | ||
| + | while (WiFi.status() != WL_CONNECTED) { | ||
| + | delay(500); | ||
| + | debugPrintf(" | ||
| + | } | ||
| + | debugPrintf(" | ||
| + | |||
| + | // We connect to Websocket server | ||
| + | debugPrintf(" | ||
| + | if (protocol[0] == ' | ||
| + | if (ssl) webSocket.beginSSL(host, | ||
| + | else webSocket.begin(host, | ||
| + | } | ||
| + | else { | ||
| + | debugPrintf(" | ||
| + | if (ssl) webSocket.beginSSL(host, | ||
| + | else webSocket.begin(host, | ||
| + | } | ||
| + | | ||
| + | webSocket.onEvent(webSocketEvent); | ||
| + | | ||
| + | if (ping_ms != 0) { | ||
| + | debugPrintf(" | ||
| + | // start heartbeat (optional) | ||
| + | // ping server every ping_ms | ||
| + | // expect pong from server within 3000 ms | ||
| + | // consider connection disconnected if pong is not received 2 times | ||
| + | webSocket.enableHeartbeat(ping_ms, | ||
| + | } | ||
| + | |||
| + | debugPrintf(" | ||
| + | |||
| + | } | ||
| + | |||
| + | void loop() { | ||
| + | |||
| + | // Websocket -> Minitel | ||
| + | webSocket.loop(); | ||
| + | |||
| + | // Minitel -> Websocket | ||
| + | uint32_t key = minitel.getKeyCode(false); | ||
| + | if (key != 0) { | ||
| + | debugPrintf(" | ||
| + | // prepare data to send over websocket | ||
| + | uint8_t payload[4]; | ||
| + | size_t len = 0; | ||
| + | for (len = 0; key != 0 && len < 4; len++) { | ||
| + | payload[3-len] = uint8_t(key); | ||
| + | key = key >> 8; | ||
| + | } | ||
| + | webSocket.sendTXT(payload+4-len, | ||
| + | } | ||
| + | |||
| + | } | ||
| + | |||
| + | void webSocketEvent(WStype_t type, uint8_t * payload, size_t len) { | ||
| + | switch(type) { | ||
| + | case WStype_DISCONNECTED: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_CONNECTED: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_TEXT: | ||
| + | debugPrintf(" | ||
| + | if (len > 0) { | ||
| + | debugPrintf(" | ||
| + | for (size_t i = 0; i < len; i++) { | ||
| + | minitel.writeByte(payload[i]); | ||
| + | } | ||
| + | } | ||
| + | break; | ||
| + | | ||
| + | case WStype_BIN: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_ERROR: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_FRAGMENT_TEXT_START: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_FRAGMENT_BIN_START: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_FRAGMENT: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | | ||
| + | case WStype_FRAGMENT_FIN: | ||
| + | debugPrintf(" | ||
| + | break; | ||
| + | } | ||
| } | } | ||
| </ | </ | ||
/home/chanteri/www/fablab37110/data/attic/start/arduino/minitel/programme.1658765210.txt.gz · Dernière modification : (modification externe)
