Real2Virtual202111

٤Ƴ٤Ĥ
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
-
|
|
|
|
!
 
 
 
 
 
-
!
 
 
-
!
 
-
|
|
|
|
!
 
 
-
!
-
|
|
|
|
|
|
-
!
-
!
|
|
|
|
|
|
|
|
|
!
 
-
|
|
-
|
|
-
-
|
|
|
|
-
|
-
|
-
|
-
|
!
-
|
!
!
-
|
|
|
!
-
|
|
|
!
!
-
!
|
!
!
 
/*
  m5atom-wifi-ex03 by Takashi Yamanoue,
  Based on the WiFiAccessPoint.ino
  Created for arduino-esp32 on 04 July, 2018
  by Elochukwu Ifediora (fedy0)
*/
 
#include <WiFi.h>
#include <WiFiClient.h>
#include <WiFiAP.h>
#include "M5Atom.h"
//#include <SoftwareSerial.h>
 
#define LED_BUILTIN 2   // Set the GPIO pin where you connected your test LED or comment this line out if your dev board has a built-in LED
 
// Set these to your desired credentials.
const char *ssid = "YAMA-ATOM5-EX01";
const char *password = "12345678";
/*
IPAddress ip(192,168,4,2);
IPAddress gateway(192,168,4,1);
IPAddress subnet(255,255,255,0);
IPAddress DNS(192,168,4,1);
*/
WiFiServer server(23);
 
//Serial1 mySerial(22,19);  //rx, tx
 
void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
 
  Serial.begin(115200);
  Serial.println();
  Serial.println("Configuring access point...");
 
//  WiFi.config(ip,gateway,subnet,DNS);
 
  // You can remove the password parameter if you want the AP to be open.
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.begin();
 
  Serial.println("Server started");
 
  Serial2.begin(9600,SERIAL_8N1,22,19);
  Serial2.println("Server started, serial1");
}
 
void loop() {
  WiFiClient client = server.available();   // listen for incoming clients
 
  if (client) {                             // if you get a client,
    Serial.println("New Client.");           // print a message out the serial port
    String currentLine = "";                // make a String to hold incoming data from the client
    while (client.connected()) {            // loop while the client's connected
      if (client.available()) {             // if there's bytes to read from the client,
        char c = client.read();             // read a byte, then
        Serial.write(c);                    // print it out the serial monitor
        Serial2.write(c);
        
        if (c == '\n') {                    // if the byte is a newline character
 
          // if the current line is blank, you got two newline characters in a row.
          // that's the end of the client HTTP request, so send a response:
          if (currentLine.length() == 0) {
            
          } else {    // if you got a newline, then clear currentLine:
            currentLine = "";
          }
        } else if (c != '\r') {  // if you got anything else but a carriage return character,
          currentLine += c;      // add it to the end of the currentLine
        }
      }
      if(Serial.available()){
        char c= Serial.read();
        Serial2.write(c);
        client.write(c);
      }
      if(Serial2.available()){
        char c=Serial2.read();
        Serial.write(c);
        client.write(c);
      }
    }
    // close the connection:
    client.stop();
    Serial.println("Client Disconnected.");
  }
}
 

Counter: 101, today: 1, yesterday: 0

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2021-12-06 (月) 13:18:23 (871d)