예제 #1
0
void
rest_init(void)
{
  list_init(restful_services);

#ifdef WITH_COAP
  coap_set_service_callback(rest_invoke_restful_service);
#else /*WITH_COAP*/
  http_set_service_callback(rest_invoke_restful_service);
#endif /*WITH_COAP*/

  /*Start rest framework process*/
  process_start(&rest_manager_process, NULL);
}
CoapInfo * coap_Init(const char * ipAddress, int port, bool secure, int logLevel)
{
    Lwm2m_Info("Bind port: %d\n", port);
    memset(CurrentTransaction, 0, sizeof(CurrentTransaction));
    memset(Observations, 0, sizeof(Observations));
    coap_init_transactions();
    coap_set_service_callback(coap_HandleRequest);
    DTLS_Init();
    if (secure)
    	networkSocket = NetworkSocket_New(NetworkSocketType_UDP | NetworkSocketType_Secure, port);
    else
    	networkSocket = NetworkSocket_New(NetworkSocketType_UDP, port);
    if (networkSocket)
    {
        if (NetworkSocket_StartListening(networkSocket))
        {
            coapInfo.fd = NetworkSocket_GetFileDescriptor(networkSocket);
        }
    }
    return &coapInfo;
}