• header.categories
    • header.recent
    • header.tags
    • header.popular
    • register
    • login

    set a time delay in java operation

    scheduled pinned locked moved General Discussion
    4 posts 2 posters 476 views 1 watching
    loading-more-posts
    • oldest-to-newest
    • newest-to-oldest
    • most-votes
    reply
    • reply-as-topic
    guest-login-reply
    deleted-message
    • A offline
      Anduril
      global:last-edited-by,

      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

      jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
      • jkandasaJ offline
        jkandasa @Anduril
        global:last-edited-by, jkandasa

        @Anduril You can set Tx delay globally in your gateway settings

        bf40e14e-ae5b-4f7e-bebd-8c46edb50322-image.png

        Still if you are looking sleep options,

        var myImports = new JavaImporter(java.io, java.lang, java.util, java.text);
        
        with(myImports) {
             Thread.sleep(500); // in milliseconds
        }
        
        one-reply-to-this-post last-reply-time reply quote 0
        • A offline
          Anduril
          global:last-edited-by,

          @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 example 74522 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?

          jkandasaJ one-reply-to-this-post last-reply-time reply quote 0
          • jkandasaJ offline
            jkandasa @Anduril
            global:last-edited-by,

            @Anduril said in set a time delay in java operation:

            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 example 74522 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?

            Yes, we have an option to lock the name. Add this property on your node.
            "lockNode": true

            For more detail have a look at https://github.com/mycontroller-org/mycontroller/issues/464

            one-reply-to-this-post last-reply-time reply quote 0
            • first-post
              last-post

            0

            online

            644

            users

            532

            topics

            3.4k

            posts
            Copyright © 2015-2025 MyController.org | Contributors | Localization