Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send String #70

Closed
Poseidon1982 opened this issue Jul 8, 2019 · 5 comments
Closed

Send String #70

Poseidon1982 opened this issue Jul 8, 2019 · 5 comments

Comments

@Poseidon1982
Copy link

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

@envy
Copy link
Owner

envy commented Jul 9, 2019

Hi,

I added a string sending method for DPT16. Please try it out, I did not test it.

@Poseidon1982
Copy link
Author

Many thanks Envy.

I tried to compile my sctach but it didn't work.
In the file "esp-knx-ip.h" I delete the parts "knx_command_type_t ct,".

So from:
void write_14byte_string(address_t const &receiver, knx_command_type_t ct, const char *val) { send_14byte_string(receiver, KNX_CT_WRITE, val); }

to:

void write_14byte_string(address_t const &receiver, const char *val) { send_14byte_string(receiver, KNX_CT_WRITE, val); }

Now it is compilingand tomorrow I will do a test with the sensor. I keep you posted.

Many thanks.
Poseidon

@envy
Copy link
Owner

envy commented Jul 9, 2019

Whoops, sorry.

Copy and paste error on my side. I fixed this in the repo, too.

@Poseidon1982
Copy link
Author

Hi Envy,

I tested today and now it working but I had to do some changes in esp-knx-ip-send.cpp.
Following is the change:

void ESPKNXIP::send_14byte_string(address_t const &receiver, knx_command_type_t ct, const char *val)
{
uint8_t buf[15] = {0x00};
int len = strlen(val);
if (len > 15)
{
len = 15;
}
memcpy(buf+1, val, len);
send(receiver, ct, 15, buf);
}

I got some strange values and I assume that there was something in buf. So I took the value from the examples above the file {0x00.
And the length have do be 15 otherwise ETS will not show only 13 bytes.
I don't really understand how it works so I did try and error and end up with a working result.

Many thanks
Poseidon

@envy
Copy link
Owner

envy commented Jul 11, 2019

Thanks, fixed. I forgot to initialize the array and account for the first extra byte being needed.

@envy envy closed this as completed Jul 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants