Coder Social home page Coder Social logo

Comments (5)

jkralik avatar jkralik commented on September 24, 2024

Pls could you try to use go-coap/v2 . This version allows you to set any option.

from go-coap.

beriberikix avatar beriberikix commented on September 24, 2024

I was able to confirm that this works in v2!

from go-coap.

jkralik avatar jkralik commented on September 24, 2024

Thx for info ;).

from go-coap.

beriberikix avatar beriberikix commented on September 24, 2024

I'm trying to put together a sample using the new V2 syntax and I'm finding a few different ways to construct a request. If I create a connection using udp.Dial(), how should I generate the message options for say a Get()? One challenge is that there is no NewMessage() if connection is created with udp., unlike coap..

Forgive me if that's a naive q, still a novice Gopher here :)

from go-coap.

jkralik avatar jkralik commented on September 24, 2024

No problem. This is a example for udp - for tcp it is very similar (just replace string udp by tcp in import).

import "github.com/go-ocf/go-coap/v2/udp/message/pool"

...
c, err := udp.Dial("127.0.0.1:1234")
req := pool.AcquireMessage(ctx)
req.SetCode(code)
req.SetToken(token)
req.SetPath(path)
req.AddQuery("if=abc")
req.SetOptionBytes
req.SetOptionString
req.AddOptionString
req.SetOptionUint32
req.AddOptionUint32
...
resp, err := c.Do(req) // or  err := c.WriteMessage(req) 
...

from go-coap.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.