Add Softap Module 13/181113/2
authorjunkyu han <junkyu.han@samsung.com>
Fri, 8 Jun 2018 07:53:35 +0000 (16:53 +0900)
committerjunkyu han <junkyu.han@samsung.com>
Mon, 11 Jun 2018 04:48:19 +0000 (13:48 +0900)
Change-Id: If24f3620862dffccfbdb024a64c70fcbe9da76ae

daemon/CMakeLists.txt
daemon/include/ttd-softap.h [new file with mode: 0644]
daemon/src/ttd-softap.c [new file with mode: 0644]
packaging/tizen-things-daemon.spec

index e0fe4fc..5088899 100644 (file)
@@ -14,6 +14,7 @@ pkg_check_modules(DAEMON_PKGS REQUIRED
        openssl
        capi-appfw-app-control
        vconf
+       capi-network-softap
 )
 
 FOREACH (flag ${DAEMON_PKGS_CFLAGS})
diff --git a/daemon/include/ttd-softap.h b/daemon/include/ttd-softap.h
new file mode 100644 (file)
index 0000000..1e8ff69
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define TTD_SOFTAP_SSID "tizen-things-service"
+
+int ttd_softap_init(void);
+void ttd_softap_fini(void);
+
diff --git a/daemon/src/ttd-softap.c b/daemon/src/ttd-softap.c
new file mode 100644 (file)
index 0000000..ecd1145
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Flora License, Version 1.1 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://floralicense.org/license/
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <softap.h>
+#include <stdlib.h>
+
+#include "ttd-log.h"
+#include "ttd-softap.h"
+#include "ttd-config.h"
+
+softap_h sa = NULL;
+
+static void __enabler_connection_changed_cb(softap_client_h client, bool opened, void *user_data)
+{
+       _D("Enabler connection is %s", opened ? "Opened" : "Closed");
+
+       if (opened) {
+               /* Start Transfer with Enabler */
+       } else {
+               /* Can we assume that Enabler disconnect when communication is finished? */
+       }
+}
+
+static void __enabled_cb(softap_error_e result, bool is_requested, void *user_data)
+{
+       _D("SoftAP is enabled: %d", result);
+}
+
+int ttd_softap_init(void)
+{
+       if (softap_create(&sa) != SOFTAP_ERROR_NONE) {
+               _E("Failed to create SoftAP");
+               return -1;
+       }
+
+       if (softap_set_ssid(sa, TTD_SOFTAP_SSID) != SOFTAP_ERROR_NONE) {
+               _E("Failed to set ssid");
+               return -1;
+       }
+
+       if (softap_set_ssid_visibility(sa, 1) != SOFTAP_ERROR_NONE) {
+               _E("Failed to set ssid visibility");
+               return -1;
+       }
+
+       if (softap_set_security_type(sa, 1) != SOFTAP_ERROR_NONE) {
+               _E("Failed to set security type");
+               return -1;
+       }
+
+       if (softap_set_passphrase(sa, "aaaaaaaa") != SOFTAP_ERROR_NONE) {
+               _E("Failed to set pass passphrase");
+               return -1;
+       }
+
+       if (softap_set_enabled_cb(sa, __enabled_cb, NULL) != SOFTAP_ERROR_NONE) {
+               _E("Failed to set enabled_cb");
+               return -1;
+       }
+
+       if (softap_enable(sa) != SOFTAP_ERROR_NONE) {
+               _E("Failed to enable SoftAP");
+               return -1;
+       }
+
+       if (softap_set_client_connection_state_changed_cb(sa, __enabler_connection_changed_cb, NULL) != SOFTAP_ERROR_NONE) {
+               _E("Failed to set client connection changed callback for Enabler");
+               return -1;
+       }
+
+       return 0;
+}
+
+void ttd_softap_fini(void)
+{
+       softap_unset_client_connection_state_changed_cb(sa);
+
+       softap_disable(sa);
+
+       softap_destroy(sa);
+
+       sa = NULL;
+}
index 0ddb682..9eb8068 100644 (file)
@@ -21,6 +21,7 @@ BuildRequires:  pkgconfig(openssl)
 BuildRequires:  pkgconfig(capi-appfw-app-control)
 BuildRequires:  pkgconfig(capi-appfw-app-common)
 BuildRequires:  pkgconfig(vconf)
+BuildRequires:  pkgconfig(capi-network-softap)
 
 %description
 Tizen Things daemon