1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20 #include "CoapHttpHandler.h"
29 void handleSigInt(int signum);
32 * This method is an entry point of CoAP-HTTP Proxy.
37 printf("CoAP-HTTP proxy is starting..\n");
38 OCStackResult result = OCInit(NULL, 0, OC_SERVER);
39 if (result != OC_STACK_OK)
41 printf("Failed starting proxy\n");
45 if (CHPInitialize() != OC_STACK_OK)
47 printf("Failed to start proxy.\n");
52 printf("Proxy started successfully.\n");
54 signal(SIGINT, handleSigInt);
57 if (OCProcess() != OC_STACK_OK)
61 printf("OCStack process error\n");
66 if (CHPTerminate() != OC_STACK_OK)
68 printf("CHPTerminate failed.\n");
72 printf("CHPTerminate success.\n");
76 printf("Exiting proxy main loop...\n");
82 * This is a signal handling function for SIGINT(CTRL+C).
83 * A Resource Directory handle the SIGINT signal for safe exit.
86 * signal number of caught signal.
88 void handleSigInt(int signum)