XPL Need help

Hi!

Relly need help on this.
I whant to send data that i recived using X10 to Xpl. Downloaded the lib and tested the example:

#include <SPI.h>        
#include <Ethernet.h>
#include <EthernetUdp.h>

#include "xPL.h"

xPL xpl;

unsigned long timer = 0; 

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10, 0, 0, 177);
IPAddress broadcast(10, 0, 0, 255);
EthernetUDP Udp;

void SendUdPMessage(char *buffer)
{
    Udp.beginPacket(broadcast, xpl.udp_port);
    Udp.write(buffer);
    Udp.endPacket(); 
}

void setup()
{
  Serial.begin(115200);
  Ethernet.begin(mac,ip);
  Udp.begin(xpl.udp_port);  
  
  xpl.SendExternal = &SendUdPMessage;  // pointer to the send callback 
  xpl.SetSource_P(PSTR("xpl"), PSTR("arduino"), PSTR("test")); // parameters for hearbeat message
}

void loop()
{
  xpl.Process();  // heartbeat management
   
   // Example of sending an xPL Message every 10 second
   if ((millis()-timer) >= 10000)
   {
     xPL_Message msg;

     msg.hop = 1;
     msg.type = XPL_TRIG;

     msg.SetTarget_P(PSTR("*"));
     msg.SetSchema_P(PSTR("sensor"), PSTR("basic"));

     msg.AddCommand_P(PSTR("device"),PSTR("1"));
     msg.AddCommand_P(PSTR("type"),PSTR("[b]temp[/b]"));
     msg.AddCommand_P(PSTR("current"),PSTR("22"));

     xpl.SendMessage(&msg);
     
     timer = millis();
   } 
}

But then i try to replace “temp” in the example with a variabel i only get

initializer fails to determine size of '__c'

Any tip?

But then i try to replace "temp" in the example with a variabel i only get

But, you don't want to tell us what variable, or how?

Are you replacing "temp" in the PSTR() macro with something other than a string? That's going to fail.

Of course, you can use dtostrf() or itoa() to convert values to strings, and then use them in the PSTR() macro.

Yep… use dtostrfbuffer.

msg.AddCommand(“current”,dtostrfbuffer);

Hi!

Sorry… This is the code that is not working…

/* Arduino Interface to the PSC05 X10 Receiver.                       BroHogan 3/24/09
 * SETUP: X10 PSC05/TW523 RJ11 to Arduino (timing for 60Hz)
 * - RJ11 pin 1 (BLK) -> Pin 2 (Interrupt 0) = Zero Crossing
 * - RJ11 pin 2 (RED) -> GND
 * - RJ11 pin 3 (GRN) -> Pin 4 = Arduino receive
 * - RJ11 pin 4 (YEL) -> Pin 5 = Arduino transmit (via X10 Lib)
 * NOTES:
 * - Must detach interrup when transmitting with X10 Lib 
 */

#include <SPI.h>        
#include <Ethernet.h>
#include <EthernetUdp.h>
#include "xPL.h"

#include <x10.h>                       // X10 lib is used for transmitting X10
#include <x10constants.h>              // X10 Lib constants
#define RPT_SEND 2 

#define ZCROSS_PIN     2               // BLK pin 1 of PSC05
#define RCVE_PIN       4               // GRN pin 3 of PSC05
#define TRANS_PIN      5               // YEL pin 4 of PSC05
#define LED_PIN        13              // for testing 

x10 SX10= x10(ZCROSS_PIN,TRANS_PIN,RCVE_PIN,LED_PIN);// set up a x10 library instance:

xPL xpl;

unsigned long timer = 0;


// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0x90, 0xA2, 0xDA, 0x0D, 0xF5, 0xE2 };
IPAddress ip(192, 168, 73, 91);
IPAddress broadcast(192, 168, 73, 255);
EthernetUDP Udp;



void SendUdPMessage(char *buffer)
{
    Udp.beginPacket(broadcast, xpl.udp_port);
    Udp.write(buffer);
    Udp.endPacket(); 
}


void setup()
{
  Serial.begin(115200);
  Ethernet.begin(mac,ip);
  Udp.begin(xpl.udp_port);  
  
  xpl.SendExternal = &SendUdPMessage;  // pointer to the send callback 
  xpl.SetSource_P(PSTR("xpl"), PSTR("spc4300"), PSTR("alive")); // parameters for hearbeat message
}


// A simple test program that demonstrates integrated send/receive
// prints X10 input, then sets D5 on/off if unit code on input was 1
void loop(){
  xpl.Process();  // heartbeat management
  if (SX10.received()) {                         // received a new command
  String hus = "A";
  String kod = "1";
  String commando = "off";

    if (SX10.cmndCode() == ON ) 
        {
        commando = "on";
        }
        else
        {
        commando = "off";
        }
  kod = String(SX10.unitCode());  // returns integer unit code
  hus = String(SX10.houseCode()); // returns ascii A-P human readable house code
  

  xPL_Message msg;
     msg.hop = 1;
     msg.type = XPL_TRIG;
     msg.SetTarget_P(PSTR("rfxcom-lan.0004a35960c9"));
     msg.SetSchema_P(PSTR("x10"), PSTR("basic"));
     msg.AddCommand_P(PSTR("device"),PSTR(hus+kod));
     msg.AddCommand_P(PSTR("command"),PSTR(commando));
     
     xpl.SendMessage(&msg);
  SX10.reset();
}
}

I will check the input from you and see if it will help…
//micke