Здравствуйте. Мне нужно инкапсулировать методы библиотеки Ethernet, и работающей под ней SPI, в свой класс.
Вот, как я попытался это сделать:
lib.h
#ifndef lib_h
#define lib_h
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class lib {
public:
void add_var(char *varname, int var_value);
bool connect_open();
void send();
};
#endif
lib.cpp
#include <lib.h>
bool libr::connect_open() {
#include <SPI.h>
#include <Ethernet.h>
EthernetClient client;
byte addr[4]= {8,8,8,8};
if (client.connect(addr, 80)) {
Serial.println("Connect is done");
return true;
}
else{
Serial.println("Connect is failed");
return false;
}
}
А выдает мне это следующие ошибки:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h: In member function 'bool lib::connect_open()':
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h:313:18: error: local class 'class lib::connect_open()::SPIClass' shall not have static data member 'uint8_t lib::connect_open()::SPIClass::initialized' [-fpermissive]
static uint8_t initialized;
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h:314:18: error: local class 'class lib::connect_open()::SPIClass' shall not have static data member 'uint8_t lib::connect_open()::SPIClass::interruptMode' [-fpermissive]
static uint8_t interruptMode; // 0=none, 1=mask, 2=global
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h:315:18: error: local class 'class lib::connect_open()::SPIClass' shall not have static data member 'uint8_t lib::connect_open()::SPIClass::interruptMask' [-fpermissive]
static uint8_t interruptMask; // which interrupts to mask
^
C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SPI\src/SPI.h:316:18: error: local class 'class lib::connect_open()::SPIClass' shall not have static data member 'uint8_t lib::connect_open()::SPIClass::interruptSave' [-fpermissive]
static uint8_t interruptSave; // temp storage, to restore state
^
In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src/Ethernet.h:7:0,
from C:\Users\lib\Documents\Arduino\libraries\lib\lib.cpp:5:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/EthernetClient.h:38:19: error: local class 'class lib::connect_open()::EthernetClient' shall not have static data member 'uint16_t lib::connect_open()::EthernetClient::_srcport' [-fpermissive]
static uint16_t _srcport;
^
In file included from C:\Users\lib\Documents\Arduino\libraries\lib\lib.cpp:5:0:
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/Ethernet.h:18:37: error: local class 'class lib::connect_open()::EthernetClass' shall not have static data member 'uint8_t lib::connect_open()::EthernetClass::_state [4]' [-fpermissive]
static uint8_t _state[MAX_SOCK_NUM];
^
C:\Program Files (x86)\Arduino\libraries\Ethernet\src/Ethernet.h:19:44: error: local class 'class lib::connect_open()::EthernetClass' shall not have static data member 'uint16_t lib::connect_open()::EthernetClass::_server_port [4]' [-fpermissive]
static uint16_t _server_port[MAX_SOCK_NUM];
^
Что я делаю не так?