정보나눔

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

wizfi310 mac주소 질문
케이 | 2017-04-17

#include "WizFi310.h"

char ssid[] = "";    // your network SSID (name)
char pass[] = "";          // your network password
int status = WL_IDLE_STATUS;       // the Wifi radio's status
byte mac[6];  
char server[] = "arduino.cc";

// Initialize the Ethernet client object
WiFiClient client;

void printWifiStatus();

void setup()
{
    Serial.begin(115200);
    Serial3.begin(115200);
    WiFi.init(&Serial3);

    // check for the presence of the shield
    if (WiFi.status() == WL_NO_SHIELD) {
        Serial.println("WiFi shield not present");
        //SerialUSB.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);
    }

    // you're connected now, so print out the data
    Serial.println("You're connected to the network");
    
    printWifiStatus();
    
    Serial.println();
    Serial.println("Starting connection to server...");
    
    // if you get a connection, report back via serial
    if (client.connect(server, 80)) {
        Serial.println("Connected to server");
        // Make a HTTP request
        client.println("GET /asciilogo.txt HTTP/1.1");
        client.println("Host: arduino.cc");
        client.println("Connection: close");
        client.println();
    }
}

void loop()
{
    // if there are incoming bytes available
    // from the server, read them and print them
    while (client.available()) {
        char c = client.read();
        Serial.write(c);
    }

    // if the server's disconnected, stop the client
    if (!client.connected()) {
    Serial.println();
    Serial.println("Disconnecting from server...");
    client.stop();

    // do nothing forevermore
        while (true);
    }
}

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");
    
  WiFi.macAddress(mac);
  Serial.print("MAC: ");
  Serial.print(mac[5],HEX);
  Serial.print(":");
  Serial.print(mac[4],HEX);
  Serial.print(":");
  Serial.print(mac[3],HEX);
  Serial.print(":");
  Serial.print(mac[2],HEX);
  Serial.print(":");
  Serial.print(mac[1],HEX);
  Serial.print(":");
  Serial.println(mac[0],HEX);
}

 

위에 코드로 맥주소를 알아내려고 했는데 맥주소가 3:E8:75:30:0:E9 이런식으로 이상하게 뜨네요 또 옆에 다른 아두이노로 해봐도 똑같이 뜨내요 뭔가 코딩이 잘못 됬나요?

이전글   |    오렌지보드 채팅 어플 관련 2017-04-17
다음글   |    아두이노 보드에 LED STRIP을 직접 연결하려고 하는데요... 2017-04-17