These are chat archives for esp8266/Arduino

3rd
May 2017
riataman
@riataman
May 03 2017 00:35 UTC
I see if used inside C++ methods
riataman
@riataman
May 03 2017 00:41 UTC
DARN Arduino, won't let me include local libraries in an sketch.
Saurabh Vyas
@saurabhvyas
May 03 2017 10:00 UTC
anyone know how to implement realtime or sockets with arduino for node mcu v3
?
Michael Miller
@Makuna
May 03 2017 15:59 UTC
@majklovec What do you mean use F() and PSTR() in a class? Do you have an snippit of code to demonstrate your issue (not a whole sketch, just a few lines).
Michal Vondráček
@majklovec
May 03 2017 16:57 UTC

The snippet is easy:

Serial.println(F("test"));

I've copied the function @riataman mentioned and it's not working either.

#include "Plugin.h"
#include <Arduino.h>

class AnalogPlugin : public Plugin {
private:
  static Plugin *create() { return new AnalogPlugin; }
  static const size_t _id;

public:
  size_t id() const { return _id; }

  String errorToString(int error) {
    switch (error) {
    case 1:
      return F("connection refused");
    case 2:
      return F("send header failed");
    default:
      return F("send sdsdsadsadsa failed");
    }
  }

  int _read(JsonObject &options) {
    // Serial.println(String(F("dssdsad")));
    Serial.println(errorToString(1));
    sendValue(options["name"], "value", analogRead(A0));
  }
};

const size_t AnalogPlugin::_id = Factory::registerFunc(38, &create);
@saurabhvyas for websockets I'm using: https://github.com/me-no-dev/ESPAsyncWebServer
chrifey
@chrifey
May 03 2017 19:33 UTC
Hi *, anyone willing to help me with a tpm2net implementation? I'm trying to use the tpm2net code from pixelcontroller, but have problems with the tpm2net packet parsing
Michael Miller
@Makuna
May 03 2017 21:11 UTC
@majklovec Can you provide a minimal example sketch demonstrating the problem? This works for me...
class AnalogPlugin {
private:
  const size_t _id;

public:
  AnalogPlugin( size_t id) :
    _id(id)
    {

    }

  size_t id() const { return _id; }

  String errorToString(int error) {
    switch (error) {
    case 1:
      return F("connection refused");
    case 2:
      return F("send header failed");
    default:
      return F("send sdsdsadsadsa failed");
    }
  }
};

AnalogPlugin plug(10);

void setup() {
  // put your setup code here, to run once:

  Serial.begin(9600);
  Serial.println(plug.errorToString(1));
}

void loop() {
  // put your main code here, to run repeatedly:
}