정보나눔

오픈소스하드웨어 프로젝트에 대한 다양한 정보를 나누는 공간입니다.

오렌지보드 wifi 통신
휴통신 | 2017-12-12

wifiz250통신이 되긴 하지만 1초 연결후 바로 끊기는 상황이 생겨서 데이터를 지속적으로 받아오지 못합니다. 이게 헤더파일 문제인지 코드상의 문제인지 어떤게 잘못된지 모르겠습니다ㅠ

통신이 안되서 구현이 안됩니다. 확인 부탁드리겠습니다

 

 

#include <SPI.h>
#include "WizFi250.h"

char ssid[] = "AndroidHotspot7725";         // your network SSID (name)
char pass[] = "20150521";        // your network password
int status = WL_IDLE_STATUS;     // the Wifi radio's status
int reqCount = 0;                // number of requests received

WiFiServer server(35);

// use a ring buffer to increase speed and reduce memory allocation
WizFiRingBuffer buf(100);

void printWifiStatus();
void sendHttpResponse(WiFiClient client);

void setup()
{
  Serial.begin(115200);   // initialize serial for debugging
  WiFi.init();

  // check for the presence of the shield
  if (WiFi.status() == WL_NO_SHIELD) {
    Serial.println("WiFi shield not present");
    while (true); // don't continue
  }

  Serial.print("Attempting to start AP ");
  Serial.println(ssid);

  // uncomment these two lines if you want to set the IP address of the AP
  //IPAddress localIp(192, 168, 111, 111);
  //WiFi.configAP(localIp);

  // start access point
  status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);

  Serial.println("Access point started");
  printWifiStatus();

  // start the web server on port 80
  server.begin();
  Serial.println("Server started");
}


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
    buf.init();                               // initialize the circular buffer
    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
        buf.push(c);                          // push it to the ring buffer

        Serial.write(c);
        // you got two newline characters in a row
        // that's the end of the HTTP request, so send a response

        if (buf.endsWith("\r\n\r\n")) {
          sendHttpResponse(client);
          break;
        }
      }
    }

    // give the web browser time to receive the data
    delay(10);

    // close the connection
    client.stop();
    Serial.println("Client disconnected");
  }
}

void sendHttpResponse(WiFiClient client)
{
  client.print("OrangeBoard WiFi APmode Test!!");
}

void printWifiStatus()
{
  // print your WiFi shield's IP address
  IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print where to go in the browser
  Serial.println();
  Serial.print("To see this page in action, connect to ");
  Serial.print(ssid);
  Serial.print(" and open a browser to http://");
  Serial.println(ip);
  Serial.println();
}

이전글   |    앱인벤터 아두이노 온습도 센서 결과값 출력 ... 2017-12-12
다음글   |    오렌지보드BLE 블루투스 사용방법좀요 ㅠ 2017-12-12