Code Monkey home page Code Monkey logo

esp-knx-ip's People

Contributors

ascillato avatar envy avatar maggyver avatar per1234 avatar zbikmarc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-knx-ip's Issues

Update a config_string ..

Hi Nico,

Is there a way to update a registered config_string?

I have added a wifiManager to my sketch so I can configure a WiFi AP if the device cannot connect to the last known AP. So I have registered a SSID and Password string. During startup I read the values after knx.load():

  _SIDID_id = knx.register_config_string("sSID_ID", 50, WiFi.SSID());
  _SIDPW_id = knx.register_config_string("sSID_PW", 50, WiFi.psk());
  param_id = knx.register_config_int("My Parameter", default_val);

  Serial.print("_SIDID_id ["); Serial.print(_SIDID_id); Serial.println("]");
  Serial.print("_SIDPW_id ["); Serial.print(_SIDPW_id); Serial.println("]");

  knx.load(); // Try to load a config from EEPROM

  sSID_ID = knx.get_config_string(_SIDID_id);
  sSID_PW = knx.get_config_string(_SIDPW_id);

  Serial.print("Connect to AP ["); Serial.print(sSID_ID); Serial.println("]");
  ....

If the sSID_ID and sSID_PW does not make a WiFi connection I start the wifiManager to select the right AP. Then I want to save the new WiFi.SSID() and WiFi.pks() to te already registered positions ...

I tried:

_SIDID_id = knx.__config_set_string(_SIDID_id, WiFi.SSID());

but "__config_set_string()" is not public...

So, I created a public function:

void ESPKNXIP::update_config_string(config_id_t id, String val)
{
  memcpy(&custom_config_data[custom_configs[id].offset], val.c_str(), val.length()+1);
}

... that does the trick! Any change you can put this patch in the master?

Same goes with update_config_int() i suppose ..

Regards

What IDE are you using?

Greetings, Envy. Tell me please what IDE you use. I modified the example file for the DHT22 sensor in Arduino IDE a little. I would like to work in some other IDE

ChangeLog

Hi @envy,

What about adding a ChangeLog File so as to know what changes are being made to the ESP-KNX-IP Library?

Like PR #32 for example

KNX-IP Lite Version

Hi @envy,

Great Library!!! I was able to connect it to Home Assistant very fast and It is working great!!! 👍 Thanks

I have a feature request.

Can be modified a little your library so as to be just the KNX-IP Interface without the Webserver? Like an option to turn off the webserver and eeprom features, and to set manually the address and callbacks?
This request is because for using your library in a project that has its own webserver, the integration is very difficult.

If you can have the webserver and eeprom as optional, it can be easily integrated on ESPEasy, Sonoff-Tasmota, Espurna, etc.

What do you think?

Don't store function pointers in EEPROM

Instead of saving functions pointers in ga_callbacks, store the id of the callback.
That way we need a second lookup inside __loop_knx but gain the ability to reuse the stored EEPROM config even if the code layout changes. Also we need to store less (8 bit vs pointer-type, so probably 32 bit).

Also define a callback_id_t type for callback ids.

AsyncUDP Branch and Master Branch

Hi @envy

There are several issues on the version 2.4.0 of the esp8266 board libraries.

As the library ESP-KNX-IP / Async-UDP Branch requires the ESPAsyncUDP Library that requires the 2.4.0, I think you should keep both branchs until a new release of esp8266 board libraries without the bugs is released.

Some of the bugs are reboot when using sleep. Hungs with webserver, etc.

So, what do you think of update the Master Branch with the last changes of the Async-UDP Branch?

and also what about adding the ACK to solve the lost telegrams issue?

Thanks

example environment-sensor does not compile

error message:


esp_knx_environment_sensor\esp_knx_environment_sensor.ino: In function 'void setup()':

esp_knx_environment_sensor:37: error: invalid conversion from 'void ()(knx_command_type_t, const address_t&, uint8_t, uint8_t) {aka void ()(__knx_command_type, const __address&, unsigned char, unsigned char)}' to 'callback_fptr_t {aka void ()(const __message&, void)}' [-fpermissive]

knx.register_callback("Read Temperature", temp_cb);

                                                ^

In file included from esp_knx_environment_sensor\esp_knx_environment_sensor.ino:7:0:

C:\Users\engel\Documents\Arduino\libraries\esp-knx-ip-master/esp-knx-ip.h:315:19: error: initializing argument 2 of 'callback_id_t ESPKNXIP::register_callback(String, callback_fptr_t, void*, enable_condition_t)' [-fpermissive]

 callback_id_t register_callback(String name, callback_fptr_t cb, void *arg = nullptr, enable_condition_t cond = nullptr);

               ^

esp_knx_environment_sensor:38: error: invalid conversion from 'void ()(knx_command_type_t, const address_t&, uint8_t, uint8_t) {aka void ()(__knx_command_type, const __address&, unsigned char, unsigned char)}' to 'callback_fptr_t {aka void ()(const __message&, void)}' [-fpermissive]

Bu I need this example to adjust my own source to the new library.
Could you please fix or explain?
Thank you!

Regards, Oliver

Add a prefix for the webserver API

Currently we instanciate a webserver and only use it ourselves. It is possible to specify an already existing webserver object in start() but this still clobbers the root. We need a customizable prefix so that our endpoints are not in the root.

Webserver integration

Please make the webserver integrable with an existing web server of the main app, bei passing the existing server and an absolute path to the library at start and builc all internal path relative to th egiven one.

Send String

Hi Envy,

first of all thanks for this great work.
Would it be possible to add also a send string function?
I have some text information which I would like to send to the KNX bus.
Like the direction of the wind from a wind sensor.

Many thanks.
Poseidon

Step Up/Down Dimming 3.005/3.007, 4 bit

Hi Nico,

Is there a way to send a 4bit telegram? For StepUp/Down dimming needs this but I can't see how..

dim_3 007

... or am I missing something (again!)??

Pressing the KNX switch to dimUp/Down the lamp the monitor shows:

LPDU: BC 11 84 10 0E E1 00 89 A0 :L_Data low from 1.1.132 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 09 
LPDU: BC 11 85 10 0E E1 00 88 A0 :L_Data low from 1.1.133 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 08  

Writing 07, 08 or 09 values using writeBit() I get this:

LPDU: BC 11 C8 10 0E E1 00 81 E4 :L_Data low from 1.1.200 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 
LPDU: BC 11 C8 10 0E E1 00 81 E4 :L_Data low from 1.1.200 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 

Using write1ByteInt() the monitor shows:

LPDU: BC 11 C8 10 0E E2 00 80 09 EF :L_Data low from 1.1.200 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 09 
LPDU: BC 11 C8 10 0E E2 00 80 08 EE :L_Data low from 1.1.200 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 08 

Another small KNX-IP stack for ESP and Linux with builtin management server for ETS programming

Hi,

there is a another KNX-IP stack for the ESP (and Linux) which also supports ETS-programming+configuration:
https://github.com/thelsing

Furthermore, there is a small Windows tool which can generate a signed .knxprod product database file by using DLLs provided by ETS4 for your custom homebrew KNX-IP device. As it is correctly signed, it can be imported into the ETS project like any other product database file.

Just for your information. ;)

Static example does not compile

Static example does not compile in Arduino IDE (1.8.7) with esp8266 board library version 2.3.0. Same error for different boards selected.

Issue looks similar to what was in #13

C:\SANITIZED\Arduino\esp_knx_static_example\esp_knx_static_example.ino: In function 'void setup()':

esp_knx_static_example:34:76: error: invalid conversion from 'callback_id_t {aka unsigned char}' to 'callback_fptr_t {aka void (*)(const __message&, void*)}' [-fpermissive]

   callback_id_t temp_cb = knx.callback_register("Read Temperature", temp_cb);

                                                                            ^

In file included from C:\SANITIZED\Arduino\esp_knx_static_example\esp_knx_static_example.ino:8:0:

C:\SANITIZED\Arduino\libraries\esp-knx-ip-master/esp-knx-ip.h:367:19: error:   initializing argument 2 of 'callback_id_t ESPKNXIP::callback_register(String, callback_fptr_t, void*, enable_condition_t)' [-fpermissive]

     callback_id_t callback_register(String name, callback_fptr_t cb, void *arg = nullptr, enable_condition_t cond = nullptr);

                   ^

esp_knx_static_example:35:71: error: invalid conversion from 'callback_id_t {aka unsigned char}' to 'callback_fptr_t {aka void (*)(const __message&, void*)}' [-fpermissive]

   callback_id_t hum_cb = knx.callback_register("Read Humidity", hum_cb);

                                                                       ^

In file included from C:\SANITIZED\Arduino\esp_knx_static_example\esp_knx_static_example.ino:8:0:

C:\SANITIZED\Arduino\libraries\esp-knx-ip-master/esp-knx-ip.h:367:19: error:   initializing argument 2 of 'callback_id_t ESPKNXIP::callback_register(String, callback_fptr_t, void*, enable_condition_t)' [-fpermissive]

     callback_id_t callback_register(String name, callback_fptr_t cb, void *arg = nullptr, enable_condition_t cond = nullptr);

                   ^

esp_knx_static_example:36:73: error: invalid conversion from 'callback_id_t {aka unsigned char}' to 'callback_fptr_t {aka void (*)(const __message&, void*)}' [-fpermissive]

   callback_id_t pres_cb = knx.callback_register("Read Pressure", pres_cb);

                                                                         ^

In file included from C:\SANITIZED\Arduino\esp_knx_static_example\esp_knx_static_example.ino:8:0:

C:\SANITIZED\Arduino\libraries\esp-knx-ip-master/esp-knx-ip.h:367:19: error:   initializing argument 2 of 'callback_id_t ESPKNXIP::callback_register(String, callback_fptr_t, void*, enable_condition_t)' [-fpermissive]

     callback_id_t callback_register(String name, callback_fptr_t cb, void *arg = nullptr, enable_condition_t cond = nullptr);

                   ^

exit status 1
invalid conversion from 'callback_id_t {aka unsigned char}' to 'callback_fptr_t {aka void (*)(const __message&, void*)}' [-fpermissive]

Received packets are sometimes lost if they are recevied during handling of another one

If we are currently handling a packet while another packet arrives, that packet is sometimes lost.
Don't know if it is a problem of the UDP library or my code.

Might be fixed by calling parsePacket() multiple times and saving multiple packets before working on them.
However, this increases the time we work on packets so might miss other ones again :/

Make MULTICAST_IP externally configurable using compiler switches

I had to change MULTICAST_IP when using Tasmota's KNX support because a router frequently used in Germany (AVM's Fritz!Box) does not correctly implement multicast support. This, however, seems to be a frequent issue with many routers.

As these faulty implementations forward Apple's Bonjour traffic, an option is to set the default multicast address to 224, 0, 0, 251. Using Tasmota, this requires to modify esp-knx-ip in the lib/ folder - which should be avoided.

Therefore, it could make sense to change esp-knx-ip-0.5.2/esp-knx-ip.h as follows:

Current version:

#define MULTICAST_IP              IPAddress(224, 0, 23, 12) // [Default IPAddress(224, 0, 23, 12)]

Updated version:

#ifndef
#define MULTICAST_IP              IPAddress(224, 0, 23, 12) // [Default IPAddress(224, 0, 23, 12)]
#endif

This would allow setting the MULTICAST_IP using compiler switches (e.g., -DMULTICAST_IP=IPAddress(224, 0, 0, 251)).

With this setting, I'm able to get a working setup with KNX/IP to KNX/TP forwarding. So, I'm able to switch a MagicHome LED controller running Tasmota with a KNX/TP switch.

SONOFF example also with additional sensors?

Hi,
first to say this is a great project!

So nevertheless I'm wondering whether it is (already) possible to add additional sensors like a DS18B20 to the GPIOs of the SONOFF and get there measurements also via knx?
This is a nice add-on the Tasmota firmware (MQTT) already has.

Thanks for the response.

More examples please

Hi Nico,

Could you please add some more examples?

I have trouble figuring out where param’s come from and where they go to ....

Thanks!!!

Simple 1-bit 'Blink' to group address

Good day,

I find this an interesting topic.

I would like a simple example,
How can I simply send a 1-bit value to a group address?

for instance:
I use the 'Blink' sketch on the ESP8266, so I want a 1 or a 0 to group address 1/1/0.

I have to set the physical address via the webpage of the ESP8266 right?

Thanks for the help.

Sincerely,

Jelle Karel

Port to ESP32?

Hi,

I am very interested in this project but it would need to run on ESP32s for me. Do you have any plans to port it? Or has anybody done that already?

Thanks and best regards
Keith

Make API restful

We should make the API restful with JSON so that others can easily parse the data or configure the ESP.

Using ESP-KNX-IP Library to connect to Home Assistant

This is a workaround explanation for using ESP-KNX-IP Library to connect to Home Assistant.

The link between Home Assistant and a KNX Router, is the XKNX Python Library.

Side note:
If you don't have a KNX Router, you can use KNXd on the same Raspberry Pi than Home Assistant.

There is a bug using XKNX Library on Home Assistant, that makes XKNX Library not understanding ESP-KNX-IP (Issue XKNX/xknx#112)

While waiting for response on the XKNX issue, the checksum can be eliminated changing esp-knx-ip-send.cpp#L69 for udp.write(buf, len-1)

With this you can have a working ESP-KNX-IP Library for testing on Home Assistant until the bug is solved.

Further instructions on how to connect with existing KNX system

Hi, this project looks like a great way to add inexpensive custom devices to a KNX system. But I miss some key information on how exactly to do that. I see it uses 224.0.23.12:3671 UDP, so the ESP device acts as a coupler or something? For example I have a Weinzierl 730 ethernet gateway. How is supposed ESP device to be connected to the KNX system? And what is the role of ETS in that case?

Thanks in advance! :)

Hello, has anyone managed to get this library to work with esp32?

ATENCIÓN: la librería ESP-KNX-IP-Library_0.4_2894 pretende ejecutarse sobre arquitectura(s) esp8266 y puede ser incompatible con tu actual tarjeta la cual corre sobre arquitectura(s) esp32.
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send(const address_t&, knx_command_type_t, uint8_t, uint8_t*)':
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip-send.cpp:80:6: error: 'class WiFiUDP' has no member named 'beginPacketMulticast'
udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP());
^
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp: In member function 'void ESPKNXIP::__start()':
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp:98:67: error: no matching function for call to 'WiFiUDP::beginMulticast(IPAddress, IPAddress, int)'
udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT);
^
In file included from /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFi.h:39:0,
from /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.h:57,
from /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp:7:
/Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFiUdp.h:57:11: note: candidate: uint8_t WiFiUDP::beginMulticast(IPAddress, uint16_t)
uint8_t beginMulticast(IPAddress a, uint16_t p);
^
/Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFiUdp.h:57:11: note: candidate expects 2 arguments, 3 provided
Se encontraron varias bibliotecas para "esp-knx-ip.h"
Usado: /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894
Se encontraron varias bibliotecas para "EEPROM.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/EEPROM
Se encontraron varias bibliotecas para "WiFi.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
No usado: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Se encontraron varias bibliotecas para "AsyncUDP.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/AsyncUDP
Se encontraron varias bibliotecas para "WebServer.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WebServer
Se encontraron varias bibliotecas para "FS.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/FS
exit status 1
Error compilando para la tarjeta ESP32 Dev Module.
ATENCIÓN: la librería ESP-KNX-IP-Library_0.4_2894 pretende ejecutarse sobre arquitectura(s) esp8266 y puede ser incompatible con tu actual tarjeta la cual corre sobre arquitectura(s) esp32.
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send(const address_t&, knx_command_type_t, uint8_t, uint8_t*)':
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip-send.cpp:80:6: error: 'class WiFiUDP' has no member named 'beginPacketMulticast'
udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP());
^
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp: In member function 'void ESPKNXIP::__start()':
/Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp:98:67: error: no matching function for call to 'WiFiUDP::beginMulticast(IPAddress, IPAddress, int)'
udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT);
^
In file included from /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFi.h:39:0,
from /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.h:57,
from /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894/esp-knx-ip.cpp:7:
/Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFiUdp.h:57:11: note: candidate: uint8_t WiFiUDP::beginMulticast(IPAddress, uint16_t)
uint8_t beginMulticast(IPAddress a, uint16_t p);
^
/Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi/src/WiFiUdp.h:57:11: note: candidate expects 2 arguments, 3 provided
Se encontraron varias bibliotecas para "esp-knx-ip.h"
Usado: /Users/robertson/Documents/Arduino/libraries/ESP-KNX-IP-Library_0.4_2894
Se encontraron varias bibliotecas para "EEPROM.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/EEPROM
Se encontraron varias bibliotecas para "WiFi.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WiFi
No usado: /Applications/Arduino.app/Contents/Java/libraries/WiFi
Se encontraron varias bibliotecas para "AsyncUDP.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/AsyncUDP
Se encontraron varias bibliotecas para "WebServer.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/WebServer
Se encontraron varias bibliotecas para "FS.h"
Usado: /Users/robertson/Library/Arduino15/packages/esp32/hardware/esp32/1.0.4/libraries/FS
exit status 1
Error compilando para la tarjeta ESP32 Dev Module.

Receive messages on group 2/1/0

Hello, thanks for the great library :)
I register my switches like this way:
for (auto &item : items) { callback_id_t switchesCallbackId = knx.callback_register(String(item.name), switchesCallback, &item); knx.callback_assign(switchesCallbackId, knx.GA_to_address(2, 1, i)); i++;

the final result for 2 switches is like 2/1/1 and 2/1/2, I have any method to handle with the telegrams sent to 2/1/0 ?
if I receive on message on this group address I want to turn on/turn off all switches.

line in Physical address can not be 0

Hi,

I'm unable to configure a correct physical address 1.0.90 because in esp-knx-ip.cpp the minimum for line is set to "1":

m += F("<input class='form-control' type='number' name='line' min='1' max='15' value='");

should be

m += F("<input class='form-control' type='number' name='line' min='0' max='15' value='");

Regards, Oliver

physical address

Hello Envy,
You can explain the purpose of physical address?

Thanks for the great job

Consistent spelling of GA/PA

static address_t GA_to_address(uint8_t area, uint8_t line, uint8_t member)

static address_t PA_to_address(uint8_t area, uint8_t line, uint8_t member)

GA_to_address() and PA_to_address() are the only methods where GA and PA are spelled with capital letters. Everywhere else they are lower letters. This is a bit inconsistent and confusing.

Make webui translateable.

Extract all static strings and put them in a header.
Look other projects to find out how they do it.

ESP ETS5 registration

Hi,
How we can register esp-knx-ip to ETS5, or is there are other option how to put it in to the scenario with the rest of KNX Items?

WifiUDP.h cannot be found

Hi envy,

Thanks for this very cool library! I have a short question about the included "WifiUDP.h" in "esp-knx-ip.h". On my system this header file is written "WiFiUdp.h", and so I have to change the notation of this to compile my project. Do you use a system which is not case sensitive or do I just have another version installed? I'm using "esp8266" in version 2.4.0.

Thanks and regards,
McOrvas

physical address problems for programming in ETS5

Having solved problems encountered with the https://github.com/arendst/Tasmota version on a Sonoff basic R2,
and as I couldn't get any command results from ETS5 a priori multicast problems, I chose to install your tasmota KNX.ino version of envy / esp-knx-ip.

With this version tasmota KNX.ino esp-knx-ip. , I was able to get a command from the diagnostics mode of ETS5. With this version, with the physical address 1.1.108 the control GA 1/1/2 and the status GA 1/1/3, works.
Unfortunately, since I do not have a participant in TES5 for these GAs, except for the communicator, the Write action in the Diagnostics mode of ETS5 uses the physical address 0.0.1 by default. This is well recognized by the Sonoff Tasmota which turns on and off through the KNX bus? And the state return of the Sonoff Tasmota is done well with the physical address 1.1.108 that I declared in the parameters of the Sonoff Tasmota.
Therefore, the On or Off action, on the switch programmed in ETS5, does not activate the Sonoff Tasmota.

I will try to use the method from https://github.com/thelsing/CreateKnxProd to create an importable file.knxprod participant directly with this app.
But perhaps you would have thanks to your experience another method so that I can associate my 2 AG d in a parameterizable actuator participant directly in ETS5.
Kind regards.

Delete Functions needed

Hi @envy ,

When using and configuring the ESP-KNX-IP Library but only by code and not using the ESP-KNX-IP webpage, are needed new functions:

  • callback_delete_assignment
  • callback_delete_register

Can be added to the library?

Thanks a lot for your time! Great Library.

limited config params count?

Hi,

i have a problem with my config fields count. Is there a limit to a count or memory limit? I have the following fields set. but the last 2 are missing:

Device-Address
Hostname (String)
Update-Interval (int)
10x 1W-Address (String 16)
10x GA

Only the GAs 1-8 are there, 9 and 10 are missing. Is this there a known limit?

kindly regards

Using a webserver running before KNX Library

Hi,

To test the option of using a webserver that is already running, I modify one of the webserver examples of Arduino IDE.

First of all, it is very important to pass to the KNX Library, the already running webserver, as a pointer, so:

  • If in your program, the server is defined like:

ESP8266WebServer server ( 80 );

you have to use:

knx.start(&server);

  • If in your program, the server is defined like:
ESP8266WebServer *server;
server = new ESP8266WebServer ( 80 );

you have to use:

knx.start(server);

And also to modify the esp-knx-ip.h to have #define ROOT_PREFIX "/knx"

Following is a working example of that.


@envy, can be added the ROOT_PREFIX directly to knx.start(&server)?
To be something like knx.start(&server, "/knx");

Will be very handy that, and also there is no need of modifying the library to use this feature.

What do you think?


Example:

/*
 * Copyright (c) 2015, Majenko Technologies
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * * Redistributions of source code must retain the above copyright notice, this
 *   list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright notice, this
 *   list of conditions and the following disclaimer in the documentation and/or
 *   other materials provided with the distribution.
 *
 * * Neither the name of Majenko Technologies nor the names of its
 *   contributors may be used to endorse or promote products derived from
 *   this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

#include <esp-knx-ip.h>            // KNX Library
#define KNX_ROOT_PAGE    "/knx"    // KNX Root page. On web browser put <ip>/knx, where <ip> is the IP of the device. You can see the IP from the serial console.

const char *ssid = "SSID";
const char *password = "PASS";

ESP8266WebServer server ( 80 );

const int led = 13;

void handleRoot() {
	digitalWrite ( led, 1 );
	char temp[400];
	int sec = millis() / 1000;
	int min = sec / 60;
	int hr = min / 60;

	snprintf ( temp, 400,

"<html>\
  <head>\
    <meta http-equiv='refresh' content='5'/>\
    <title>ESP8266 Demo</title>\
    <style>\
      body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }\
    </style>\
  </head>\
  <body><center>\
    <h1>Hello from ESP8266!</h1>\
    <p>Uptime: %02d:%02d:%02d</p>\
    <img src=\"/test.svg\" />\
    <br>\
    <p><a href='" KNX_ROOT_PAGE "'>KNX</a></p></center>\
  </body>\
</html>",

		hr, min % 60, sec % 60
	);
	server.send ( 200, "text/html", temp );
	digitalWrite ( led, 0 );
}

void handleNotFound() {
	digitalWrite ( led, 1 );
	String message = "File Not Found\n\n";
	message += "URI: ";
	message += server.uri();
	message += "\nMethod: ";
	message += ( server.method() == HTTP_GET ) ? "GET" : "POST";
	message += "\nArguments: ";
	message += server.args();
	message += "\n";

	for ( uint8_t i = 0; i < server.args(); i++ ) {
		message += " " + server.argName ( i ) + ": " + server.arg ( i ) + "\n";
	}

	server.send ( 404, "text/plain", message );
	digitalWrite ( led, 0 );
}

void setup ( void ) {
	pinMode ( led, OUTPUT );
	digitalWrite ( led, 0 );
	Serial.begin ( 115200 );
	WiFi.mode ( WIFI_STA );
	WiFi.begin ( ssid, password );
	Serial.println ( "" );

	// Wait for connection
	while ( WiFi.status() != WL_CONNECTED ) {
		delay ( 500 );
		Serial.print ( "." );
	}

	Serial.println ( "" );
	Serial.print ( "Connected to " );
	Serial.println ( ssid );
	Serial.print ( "IP address: " );
	Serial.println ( WiFi.localIP() );

	if ( MDNS.begin ( "esp8266" ) ) {
		Serial.println ( "MDNS responder started" );
	}

	server.on ( "/", handleRoot );
	server.on ( "/test.svg", drawGraph );
	server.on ( "/inline", []() {
		server.send ( 200, "text/plain", "this works as well" );
	} );
	server.onNotFound ( handleNotFound );
	server.begin();
	Serial.println ( "HTTP server started" );

   // Set physical address (1.1.1)
  knx.physical_address_set(knx.PA_to_address(1, 1, 1));
  knx.start(&server);
  //knx.start(&server, KNX_ROOT_PAGE);
}

void loop ( void ) {
	server.handleClient();
  knx.loop();
}

void drawGraph() {
	String out = "";
	char temp[100];
	out += "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" width=\"400\" height=\"150\">\n";
 	out += "<rect width=\"400\" height=\"150\" fill=\"rgb(250, 230, 210)\" stroke-width=\"1\" stroke=\"rgb(0, 0, 0)\" />\n";
 	out += "<g stroke=\"black\">\n";
 	int y = rand() % 130;
 	for (int x = 10; x < 390; x+= 10) {
 		int y2 = rand() % 130;
 		sprintf(temp, "<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\" stroke-width=\"1\" />\n", x, 140 - y, x + 10, 140 - y2);
 		out += temp;
 		y = y2;
 	}
	out += "</g>\n</svg>\n";

	server.send ( 200, "image/svg+xml", out);
}

Make it possible to add links to the web ui

Something like this:

// Adding a link
link_id_t link_id = knx.webui_link_add(text, link);
// Changing url
knx.webui_link_set_link(link_id, newlink);
// Changing text
knx.webui_link_set_text(link_id, newtext);
// Removing link
knx.webui_link_remove(link_id);

How do I write a "small" telegram

Hi Envy,

I try to use this great library to switch a lamp but it does not seem to work.

The log of KNXD shows these messages when I push a switch or dim with the same switch (see the first 3 log-lines). The same can be done by using the knxtool groupswrite command (I assume "s" stands for "small"):

LPDU: BC 11 82 10 0E E1 00 81 AE :L_Data low from 1.1.130 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 01 
LPDU: BC 11 83 10 0E E1 00 89 A7 :L_Data low from 1.1.131 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 09 
LPDU: BC 11 84 10 0E E1 00 88 A1 :L_Data low from 1.1.132 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write (small) 08 
LPDU: BC 11 85 10 0E E2 00 80 09 A2 :L_Data low from 1.1.133 to 2/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 09 
LPDU: BC 11 82 18 0E E2 00 80 80 24 :L_Data low from 1.1.130 to 3/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 80 

The last 2 lines are from the knxtool groupwrite command (without the "s").

Now, if i use the esp-knx-ip library and write a 1 byteInt value, the knxd log shows:

LPDU: BC 11 C8 08 0E E2 00 80 14 EA :L_Data low from 1.1.200 to 1/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 14 
LPDU: BC 11 C8 08 0E E2 00 80 00 FE :L_Data low from 1.1.200 to 1/0/14 hops: 06 T_DATA_XXX_REQ A_GroupValue_Write 00 

It looks like a "groupwrite".

So, my question is: how do I send a "small" telegram?
Here are the specs for a "small" telegram:
image

The 1byteInt looks like these specs:
image

Question on Physical Address. Manual Entry

Hi,

Setting the Physical Address by code was intended to be like the following? Or there is another way?

  // Set Physical KNX Address of ESP KNX (Optional)
  address_t physaddr;
  physaddr.pa.area=1;
  physaddr.pa.line=1;
  physaddr.pa.member=1;
  knx.physical_address_set(physaddr);

Read GA associated to callback

Is there a way to read the GA from a callback, which has been associated via web UI? I want to send to this GA manually like this:

cb_assoc = knx.callback_register("My callback", my_callback);

if (... somecondition ...) {
ga_my_callback = knx.callback_get_ga(cb_assoc);
knx.write_2byte_float(ga_my_callback, sensor_value);
}

I do not want to register (the very same) GA via config_register_ga.

Compile error with 2.5.0-beta1 - invalid operands of types 'double' and 'int' to binary 'operator&'

Auto updated to hardware 2.5.0-beta1, Arduino 1.8.5, ESP KNX IP Library 0.5.1

Error:
<..>\Documents\Arduino\libraries\esp-knx-ip-0.5.1\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_2byte_float(const address_t&, knx_command_type_t, float)':

<..>\Documents\Arduino\libraries\esp-knx-ip-0.5.1\esp-knx-ip-send.cpp:136:22: error: invalid operands of types 'double' and 'int' to binary 'operator&'

long m = round(v) & 0x7FF;

                  ^

....
exit status 1
Error compiling for board Generic ESP8266 Module.

ESP32

Hi Envy, thanks for your great work!

This library not work with ESP32.
How change for ESP32 board?

[ Question ] Sending and receiving a float type value

Hi Nico,

How are you?

I want to use your library to send and receive a float type value.

For sending a I use the send_2byte_float() function that works great. It is being received by KNX without any problem.

Now I want to do the other way round. To receive a float type value. Do you have the code to transform the mantisa from the KNX DPT to a float value? When a float is received, the msg.data_len is 3, but the msg.data[0] is always zero. So all the 2byte float is in msg.data[2] and msg.data[1].

So my question is if you have the fragment of code to decode msg.data[2] and msg.data[1] into a float variable ?

Thanks,

Adrian

warnings during compiling

Hi,

When compiling on Arduino IDE, there are some warnings.

The compile ends OK and the Software run without problems. But these warnings need to be addresed in any way?

Arduino Build Console Output:

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_1bit(const address_t&, knx_command_type_t, uint8_t)':

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:75:23: warning: narrowing conversion of '(((int)bit) & 1)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {bit & 0b00000001};

                       ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_2bit(const address_t&, knx_command_type_t, uint8_t)':

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:81:26: warning: narrowing conversion of '(((int)twobit) & 3)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {twobit & 0b00000011};

                          ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_4bit(const address_t&, knx_command_type_t, uint8_t)':

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:87:27: warning: narrowing conversion of '(((int)fourbit) & 15)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {fourbit & 0b00001111};

                           ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_3byte_time(const address_t&, knx_command_type_t, uint8_t, uint8_t, uint8_t, uint8_t)':

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:134:50: warning: narrowing conversion of '(((((int)weekday) << 5) & 255) + (((int)hours) & 31))' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {0x00, (((weekday << 5) & 0xE0) + (hours & 0x1F)), minutes & 0x3F, seconds & 0x3F};

                                                  ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:134:77: warning: narrowing conversion of '(((int)minutes) & 63)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {0x00, (((weekday << 5) & 0xE0) + (hours & 0x1F)), minutes & 0x3F, seconds & 0x3F};

                                                                             ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:134:93: warning: narrowing conversion of '(((int)seconds) & 63)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {0x00, (((weekday << 5) & 0xE0) + (hours & 0x1F)), minutes & 0x3F, seconds & 0x3F};

                                                                                             ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp: In member function 'void ESPKNXIP::send_3byte_date(const address_t&, knx_command_type_t, uint8_t, uint8_t, uint8_t)':

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:140:29: warning: narrowing conversion of '(((int)day) & 31)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {0x00, day & 0x1F, month & 0x0F, year};

                             ^

C:\Users\Usuario\Documents\Arduino\libraries\esp-knx-ip-master\esp-knx-ip-send.cpp:140:43: warning: narrowing conversion of '(((int)month) & 15)' from 'int' to 'uint8_t {aka unsigned char}' inside { } [-Wnarrowing]

  uint8_t buf[] = {0x00, day & 0x1F, month & 0x0F, year};

                                           ^

On AyncUDP branch, Callbacks don't work with knx.start(nullptr)

Hi,

On the AyncUDP branch, if I start ESP-KNX-IP with knx.start(WebServer); or with knx.start(); the library works perfectly.

But if I use the non webserver version: knx.start(nullptr);, callbacks don't work. Nevertheless, in this mode I can send telegrams without problem but I can not receive any.

What can I do?

Please add knx.stop()

Hi,

As there is a knx.start() should be also a knx.stop() that stops the UDP connection. Not the webserver.

What do you think of adding this?

Phy and group adresses

Hi. I have checked your code and example - great working ! Thank you.
One small thing: Please use the standard syntax fpr physical adresses with pots like 0.0.1 in your webpage. Group adresses with slashes like 0/0/1. It makes things more clear :-)

For finalization it would be great to seperate the webserver implementation and the KNX finctionality.

best regards, Peter

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.