Closed alexbk66 closed 5 years ago
This looks interesting. Can you tell me what this is doing?
This prints discovered service.TxtRecord
Only when service is discovered first time, after mDNS works
It looks like the = on lines 1 through 10 was added by accident. This is C#?
The "=" is just from ToString() function:
public override string ToString()
{
return String.Format("{0} = {1}", Key, ValueString);
}
Which means that record["data1"] = {"switch":"on"
And the rest of json string goes to record keys, not values
Yes, it's C#
What's the record separator in json string? It should be comma, but it looks like you have something else, i.e. new line.
BTW, I noticed in your code sometimes ^M which means you are editing in Windows which appends ^L^M and on Linux new line is just ^L
data1 = {"switch":"on","startup":"stay", "pulse" :"off","sledOnline" :"on" ,"pulseWidth" :500 ,"rssi" :-57} seq = 43 apivers = 1 type = diy_plug id = 100086f61b txtvers = 1
@alexbk66 data1 values json-formatted objects,You have to explain it again?
I know, that's the problem - it should be json comma separated, but it's obviously not - since Mono.Zeroconf returns them split in separate records.
I'm trying to help you - testing your code! It's not really nice to outsource testing to your cutomers why actually pay for your devices. It's not opensource project....
I mean our current 3.3.0 device code is using standard json, TxtRecord parsing error.
I'm debugging now
I found that Mono.Zeroconf.Providers.AvahiDBus.TxtRecord parsing uses the following pattern, which obviously splits the record on comma. No idea why. I contacted the author, see if he replies.
For now I just commented out this code - and it works....
static Regex item_regex = new Regex (@"""[^""]*""|[^,]+", RegexOptions.IgnorePatternWhitespace);
foreach (Match item_match in item_regex.Matches (encoding.GetString (raw_item)))
{
Using Mono.Zeroconf discovery when service is found - 'data1' gets split into 11 records, instead of single string:
0: data1 = {"switch":"on" 1: "startup" = 2: :"stay" = 3: "pulse" = 4: :"off" = 5: "sledOnline" = 6: :"on" = 7: "pulseWidth" = 8: :500 = 9: "rssi" = 10: :-57} = 11: seq = 43 12: apivers = 1 13: type = diy_plug 14: id = 100086f61b 15: txtvers = 1