I use the ethernet module to upload data to the server using the Cayenne-Arduino-Library and arduino_uip . I want to read myip[]from CayenneEthernet.h
Original:
void begin(const char* auth,
const char* domain = BLYNK_DEFAULT_DOMAIN,
uint16_t port = BLYNK_DEFAULT_PORT,
const byte mac[] = _blynkEthernetMac)
{
BLYNK_LOG("Here we are");
...
IPAddress myip = Ethernet.localIP();
BLYNK_LOG("My IP: %d.%d.%d.%d", myip[0], myip[1], myip[2], myip[3]);
}
Edited by:
int* begin(const char* auth,
const char* domain = BLYNK_DEFAULT_DOMAIN,
uint16_t port = BLYNK_DEFAULT_PORT,
const byte mac[] = _blynkEthernetMac)
{
...
IPAddress myip = Ethernet.localIP();
BLYNK_LOG("My IP: %d.%d.%d.%d", myip[0], myip[1], myip[2], myip[3]);
return myip;
}
Arduino Code:
#define CAYENNE_DEBUG
#define CAYENNE_PRINT Serial
#include <CayenneDefines.h>
#include <UIPEthernet.h>
#include <BlynkSimpleUIPEthernet.h>
#include <CayenneEthernetClient.h>
#define VIRTUAL_PIN V1
#define VIRTUAL_PIN V0
...
void setup(){
...
int *A=Cayenne.begin(token);
...
}
void loop(){
...
}
I get this error:
error: void is not ignored, as it should be
Question:
How to return an array correctly?
UPDATE:
After the search Cayenne.begin()is defined on CayenneEthernetClient.h
class CayenneEthernetClient : public CayenneClient
{
public:
void begin(const char* token, const byte mac[] = NULL)
{
BLYNK_LOG("HERE WE ARE 3");
Blynk.begin(token, CAYENNE_DOMAIN, CAYENNE_PORT, GetMACAddress(token, mac));
}
private:
const byte* GetMACAddress(const char* token, const byte mac[])
{
...
return _mac;
}
byte _mac[6];
};
CayenneEthernetClient Cayenne;
After that, this function starts with BlynkProtocol.h
private:
int readHeader(BlynkHeader& hdr);
uint16_t getNextMsgId();
protected:
void begin(const char* auth) {
BLYNK_LOG("HERE WE ARE 2");
this->authkey = auth;
}
bool processInput(void);
After that begin () is called on BlynkEthernet.h
void begin( const char* auth,
const char* domain = BLYNK_DEFAULT_DOMAIN,
uint16_t port = BLYNK_DEFAULT_PORT,
const byte mac[] = _blynkEthernetMac)
{
Base::begin(auth);
BLYNK_LOG("Getting IP...");
BLYNK_LOG("HERE WE ARE 1");
if (!Ethernet.begin((byte*)mac)) {
BLYNK_FATAL("DHCP Failed!");
}
::delay(1000);
this->conn.begin(domain, port);
IPAddress myip = Ethernet.localIP();
BLYNK_LOG("My IP: %d.%d.%d.%d", myip[0], myip[1], myip[2], myip[3]);
}
And this begin () is called finally on BlynkArduinoClient.h
void begin(const char* d, uint16_t p) {
BLYNK_LOG("HERE WE ARE 9");
domain = d;
port = p;
}
Output to serial monitor:
[75] HERE WE ARE 3
[76] MAC: FE-9D-D2-DD-A3-A0
[76] HERE WE ARE 2
[77] Getting IP...
[80] HERE WE ARE 1
[5385] HERE WE ARE 9
[5386] My IP: 10.42.0.162