CoAP has provisions for server discovery. The Mule CoAP Client Connector has two message-processors to use these.
The Ping message-processor issues a ping request on a CoAP resource. The processor returns the Boolean true when the server has acknowledged the ping, otherwise false is returned.
Example 3. Ping example
<flow name="ping_example"> ... <coap-client:ping config-ref="my_CoAP_Client" path="/" /> <choice> <when expression="#[ payload == true ]"> <set-payload value="Ping succeeded!"/> </when> <otherwise> <set-payload value="Ping failed!"/> </otherwise> </choice> ... </flow>
The Discover message-processor requests the list of resources available on a CoAP server. The message-processor returns a collection of Weblink ( org.eclipse.californium.core.WebLink ) objects.
Example 4. Discover example
<flow name="discover_example"> ... <coap-client:discover config-ref="my_CoAP_Client" /> <foreach collection="#[payload]"> <logger message="#[payload.getURI()]" level="INFO"/> </foreach> ... </flow>