@bmanos you should declare int counter
in the header, not in the void loop()
. The way you did it I think it will be set to 0 in each loop, never reaching 120. And of course @jkandasa is right, it has to be if (counter == 120)
Best posts made by Anduril
-
RE: About battery level
Latest posts made by Anduril
-
RE: set a time delay in java operation
@jkandasa thanks a lot (again) for that tip. My transmit delay was set, but maybe 100 ms were too low for signing to finish before the next message. Now I set it to 200 ms and it seems to work according to my first tests.
Another minor question: I added Names to my sensors (which were auto-detected during node presentation if that matters), but they get overwritten with for example74522 TSF:MSG:READ,17-17-0,s=22,c=0,t=23,pt=0,l=0,sg=1:
which seems to be the complete serial incoming message for that sensor. Is this know and is there a way to avoid this name-changing? -
set a time delay in java operation
Hey there,
I have a node with multiple sensors and want to update them with a java script. I have signatures activated and us an RFM69 transmitter on my gateway.
1574774 TSF:MSG:READ,0-0-17,s=21,c=3,t=16,pt=0,l=0,sg=0: 1574793 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=17,pt=6,l=25,sg=0,ft=0,st=OK:<NONCE> 1574814 TSF:MSG:READ,0-0-17,s=21,c=1,t=24,pt=0,l=17,sg=1:10000000000000000 1574888 TSF:MSG:READ,0-0-17,s=22,c=3,t=16,pt=0,l=0,sg=1: 1574907 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=0,st=OK:<NONCE> 1574928 TSF:MSG:READ,0-0-17,s=22,c=1,t=24,pt=0,l=17,sg=1:20000000000000000 1574978 TSF:MSG:SEND,17-17-0-0,s=21,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=OK: 1574998 TSF:MSG:READ,0-0-17,s=255,c=3,t=17,pt=6,l=25,sg=1:<NONCE> 1576260 !TSF:MSG:SEND,17-17-0-0,s=21,c=1,t=24,pt=0,l=17,sg=1,ft=0,st=NACK:10000000000000000 1576273 TSF:MSG:READ,0-0-17,s=4,c=3,t=16,pt=0,l=0,sg=1: 1576294 TSF:MSG:SEND,17-17-0-0,s=255,c=3,t=17,pt=6,l=25,sg=1,ft=1,st=OK:<NONCE> 1576315 TSF:MSG:READ,0-0-17,s=4,c=1,t=24,pt=0,l=19,sg=1:Hans 1577578 !TSF:MSG:SEND,17-17-0-0,s=22,c=3,t=16,pt=0,l=0,sg=1,ft=0,st=NACK: 1577584 !TSF:MSG:SIGN FAIL
I think adding something like
Thread.sleep(x)
could solve the problem, as the signature transmission would have a little more time to avoid collission (but maybe I'm wrong). Sending them manually works absolutely fine.mcApi.sensor().sendPayload(S1); mcApi.sensor().sendPayload(S2); mcApi.sensor().sendPayload(ID); mcApi.sensor().sendPayload(Name1); mcApi.sensor().sendPayload(Name2);
Is there any way to insert a kind of delay in a script?
Regards,
Anduril -
RE: possible to read xml file in custom widget?
This feature is great (at least for my usage). Is it also possible to update the values in the xml file? I don't mean adding new nodes or other fancy stuff, only updating for example
/student/details/class
fromThree
toFour
.
As far as I read the xpath is just a pointer in the tree of an xml, so there is no option to manipulate items. Maybe there is another function available to do this. -
assign value on user confirmation (button click)
Hi,
I have succesfully imported a bunch of values out of a xml file to variable repositories. Just to keep the topic simple and readable in future I ask this question in a new thread.
Now I want to have some kind of user confirmation (for example a click on a button) that the data was checked and should be sent to the nodes. I can write a simple script to assign the values from the repositories to the sensor values (by their UUID), but I don't know how to activate that script by butten or other user input.Regards,
Anduril -
RE: possible to read xml file in custom widget?
wow that's great... thanks a lot.
-
RE: possible to read xml file in custom widget?
Thanks a lot, it works that way. Now my next problem is how to find specific information in this data. I could try to parse line by line, as I have a fixed structure. But maybe it would be easier to create a generic xml parsing mechanism. This would also allow for easier export to xml (my next step when reading works flawless).
-
RE: possible to read xml file in custom widget?
thanks @jkandasa, it was probably a problem solved with the most recent snapshot. I updated and it works now with the online xml.
Using a local xml still yields an error, I think there is an error in my call...var myImports = new JavaImporter(java.io, java.lang, java.util, java.text); with(myImports) { var response = mcApi.http().get("c:/file-xml-demo.xml"); if(response.responseCode == 200){ var xmlData = response.entity; } }
using [...]get("c:\file-[...] does not work either, so it's not a problem with slash and backslash.
The html file only contains this:${xmlData}
Using the
run now
option I get this error:TypeError: Cannot get property "responseCode" of null in at line number 5
-
RE: possible to read xml file in custom widget?
well I did also tried your example code and it seems
mcApi.http().get
does not work correctly...TypeError: mcApi.http is not a function in at line number 4
-
RE: possible to read xml file in custom widget?
well the way to access the data is (in my case) not important, I could also use a static parser. I want to open several xml files with all the same structure and extract the data to mycontroller variables. Those could be read and processed in a second step by another script.
-
RE: possible to read xml file in custom widget?
hi,
is it also possible to read a local xml file? And how can I access the different information in the file, are they transfered to the xmlData as options? So would this file:
<?xml version="1.0" encoding="UTF-8"?> <name id="1"> <first>John</first> <last>Doe</last> </name>
be read as for example
xmlData.name.first