[ENROLLEE] Tizen enrollee sample application build using scons command
[platform/upstream/iotivity.git] / service / easy-setup / sdk / enrollee / src / softap.cpp
1 //      http://www.apache.org/licenses/LICENSE-2.0
2 //
3 // Unless required by applicable law or agreed to in writing, software
4 // distributed under the License is distributed on an "AS IS" BASIS,
5 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
6 // See the License for the specific language governing permissions and
7 // limitations under the License.
8 //
9 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
10
11 /**
12  * These are adapter APIs will make caller modules agnostic to platform.
13  */
14
15 #include "softapnative.h"
16 #include "easysetup.h"
17 #include "softap.h"
18 #include "networkhandler.h"
19
20 void ESCreateSoftapCallback(int result, const char *ip, const char* mac_addr,
21                                                             const char* device_name );
22
23 NetworkEventCallback gCallback;
24
25 /**
26  * It will return Device which is creating Soft AP ;  Devices are identified by their role.
27  * i.e.Enrollee or Mediator.
28  */
29 DeviceRole ESSoftapHost()
30 {
31     // TODO: To implement
32     return ENROLLEE;
33 }
34
35 /**
36  * It will return true if the Soft AP is created at Enrollee device
37  */
38 bool ESSoftapAtEnrollee()
39 {
40     return ( ESSoftapHost() == ENROLLEE) ? true : false;
41 }
42
43 /**
44  * It will return true if the Soft AP is created at Mediator device
45  */
46 bool ESSoftapAtMediator()
47 {
48     return (ESSoftapHost() == MEDIATOR) ? true : false;
49 }
50
51
52 /**
53  * This API will map result returned from the native to the caller.
54  * Callback API's signature needs to be modified under build switch according
55  * to the underline platform.
56  */
57 void ESCreateSoftapCallback(int result, const char *ip, const char* mac_addr,
58                                                                 const char* device_name)
59 {
60     if(SOFTAP_SUCCESS ==  result) //on Success
61     {
62         gCallback(ES_OK);
63     }
64     else //on Failure
65     {
66         gCallback(ES_ERROR);
67     }
68 }
69
70 /**
71  * This API will create the softap at enrollee
72  */
73 void ESCreateSoftap(const char * ssid, const char* passwd, NetworkEventCallback cb)
74 {
75     gCallback = cb;
76
77     // TODO: To be implemented
78     // Create Soft AP through native APIs -- start
79     // native API call by and pass ESCreateSoftapCallback() as callback
80     ESCreateSoftapNative(ssid, passwd,ESCreateSoftapCallback);
81     // Create Soft AP through native APIs -- end
82 }
83