Navigation

    • Register
    • Login
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. Clone Tv
    3. Posts
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    Posts made by Clone Tv

    • RE: MQTT RETAIN messages work a little strangely

      I do not use signed messages, so I used the Signed flag in the MySensors packet header to implement selective MQTT retain state.

      Gateway is ESP2866 - no specific code.
      Code send from client:

      template<typename T>
      void reportMsg(const uint8_t & id, const mysensors_data_t & tag, const T & val, const bool retain) {
          MyMessage msg(id, tag);
          msg.setSigned(retain);
          send(msg.set(val), true);
      }
      

      Lite patch MyGatewayTransportMQTTClient.cpp:

      bool gatewayTransportSend(MyMessage &message) {
         ...
         bool retain = message.getSigned();
         message.setSigned(false);
         ....
      
      posted in Development
      Clone Tv
      Clone Tv
    • RE: MQTT RETAIN messages work a little strangely

      Yes, I am using the mosquitto MQTT broker, but the problem is most likely with the mysensors MQTT gateway. On Mosquito, I am able to write a packet with the retained flag from the console, and it works.

      posted in Development
      Clone Tv
      Clone Tv
    • MQTT RETAIN messages work a little strangely

      MQTT RETAIN messages work a little strangely. The first ones always come and are recorded by the mosquito server, but all subsequent messages do not reach and are not recorded by the server .. The RETAIN flag is naturally set.

      posted in Development
      Clone Tv
      Clone Tv
    • RE: Gateway - I2C Advanced button and led

      small fix of the patch, removed "contact bounce" in the inclusive button.

      posted in My Project
      Clone Tv
      Clone Tv
    • Gateway - I2C Advanced button and led

      I have a gate based on esp2866, wemos mini board. There are few gpio outputs on it. To implement additional features, such as an inclusive button and status LEDs, I had to connect a gpio expansion board via I2C. I took a PCF8574 based board. For the operation of the button and indication through it, the sources had to be slightly changed, the patch for version 2.4.0 is attached in gist.

      Example sketch code:

      #define MY_DEFAULT_LED_EXT 1
      #define MY_INCLUSION_MODE_FEATURE
      #define MY_INCLUSION_BUTTON_FEATURE
      #define MY_INCLUSION_MODE_DURATION 10
      
      #include <MySensors.h>
      #include <core/MyInclusionMode.h>
      #include <PCF8574.h>
      
      const uint8_t scl_PIN = D1;
      const uint8_t sda_PIN = D2;
      const uint8_t led_device[4] { 2U, 3U, 6U, 4U };
      const uint8_t btn_device[4] { 0U, 1U, 5U, 7U };
      PCF8574 expander(0x22, sda_PIN, scl_PIN);
      
      void setup() {
        Wire.begin(sda_PIN, scl_PIN);
        Serial.begin(115200);
        while (!Serial) delay(50);
        
        for (uint8_t i = 0; i < 4U; i++) {
          expander.pinMode(led_device[i], OUTPUT);
          expander.digitalWrite(led_device[i], HIGH);
          Serial.printf("Init LED expander: %u/%u\n", (uint16_t)i, (uint16_t)led_device[i]);
      
          expander.pinMode(btn_device[i], INPUT);
          expander.digitalWrite(btn_device[i], HIGH);
          Serial.printf("Init BTN expander: %u/%u\n", (uint16_t)i, (uint16_t)btn_device[i]);
        }
        expander.begin();
        ledsSetCb(
          [=](uint8_t & state) { expander.digitalWrite(led_device[1], state); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[2], state); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[3], state); }
        );
        inclusionSetCb(
          [=]() { return (expander.digitalRead(btn_device[0], true) == LOW); },
          [=](uint8_t & state) { expander.digitalWrite(led_device[0], state); }
        );
      }
      
      void loop() {}
      
      
      

      I2C extender
      PCF8574-module-type2-800x800.jpg

      posted in My Project
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      Yes, I found 🙂
      It may be useful for those who might come across this issue later:

      Git MYCONTROLLER repo

      Code for sending RSSI from loop function.
      It is not necessary to announce (present) the RSSI sensor.

                          MY_CRITICAL_SECTION {
                              char *buff = new char[18]{};
                              (void) snprintf(buff, 17, "rssi:%d", rssi);
                              reportMsg(getId(), V_VAR5, buff);
                              delete [] buff;
                          }
      
      
      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      Many thanks to all who answered, regarding MyController I think I will have to look at the source code, in which topic and with what identifier it expects a message about the RSSI evel.

      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      @Clone-Tv said in Where to send messages about battery charge and signal strength?:

      message.sender

      Thanks for the clarification about message.sender, but then it is not entirely clear why this is used to receive messages? In essence, this should create a regeneration loop of messages ...

      Unfortunately, it was not possible to deliver the RSSI level as applied to the MyController interface. The data itself is of course sent and received, but there is no display in the corresponding column. I used the S_SOUND and V_LEVEL identifiers.

      Here's a screenshot of where it should be, but it's not there 🙂

      myc-rssi.png

      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      Do I understand correctly that if (message.sender == 1) is a broadcast message? and it is sent to all nodes at once?

      https://github.com/mfalkvidd/Arduino-MySensors-ESP8266-RFM69-Gateway/blob/030be620d45f2fd6cf02bc3633879e8bf35f7ef0/Arduino-MySensors-ESP8266-RFM69-Gateway.ino#L122

      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      C ++ templates work great, the main thing is not to use class->virtual and RTTI. I write C ++ fluently, it's easier for me.
      Thanks for your reply and sorry for my "bad" english.

      posted in MyController.org
      Clone Tv
      Clone Tv
    • RE: Where to send messages about battery charge and signal strength?

      If I send a message with a sensor ID of NODE_SENSOR_ID, I get the following duplicate message errors:

      reportMsg(NODE_SENSOR_ID, I_SIGNAL_REPORT_RESPONSE, static_cast<uint16_t>(rssi));
      

      errors:

      951492 !MCO:PRO:RC=1
      951525 !MCO:PRO:RC=1
      951558 !MCO:PRO:RC=1
      .. more ..
      
      
      posted in MyController.org
      Clone Tv
      Clone Tv
    • Where to send messages about battery charge and signal strength?

      Everyone a good day.

      Where to send messages about battery charge and signal strength? they are not visible in the corresponding fields of MyController.
      Explain the topology of sending RSSI system messages and battery level.

      Who initiates the request for battery charge and signal strength? Or does the sensor send itself at its own discretion? It seemed to me that there are the following tags: In and Out, so this is all the same dialogue on demand?

      I am sending data something like this:

      
      reportMsg(getId(), I_SIGNAL_REPORT_RESPONSE, static_cast<uint16_t>(rssi));
      
      ....
      
      template<typename T>
      void reportMsg(const uint8_t & id, const mysensors_internal_t & tag, const T & val) {
          _sendRoute(build(_msgTmp, GATEWAY_ADDRESS, id, C_SET, tag, false).set(val));
      }
      
      

      but I don't see the data .. something goes wrong. The same story with battery power, I send data from loop, without external request. Is it correct?

      posted in MyController.org
      Clone Tv
      Clone Tv
    • Updating InclusionMode Button Behavior

      If you press the InclusionMode button and hold it for 10 seconds, the device will restart. In general, typical behavior for many Internet devices.
      The patch is attached link.

      Strange, but the forum does not allow you to upload anything other than pictures ..

      It would be nice to see this in the main code of the repository. So that when updating the version, do not apply the patch separately 🙂

      posted in Feature Requests
      Clone Tv
      Clone Tv
    • RE: test

      Sorry, that was the test 🙂 the text is irrelevant to the topic.
      But, since we are talking about 64-bit numbers on Arduino-like platforms, I'm ready to translate the code that solves this situation.

      Int64String.h

      #if !defined(INT64STRING_H)
      # define INT64STRING_H 1
      
      # if (defined(ARDUINO) && (ARDUINO >= 100))
      #  include "Arduino.h"
      # else
      #  include "WString.h"
      # endif
      
      String Int64ToString(uint64_t, uint8_t = DEC, bool = false, bool = false);
      String Int64ToString(int64_t, uint8_t = DEC, bool = false);
      uint64_t StringToInt64(String);
      uint64_t StringToInt64(const char*, uint16_t);
      
      #endif
      
      

      Int64String.cpp

      #include "Int64String.h"
      #define base16char(A) ("0123456789ABCDEF"[A])
      
      String Int64ToString(uint64_t value, uint8_t base, bool prefix, bool sign) {
        if (base < 2)
          base = 2;
        else if (base > 16)
          base = 16;
      
        uint8_t i = 64;
        char buffer[66] = {0};
      
        if (value == 0)
          buffer[i--] = '0';
        else {
          uint8_t base_multiplied = 3;
          uint16_t multiplier = base * base * base;
      
          if (base < 16) {
            multiplier *= base;
            base_multiplied++;
          }
          if (base < 8) {
            multiplier *= base;
            base_multiplied++;
          }
          while (value > multiplier) {
            uint64_t q = value / multiplier;
            uint16_t r = value - q * multiplier;
      
            for (uint8_t j = 0; j < base_multiplied; j++) {
              uint16_t rq = r / base;
              buffer[i--] = base16char(r - rq * base);
              r = rq;
            }
            value = q;
          }
      
          uint16_t remaining = value;
          while (remaining > 0) {
            uint16_t q = remaining / base;
            buffer[i--] = base16char(remaining - q * base);
            remaining = q;
          }
        }
      
        if (base == DEC && sign)
          buffer[i--] = '-';
        else if (prefix) {
          if (base == HEX) {
            buffer[i--] = 'x';
            buffer[i--] = '0';
          }
          else if (base == OCT)
            buffer[i--] = '0';
          else if (base == BIN)
            buffer[i--] = 'B';
        }
        return String(&buffer[i + 1]);
      }
      
      String Int64ToString(int64_t value, uint8_t base, bool prefix) {
        bool sign = base == DEC && value < 0;
        uint64_t uvalue = sign ? -value : value;
        return Int64ToString(uvalue, base, prefix, sign);
      }
      
      uint64_t StringToInt64(String str) {
        return StringToInt64(str.c_str(), str.length());
      }
      
      uint64_t StringToInt64(const char *s, uint16_t sz = 0U) {
        uint64_t val = 0ULL;
        if (s == nullptr)
          return val;
      
        if (sz <= 0)
          sz = strlen(s);
      
        if (sz <= 2)
          return val;
        
        uint16_t i = (((s[0] == '0') && ((s[1] == 'x') || (s[1] == 'X'))) ? 2U : 0U);
        for (; i < sz; i++) {
          const char c = s[i];
          if (!isxdigit(c))
            return -1ULL;
          
          val *= 16;
          val += (c >= '0' && c <= '9') ? c - '0' : c - 'A' + 10;
        }
        return val;
      }
      
      

      I gave the sources as an apology for the created topic 🙂

      posted in My Project
      Clone Tv
      Clone Tv
    • Press inclusion button to reboot after 10 sec, ESP8266 only

      The patch for the inclusion button, after holding for 10 seconds, the device goes into reboot.
      Only suitable for ESP8266 ..

      MySensors/core/MyInclusionMode.patch

      9c9
      <  * Copyright (C) 2013-2019 Sensnology AB
      ---
      >  * Copyright (C) 2013-2020 Sensnology AB
      21,23d20
      < #if defined(ARDUINO_ARCH_ESP8266)
      < #  include <Esp.h>
      < #endif
      28,29c25,26
      < unsigned long _inclusionStartTime = 0U, _rebootStartTime = 0U;
      < bool _inclusionMode, _rebootMode;
      ---
      > unsigned long _inclusionStartTime;
      > bool _inclusionMode;
      33d29
      < 	_rebootMode = false;
      66,68c62
      < 
      < 	bool b = (hwDigitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == MY_INCLUSION_BUTTON_PRESSED);
      < 	if (!_inclusionMode && b) {
      ---
      > 	if (!_inclusionMode && hwDigitalRead(MY_INCLUSION_MODE_BUTTON_PIN) == MY_INCLUSION_BUTTON_PRESSED) {
      72,84d65
      < #	if defined(ARDUINO_ARCH_ESP8266)
      < 	if (!_rebootMode && b) {
      < 		_rebootStartTime = hwMillis() + 10000U;
      < 		_rebootMode = true;
      < 
      < 	} else if (_rebootMode && b) {
      < 		if (_rebootStartTime < hwMillis())
      < 			ESP.restart();
      < 
      < 	} else if (_rebootMode) {
      < 		_rebootMode = false;
      < 	}
      < #	endif
      86c67,68
      < 	if (_inclusionMode && (hwMillis() - _inclusionStartTime > MY_INCLUSION_MODE_DURATION * 1000L)) {
      ---
      > 
      > 	if (_inclusionMode && hwMillis()-_inclusionStartTime>MY_INCLUSION_MODE_DURATION*1000L) {
      90c72
      < }
      ---
      > }
      \ No newline at end of file
      
      posted in Development
      Clone Tv
      Clone Tv