2

我正在做一个项目,我正在努力掌握它。使用WiShield。我一直在尝试完成一个简单高音扬声器的示例程序。但是,我还没有运气。我一直在努力寻找解决方案,但我发现的一切似乎都不起作用。我该如何解决这个问题?

我的代码以及我收到的错误如下。

代码

#include <WiServer.h>

#define WIRELESS_MODE_INFRA    1
#define WIRELESS_MODE_ADHOC    2

unsigned char local_ip[] = {192,168,2,2};
unsigned char gateway_ip[] = {192,168,2,1};
unsigned char subnet_mask[] = {255,255,255,0};
const prog_char ssid[] PROGMEM = {"myssid"};

unsigned char security_type = 3; // 0 - open; 1 - WEP; 2 - WPA; 3 - WPA2

const prog_char security_passphrase[] PROGMEM = {"mywifipassword"};

prog_uchar wep_keys[] PROGMEM = {
    0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d,
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    // Key 1
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,    // Key 2
    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00    // Key 3
};

unsigned char wireless_mode = WIRELESS_MODE_INFRA;
unsigned char ssid_len;
unsigned char security_passphrase_len;

// Authentication string for the Twitter account.
char* auth = "[user:pass]"; // Base64 encoded USERNAME:PASSWORD

// This function generates a message with the current system time.
void currentTime() {
    WiServer.print("Arduino has been running for ");
    WiServer.printTime(millis());
}

// A request that sends a tweet using the currentTime function.
TWEETrequest sentMyTweet(auth, currentTime);

void setup() {
    // Initialize WiServer (we'll pass NULL for the page serving function since we don't need to serve web pages).
    WiServer.init(NULL);

    // Enable Serial output and ask WiServer to generate log messages (optional).
    Serial.begin(57600);
    WiServer.enableVerboseMode(true);
}

// Time (in milliseconds) when the next tweet should be sent.
long tweetTime = 0;

void loop(){
    // Check if it's time to sent a tweet
    if (millis() >= tweetTime) {
        sentMyTweet.submit();
        // Send next tweet 5 minutes from now
        tweetTime += 1000 * 60 * 5;
    }

    // Run WiServer
    WiServer.server_task();

    delay(10);
}

错误

在 SimpleTweeter.cpp:5 包含的文件中:

C:\Program Files (x86)\arduino-1.0\libraries\WiShield/WiServer.h:198: error: conflicting return type specified for 'virtual void Server::write(uint8_t)'

C:\Program Files (x86)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'

SimpleTweeter.pde:-1: error: 'TWEETrequest' does not name a type

SimpleTweeter.cpp: In function 'void loop()':

SimpleTweeter.pde:-1: error: 'sentMyTweet' was not declared in this scope

(我是 Arduino 的新手。)

4

1 回答 1

2

看起来 WiServer 库尚未升级为与 Arduino 1.0 一起使用。在这个版本的 Arduino 软件中,类中 write 方法的返回类型Printvoid改为size_t.

Juan C. Muller在GitHub 上一个 WiShield 的分支,它与 Arduino 1.0 兼容。

关于类型的后续错误TWEETrequest是此先前错误的连锁反应。

于 2012-04-14T22:31:47.737 回答