Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions | Variables
simple-server.c File Reference
#include <errno.h>
#include <fcntl.h>
#include <linux/kd.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <unistd.h>
#include "sol-log.h"
#include "sol-mainloop.h"
#include "sol-network.h"
#include "sol-str-slice.h"
#include "sol-vector.h"
#include "sol-coap.h"

Data Structures

struct  light_context
 

Macros

#define DEFAULT_UDP_PORT   5683
 
#define OC_CORE_ELEM_JSON_END   "}}]}"
 
#define OC_CORE_ELEM_JSON_START   "{\"oc\":[{\"href\":\"%s\",\"rep\":{"
 
#define OC_CORE_JSON_SEPARATOR   ","
 
#define OC_CORE_PROP_JSON_BOOLEAN   "\"%s\":%s"
 
#define OC_CORE_PROP_JSON_NUMBER   "\"%s\":%d"
 
#define OC_CORE_PROP_JSON_STRING   "\"%s\":\"%s\""
 

Functions

static bool get_scrolllock_led (void)
 
static int light_method_get (void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 
static int light_method_put (void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
 
static int light_resource_to_rep (const struct sol_coap_resource *resource, bool state, struct sol_buffer *buf)
 
int main (int argc, char *argv[])
 
static void set_scrolllock_led (bool on)
 
static bool update_light (void *data)
 

Variables

static int console_fd
 
static struct sol_coap_resource light
 

Macro Definition Documentation

#define DEFAULT_UDP_PORT   5683

Referenced by main().

#define OC_CORE_ELEM_JSON_END   "}}]}"
#define OC_CORE_ELEM_JSON_START   "{\"oc\":[{\"href\":\"%s\",\"rep\":{"
#define OC_CORE_JSON_SEPARATOR   ","
#define OC_CORE_PROP_JSON_BOOLEAN   "\"%s\":%s"
#define OC_CORE_PROP_JSON_NUMBER   "\"%s\":%d"
#define OC_CORE_PROP_JSON_STRING   "\"%s\":\"%s\""

Function Documentation

static bool get_scrolllock_led ( void  )
static

References console_fd, and value.

Referenced by light_method_get(), and update_light().

static int light_method_get ( void *  data,
struct sol_coap_server server,
const struct sol_coap_resource resource,
struct sol_coap_packet req,
const struct sol_network_link_addr cliaddr 
)
static
static int light_method_put ( void *  data,
struct sol_coap_server server,
const struct sol_coap_resource resource,
struct sol_coap_packet req,
const struct sol_network_link_addr cliaddr 
)
static
static int light_resource_to_rep ( const struct sol_coap_resource resource,
bool  state,
struct sol_buffer buf 
)
static
int main ( int  argc,
char *  argv[] 
)
static void set_scrolllock_led ( bool  on)
static

References console_fd.

Referenced by light_method_put().

static bool update_light ( void *  data)
static

Variable Documentation

int console_fd
static
struct sol_coap_resource light
static
Initial value:
= {
.path = {
}
}
static int light_method_put(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
Definition: simple-server.c:124
If the resource should be exported in the CoRE well-known registry.
Definition: sol-coap.h:241
#define SOL_STR_SLICE_LITERAL(_s)
Helper macro to make easier to declare a string slice from a string literal.
Definition: sol-str-slice.h:62
#define SOL_STR_SLICE_EMPTY
Helper macro to make easier to declare an empty string slice.
Definition: sol-str-slice.h:72
static int light_method_get(void *data, struct sol_coap_server *server, const struct sol_coap_resource *resource, struct sol_coap_packet *req, const struct sol_network_link_addr *cliaddr)
Definition: simple-server.c:199
Examples:
/src/samples/coap/simple-server.c.