Unsure what format to enter in reply

Hi all , first time poster..

i have a working sketch that is a tcpserver , when a client connects and sends its data i have to reply with following

Expected response:

[P]<0x00><1 byte polling interval in minutes> ACK CR LF

Here, the square brackets are literal. The polling interval is a byte value, not an ASCII digit.

Im unsure howto do the 1 byte time - to return 2 mins as the interval to client.

i have tried a few methods .. but its not updating the client.

im currently sending this
client.println("[P]x00\00000010\x06\x0d\x0e");

Can anyone help

Best regards

and not:

client.println("[P]x00\x02\x06\x0d\x0e");

????

client.println("[P]x00\x02\x06\x0d\x0e");
Doesnt Work either , client is given 512 minutes with this example

You seem to know things that we don't. Please share the reason with us so that we can understand. Is there any reference for the protocol you are trying to match?

Perhaps the client expects the x to be preceded by 0. It is conventional to precede hex values by 0x. Therefore maybe:

client.println("[P]0x00\0x02\0x06\0x0d\0x0e");

Is there a document for the client you can point us to? It seems odd to me that everything is specified in hex except for the [P]. What does the client send you? Is it in ASCII? Are you sure this is not a binary protocol?

Hi , this is what im trying to do ,
https://www.mike-stirling.com/notes/texecom-premier-alarm-signalling-protocol/

You can't have a null character (\x00 or \0) in a string. You have to use .write() with "char *, int" arguments where the 'int' is the number of characters. I think this will work:
client.write("[P]\x00\x02\x06\x0d\x0a", 8);

I don't know where they got 0x0E for LF (Linefeed). It's 0x0A. 0x0E is SO (Shift Out)

1 Like

No still no joy , panel still thinks its being given a 512 mins.

See reply #5

client.write("[P]\x00\x02\x06\x0d\x0a", 8); tried
and also tried
client.write("[P]\0x00\0x02\0x06\0x0d\0x0a", 8);
Still no joy

this is taken from a working python script

self.request.send(b'[P]\x00' + bytes([interval]) + b'\x06\r\n')

What is in bytes[interval]?

Configuration defaults

DEFAULTS = {
'server' : {
'host' : '0.0.0.0',
'port' : 10500,
'log_file' : '/tmp/alarmserver.log',
'pid_file' : '/tmp/alarmserver.pid',
},
'alarm' : {
'polling_interval' : 2,
'max_misses' : 1,
'account_file' : '/etc/alarmserver/accounts.conf'
},
'mqtt' : {
'host' : '127.0.0.1',
'port' : 1883,
'username' : None,
'password' : None,
'cafile' : None

from working python script , the gent mentioned in the above link has a server and client on git hub , im trying to mimick the server on esp8266.

"[ P ] \0 x 0 0 \0 x 0 2 \0 x 0 6 \0 x 0 d \0 x 0 a"
That is 22 characters.

client.write("[P]\0x00\0x02\0x06\0x0d\0x0a", 22);
That did not work .

Thanks this actually was the answer ,

Reply 7:

Reply #16:

So what went wrong when you said in Reply 8:

and in Reply #10:

Heh. The documentation link OP provided actually says "LF = 0x0e"...
(What HORRIBLE documentation, BTW!)

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.