Created
February 3, 2016 18:06
-
-
Save gabrielschulhof/b4f8a423983e83d9d7ae to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <sol-coap.h> | |
#include <sol-oic-client.h> | |
#include <sol-mainloop.h> | |
struct sol_oic_client client; | |
static bool no_payload(void *data, struct sol_oic_map_writer *map) { | |
return true; | |
} | |
static void receive_callback( | |
sol_coap_responsecode_t response_code, | |
struct sol_oic_client *cli, | |
const struct sol_network_link_addr *addr, | |
const struct sol_oic_map_reader *repr_vec, | |
void *data) { | |
printf("GET request has returned\n"); | |
} | |
static bool resource_found( | |
struct sol_oic_client *cli, | |
struct sol_oic_resource *res, | |
void *data) { | |
if (!strncmp(res->href.data, sol_argv()[1], res->href.len)) { | |
printf( "sol_oic_client_resource_request(): %s\n", | |
sol_oic_client_resource_request(cli, res, SOL_COAP_METHOD_GET, | |
no_payload, NULL, receive_callback, NULL) ? "true" : "false" ); | |
return false; | |
} | |
return true; | |
} | |
void startup() { | |
#ifdef SOL_OIC_CLIENT_API_VERSION | |
client.api_version = SOL_OIC_CLIENT_API_VERSION; | |
#endif /* def SOL_OIC_CLIENT_API_VERSION */ | |
client.server = sol_coap_server_new(0); | |
client.dtls_server = NULL; | |
struct sol_network_link_addr addr; | |
addr.family = SOL_NETWORK_FAMILY_INET; | |
addr.port = 5683; | |
sol_network_addr_from_str(&addr, "224.0.1.187"); | |
printf( "sol_oic_client_find_resource(): %s\n", | |
sol_oic_client_find_resource(&client, &addr, "", resource_found, | |
NULL) ? "true" : "false" ); | |
} | |
void shutdown() {} | |
SOL_MAIN_DEFAULT(startup, shutdown); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
06:00.682 DEBUG: IP_ADAP: IN | |
06:00.682 DEBUG: IP_ADAP: Address: 192.168.1.45, port:45204 | |
06:00.682 DEBUG: CA_INTRFC_CNTRLR: IN | |
06:00.682 DEBUG: CA_MSG_HNDLR: received pdu data : | |
06:00.682 DEBUG: CA_MSG_HNDLR: 48 01 98 A4 CF 58 4D CD 22 B0 62 32 B1 61 0D 05 | |
06:00.682 DEBUG: CA_MSG_HNDLR: 68 69 67 68 2D 6C 65 76 65 6C 2D 65 78 61 6D 70 | |
06:00.682 DEBUG: CA_MSG_HNDLR: 6C 65 11 3C FF | |
06:00.682 DEBUG: CA_PRTCL_MSG: pdu parse-transport type : 0 | |
06:00.682 DEBUG: CA_PRTCL_MSG: pdu parse ret: 0 | |
06:00.682 ERROR: CA_PRTCL_MSG: pdu parse failed | |
06:00.682 ERROR: CA_MSG_HNDLR: Parse PDU failed | |
06:00.682 DEBUG: CA_INTRFC_CNTRLR: OUT | |
06:00.682 DEBUG: IP_ADAP: OUT |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment