Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

HC3 Quickapp


morsink

Question

Can some one help with a code in the Quick app that makes buttons(keys) for the next code:

 

function QuickApp:onInit()

  local payload = "FF0100" 

  self.udp = net.UDPSocket({

    broadcast = true,

    timeout = 5000

  })

  self.udp:sendTo(payload, "192.168.2.48", 12345, {

    success = function()

      self:debug("UDP message sent!")

    end,

    error = function(error)

      self:debug("Error sending UDP message:", error)

    end

  })

end

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Can't finde a solution or documentation.
    I wanne send a UDP message when I press a button.

    Next is working: 

    function QuickApp:onInit()

      local payload = "FF0100" 

      self.udp = net.UDPSocket({

        broadcast = true,

        timeout = 5000

      })

      self.udp:sendTo(payload, "192.168.2.48", 12345, {

        success = function()

          self:debug("UDP message sent!")

          self:updateView("label", "text", "UDP message sent!")

          self:updateView("button1", "text", "UDP message sent!")

        end,

        error = function(error)

          self:debug("Error sending UDP message:", error)

          self:updateView("label", "text", "Error sending UDP message")

          self:updateView("button1", "text", "Error sending UDP message")

        end

      })

    end

    Link to comment
    Share on other sites

    • 0

    Create a button in de QA with the GUI:

    Please login or register to see this image.

    /monthly_2023_04/image.png.0649a0e3571526ddb2925e3335e91d98.png" />

     

    On the right side of the GUI give it a name in the Label field and give a function name in the onReleased field:

    image.png.ac04d6d0e13440629319db4a1ca50fe1.png

     

    In my example for you I named the function sendUdpMessage, now in the code add a function for the button handler: QuickApp:sendUdpMessage:

     

    Please login or register to see this code.

     

    To wrap it up with your code:

    Please login or register to see this code.

     

    • Like 2
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Thanks Joep for your message. It works!!!!, now can I optimize for the rest of my UDP message;)

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Please login or register to see this attachment.

    KMTTronic UDP Relay QuickApp

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...