This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Is there an OpenThread UDP interface that can be called in C?

I'm trying to add custom functionality to the main.c file in openThread's cli example. I need to use udp related functions, but the otUdpOpen function requires this pointer. 

So is there an OpenThread UDP interface that can be called in C? Or may be I can pass in other pointer?

Parents Reply Children
  • Maybe I misunderstood what you meant. Do you mean we can pass in a OT instance pointer as a context pointer? 

    /**
     * Open a UDP/IPv6 socket.
     *
     * @param[in]  aInstance  A pointer to an OpenThread instance.
     * @param[in]  aSocket    A pointer to a UDP socket structure.
     * @param[in]  aCallback  A pointer to the application callback function.
     * @param[in]  aContext   A pointer to application-specific context.
     *
     * @retval OT_ERROR_NONE    Successfully opened the socket.
     * @retval OT_ERROR_FAILED  Failed to open the socket.
     *
     */
    otError otUdpOpen(otInstance *aInstance, otUdpSocket *aSocket, otUdpReceive aCallback, void *aContext);
    
     

  • Hi,

    You did not mention anything about the context pointer in your original question, so I assumed you meant the otInstance pointer. You do not need to pass a context pointer, this can be set to NULL if you do not need any context, or you can pass any other object, as it is a void pointer. The context is normally used in the callback handler to map the callback to a specific operation, etc.

    Best regards,
    Jørgen

Related