정보나눔

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

오렌지보드를 이용한 pushbullet 오류좀 봐주세요 ㅠㅠ
임태양 | 2018-06-19

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

#define DEVICEID      ""

char ssid[] = "MARS2G";       // your network SSID (name)
char pass[] = "marsbest12";        // your network password
int status = WL_IDLE_STATUS;       // the Wifi radio's status

char server[] = "api.pushingbox.com";

unsigned long lastConnectionTime = 0;         // last time you connected to the server, in milliseconds
const unsigned long postingInterval = 5000L; // delay between updates, in milliseconds

boolean getIsConnected = false;

String rcvbuf;

// Initialize the Ethernet client object
WiFiClient client;

void httpRequest();
void printWifiStatus();

void setup()
{
  // initialize serial for debugging
  Serial.begin(115200);
  Serial.println(F("\r\nSerial Init"));
  WiFi.init();

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

  // attempt to connect to WiFi network
  while ( status != WL_CONNECTED) {
    Serial.print("Attempting to connect to WPA SSID: ");
    Serial.println(ssid);
    // Connect to WPA/WPA2 network
    status = WiFi.begin(ssid, pass);
  }

  Serial.println("You're connected to the network");

  printWifiStatus();
  pinMode(2,INPUT);
}

void loop() {
  // if there's incoming data from the net connection send it out the serial port
  // this is for debugging purposes only
  while (client.available()) {
    char c = client.read();
    if ( c != NULL ) {
      if (rcvbuf.length() > 20)
        rcvbuf = "";
      rcvbuf += c;
      Serial.write(c);
    }
  }
  int val = digitalRead(2);
  // if 5 seconds have passed since your last connection,
  // then connect again and send data
  if (millis() - lastConnectionTime > postingInterval) {
    if (val==LOW) {
      httpRequest();
    }
  }
  rcvbuf = "";
}

// this method makes a HTTP connection to the server
void httpRequest() {
  Serial.println();

  // close any connection before send a new request
  // this will free the socket on the WiFi shield
  client.stop();

  // if there's a successful connection
  if (client.connect(server, 80)) {
    Serial.println("Connecting...");

    // send the HTTP PUT request
    client.print(F("GET /pushingbox?devid="));
    client.print(DEVICEID);
    client.print(F(" HTTP/1.1\r\n"));
    client.print(F("Host: api.pushingbox.com\r\n"));
    client.print(F("User-Agent: Arduino\r\n"));
    client.print(F("\r\n\r\n"));

    // note the time that the connection was made
    lastConnectionTime = millis();
    getIsConnected = true;
  }
  else {
    // if you couldn't make a connection
    Serial.println("Connection failed");
    getIsConnected = false;
  }
}

void printWifiStatus() {
  // print the SSID of the network you're attached to
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

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

  // print the received signal strength
  long rssi = WiFi.RSSI();
  Serial.print("Signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
}

 

소스를 이렇게 작성하면

 

 

[WizFi250] >>> TIMEOUT >>>
[WizFi250] >>> TIMEOUT >>>
[WizFi250] >>> TIMEOUT >>>
[WizFi250] Connecting to api.pushingbox.com
[WizFi250] >>> TIMEOUT >>>
Connection failed
⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮
[WizFi250] >>> TIMEOUT >>>
[WizFi250] >>> TIMEOUT >>>
[WizFi250] Connecting to api.pushingbox.com
[WizFi250] >>> TIMEOUT >>>
Connection failed
AT+FDNS=api.pushingbox.com,3000
[ERROR]

 

이 오류가 나는데 뭐가 문제인건가요 ㅠㅠ?

 

 

프로필사진

수박쨈 2018-06-21 16:37:30

위 에러는 지금 푸싱박스 서버에 접속이 불가능할 때 뜨는 에러입니다.

 

위 코드에서 지금 보시면 #define DEVICEID      "" 디바이스ID의 define이 공란( "" )으로 되어있습니다.

 

현재 푸싱박스에 접속이 불가능하다고 에러가 발생하다고 발생하는 원인입니다.

 

 

제가 올린 글을 잘 안보셨는지, 아니면 중간에 놓치신거 같은지 이유는 모르지만 아래와 같은 부분이 있습니다.

 

한번 다시 확인해보세요~~

 

프로필사진

수박쨈 2018-06-21 16:38:44

    client.print(F("GET /pushingbox?devid="));
    client.print(DEVICEID);

 

위 코드에 있는 부분과 같이 서버에 요청하기 위해서는 DEVICEID가 꼭 필요합니다.

이전글   |    시리얼 모니터에 출력한 값을 다시 읽어오기... 2018-06-19
다음글   |    여러개의 마그네틱 도어 센서 값 읽기 2018-06-21