Pages: [1]   Go Down
Author Topic: error compile my code  (Read 910 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here the code:
Code:
// Demo using DHCP and DNS to perform a web client request.
// 2011-06-08 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php

#include <EtherCard.h>
#include <RCSwitch.h>

RCSwitch mySwitch = RCSwitch();
#define garderobe "82"

// ethernet interface mac address, must be unique on the LAN
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[700];
static uint32_t timer;

char website[] PROGMEM = "192.168.2.19";
static byte hisip[] = {192,168,2,19};

// called when the client request is complete
static void my_callback (byte status, word off, word len) {
  Serial.println(">>>");
  Ethernet::buffer[off+300] = 0;
  Serial.print((const char*) Ethernet::buffer + off);
  Serial.println("...");
}

void setup () {
  Serial.begin(57600);
  Serial.println("\n[webClient]");
  mySwitch.enableReceive(1);

  if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
    Serial.println( "Failed to access Ethernet controller");
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip); 
  ether.printIp("DNS: ", ether.dnsip);
  ether.copyIp(ether.hisip, hisip);
  ether.hisport = 3480;
  ether.printIp("SRV: ", ether.hisip);

  if (!ether.dnsLookup(website))
    Serial.println("DNS failed");
   
  ether.printIp("SRV: ", ether.hisip);
}

void loop () {
  ether.packetLoop(ether.packetReceive());
   if (mySwitch.available()) {
    unsigned long code = mySwitch.getReceivedValue();
    Serial.print("Received :");
    Serial.println( code );
    if (code == 5586965)
      {
    mySwitch.resetAvailable();
    sendtovera(garderobe);
}
}
}
void sendtovera(String devid){
 ether.browseUrl(PSTR("/data_request?id=action&DeviceNum=52&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue="), devid, website, my_callback);
}


error:
Code:
nc28j60.cpp: In function 'void sendtovera(String)':
enc28j60:63: error: no matching function for call to 'EtherCard::browseUrl(char*, String&, char [13], void (&)(byte, word, word))'
/Users/Michael/Documents/Arduino/libraries/ethercardmaster/EtherCard.h:164: note: candidates are: static void EtherCard::browseUrl(prog_char*, const char*, prog_char*, void (*)(uint8_t, uint16_t, uint16_t))

I'm loss, i thing that ether card do not like string but not sure
thanks
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3383
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm loss, i thing that ether card do not like string but not sure
thanks

Actually, it loves strings. Strings, on the hand, it's not too fond of.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

maybe it late here but i don't understand what you means?
Sorry
Logged

Lost Wages
Offline Offline
Full Member
***
Karma: 11
Posts: 103
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The C compiler is case-sensitive.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Normally to call it i use String not string, if i put string, it say that i have not  declare it.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok other method, let say i want to insert value in the url:

Code:
ether.browseUrl(PSTR("/data_request?id=action&DeviceNum=(((HERE))&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue="), "1", website, my_callback);
In python i use the s% function like this:
Code:
"/data_request?id=action&DeviceNum=%s&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=" $ devid
but is there a way in arduino code
thanks
Logged

Rome, Italy
Offline Offline
Sr. Member
****
Karma: 20
Posts: 442
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, forget the other method whatever it was intended to mean. Look at your error message:
Code:
enc28j60:63: error: no matching function for call to 'EtherCard::browseUrl(char*, String&, char [13], void (&)(byte, word, word))'
See how the compiler suggests something that could work:
Code:
... note: candidates are: static void EtherCard::browseUrl(prog_char*, const char*, prog_char*, void (*)(uint8_t, uint16_t, uint16_t))

The main difference between the parameters you are passing and the parameters that the compiler expects is... the String& parameter. Now if you look at your code around line 63 (as the compiler tells you) you see that devid is declared as a String. Can you change it into a (const) char*? The funny thing is that garderobe is actually a char*, but you (implicitly) convert it into a String when you call sendtovera(). Just redefine sendtovera() to accept a char* and it should fix the error.

Btw, the C equivalent of s% in python is sprintf().
Logged

Pages: [1]   Go Up
Jump to: