Tizen IoT Extension SDK 1.0
1.0.1
|
00001 /***************************************************************** 00002 * 00003 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 ******************************************************************/ 00018 00019 00020 #ifndef __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_H__ 00021 #define __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_H__ 00022 00023 #include <stdlib.h> 00024 #include <stdbool.h> 00025 #include <tizen.h> 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00040 #define SMARTTHINGS_SSID_LEN_MAX 32 00041 00046 #define SMARTTHINGS_CLOUD_INFO_LEN_MAX 128 00047 00052 typedef enum { 00053 SMARTTHINGS_ERROR_NONE = TIZEN_ERROR_NONE, 00054 SMARTTHINGS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, 00055 SMARTTHINGS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, 00056 SMARTTHINGS_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, 00057 SMARTTHINGS_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, 00058 SMARTTHINGS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, 00059 SMARTTHINGS_ERROR_OPERATION_FAILED = TIZEN_ERROR_UNKNOWN - 1, 00060 SMARTTHINGS_ERROR_SERVICE_UNAVAILABLE = TIZEN_ERROR_UNKNOWN -2 00061 } smartthings_error_e; 00062 00067 typedef enum { 00068 SMARTTHINGS_STATUS_NOT_READY = -1, 00069 SMARTTHINGS_STATUS_INIT = 0, 00070 SMARTTHINGS_STATUS_ES_STARTED, 00071 SMARTTHINGS_STATUS_ES_DONE, 00072 SMARTTHINGS_STATUS_ES_FAILED_ON_OWNERSHIP_TRANSFER, 00073 SMARTTHINGS_STATUS_CONNECTING_TO_AP, 00074 SMARTTHINGS_STATUS_CONNECTED_TO_AP, 00075 SMARTTHINGS_STATUS_CONNECTING_TO_AP_FAILED, 00076 SMARTTHINGS_STATUS_REGISTERING_TO_CLOUD, 00077 SMARTTHINGS_STATUS_REGISTERED_TO_CLOUD, 00078 SMARTTHINGS_STATUS_REGISTERING_FAILED_ON_SIGN_IN, 00079 SMARTTHINGS_STATUS_REGISTERING_FAILED_ON_PUB_RES 00080 } smartthings_status_e; 00081 00086 typedef enum { 00087 SMARTTHINGS_CONNECTION_STATUS_CONNECTED = 0, 00088 SMARTTHINGS_CONNECTION_STATUS_DISCONNECTED, 00089 SMARTTHINGS_CONNECTION_STATUS_REJECTED, 00090 } smartthings_connection_status_e; 00091 00096 typedef enum { 00097 SMARTTHINGS_WIFI_MODE_11A = (1 << 0), 00098 SMARTTHINGS_WIFI_MODE_11B = (1 << 1), 00099 SMARTTHINGS_WIFI_MODE_11G = (1 << 2), 00100 SMARTTHINGS_WIFI_MODE_11N = (1 << 3), 00101 SMARTTHINGS_WIFI_MODE_11AC = (1 << 4) 00102 } smartthings_wifi_mode_e; 00103 00108 typedef enum { 00109 SMARTTHINGS_WIFI_FREQ_24G = (1 << 0), 00110 SMARTTHINGS_WIFI_FREQ_5G = (1 << 1), 00111 } smartthings_wifi_freq_e; 00112 00117 typedef enum { 00118 SMARTTHINGS_WIFI_AUTHTYPE_NONE = 0, 00119 SMARTTHINGS_WIFI_AUTHTYPE_WEP, 00120 SMARTTHINGS_WIFI_AUTHTYPE_WPA_PSK, 00121 SMARTTHINGS_WIFI_AUTHTYPE_WPA2_PSK 00122 } smartthings_wifi_authtype_e; 00123 00128 typedef enum { 00129 SMARTTHINGS_WIFI_ENCTYPE_NONE = 0, 00130 SMARTTHINGS_WIFI_ENCTYPE_WEP_64, 00131 SMARTTHINGS_WIFI_ENCTYPE_WEP_128, 00132 SMARTTHINGS_WIFI_ENCTYPE_TKIP, 00133 SMARTTHINGS_WIFI_ENCTYPE_AES, 00134 SMARTTHINGS_WIFI_ENCTYPE_TKIP_AES 00135 } smartthings_wifi_enctype_e; 00136 00141 typedef struct smartthings_s *smartthings_h; 00142 00147 typedef struct smartthings_ap_info_s *smartthings_ap_info_h; 00148 00153 typedef struct smartthings_device_prov_info_s *smartthings_device_prov_info_h; 00154 00159 typedef struct smartthings_cloud_info_s *smartthings_cloud_info_h; 00160 00165 typedef struct smartthings_ap_list_s *smartthings_ap_list_h; 00166 00183 typedef void (*smartthings_connection_status_cb)(smartthings_h handle, smartthings_connection_status_e status, void *user_data); 00184 00201 typedef void (*smartthings_status_changed_cb)(smartthings_h handle, smartthings_status_e status, void *user_data); 00202 00218 typedef void (*smartthings_user_confirm_cb)(smartthings_h handle, void *user_data); 00219 00235 typedef void (*smartthings_reset_confirm_cb)(smartthings_h handle, void *user_data); 00236 00253 typedef void (*smartthings_reset_result_cb)(smartthings_h handle, bool result, void *user_data); 00254 00273 typedef void (*smartthings_pin_generated_cb)(smartthings_h handle, const char* pin, size_t size, void *user_data); 00274 00290 typedef void (*smartthings_pin_display_close_cb)(smartthings_h handle, void *user_data); 00291 00310 typedef void (*smartthings_wifi_ap_provisioning_cb)(smartthings_h handle, smartthings_ap_info_h ap_info_h, void *user_data); 00311 00330 typedef void (*smartthings_device_provisioning_cb)(smartthings_h handle, smartthings_device_prov_info_h dev_prov_h, void *user_data); 00331 00348 typedef void (*smartthings_scan_ap_cb)(smartthings_h handle, int req_id, void *user_data); 00349 00365 typedef void (*smartthings_stop_soft_ap_cb)(smartthings_h handle, void *user_data); 00366 00394 int smartthings_initialize(smartthings_h *handle, 00395 smartthings_connection_status_cb connection_status_cb, 00396 void *user_data); 00397 00412 int smartthings_deinitialize(smartthings_h handle); 00413 00433 int smartthings_start(smartthings_h handle); 00434 00454 int smartthings_stop(smartthings_h handle); 00455 00482 int smartthings_set_status_changed_cb(smartthings_h handle, 00483 smartthings_status_changed_cb status_cb, 00484 void *user_data); 00485 00505 int smartthings_unset_status_changed_cb(smartthings_h handle); 00506 00530 int smartthings_set_certificate_file(smartthings_h handle, const char *certificate, const char *private_key); 00531 00548 int smartthings_set_device_property(smartthings_h handle, const char* dev_name, int wifi_mode, int wifi_freq); 00549 00570 int smartthings_get_device_id(smartthings_h handle, char **device_id); 00571 00590 int smartthings_get_easysetup_status(smartthings_h handle, bool *is_completed); 00591 00614 int smartthings_start_easysetup(smartthings_h handle); 00615 00638 int smartthings_stop_easysetup(smartthings_h handle); 00639 00666 int smartthings_set_user_confirm_cb(smartthings_h handle, 00667 smartthings_user_confirm_cb confirm_cb, 00668 void *user_data); 00669 00689 int smartthings_unset_user_confirm_cb(smartthings_h handle); 00690 00717 int smartthings_set_reset_confirm_cb(smartthings_h handle, 00718 smartthings_reset_confirm_cb confirm_cb, 00719 void *user_data); 00720 00740 int smartthings_unset_reset_confirm_cb(smartthings_h handle); 00741 00768 int smartthings_set_reset_result_cb(smartthings_h handle, 00769 smartthings_reset_result_cb reset_result_cb, 00770 void *user_data); 00771 00791 int smartthings_unset_reset_result_cb(smartthings_h handle); 00792 00793 00823 int smartthings_set_pin_cb(smartthings_h handle, 00824 smartthings_pin_generated_cb generated_cb, 00825 smartthings_pin_display_close_cb close_cb, 00826 void *user_data); 00827 00847 int smartthings_unset_pin_cb(smartthings_h handle); 00848 00875 int smartthings_set_wifi_ap_provisioning_cb(smartthings_h handle, 00876 smartthings_wifi_ap_provisioning_cb wifi_ap_cb, 00877 void *user_data); 00878 00898 int smartthings_unset_wifi_ap_provisioning_cb(smartthings_h handle); 00899 00926 int smartthings_set_device_provisioning_cb(smartthings_h handle, 00927 smartthings_device_provisioning_cb dev_prov_cb, 00928 void *user_data); 00929 00949 int smartthings_unset_device_provisioning_cb(smartthings_h handle); 00950 00978 int smartthings_set_scan_ap_cb(smartthings_h handle, 00979 smartthings_scan_ap_cb scan_ap_cb, 00980 void *user_data); 00981 01001 int smartthings_unset_scan_ap_cb(smartthings_h handle); 01002 01029 int smartthings_set_stop_soft_ap_cb(smartthings_h handle, 01030 smartthings_stop_soft_ap_cb stop_soft_ap_cb, 01031 void *user_data); 01032 01052 int smartthings_unset_stop_soft_ap_cb(smartthings_h handle); 01053 01076 int smartthings_send_user_confirm(smartthings_h handle, bool confirm); 01077 01078 01101 int smartthings_send_reset_confirm(smartthings_h handle, bool confirm); 01102 01124 int smartthings_reset(smartthings_h handle); 01125 01144 int smartthings_apinfo_get_ssid(smartthings_ap_info_h ap_info_h, char **ssid); 01145 01164 int smartthings_apinfo_get_password(smartthings_ap_info_h ap_info_h, char **pwd); 01165 01182 int smartthings_apinfo_get_authtype(smartthings_ap_info_h ap_info_h, smartthings_wifi_authtype_e *authtype); 01183 01200 int smartthings_apinfo_get_enctype(smartthings_ap_info_h ap_info_h, smartthings_wifi_enctype_e *enctype); 01201 01218 int smartthings_apinfo_get_channel(smartthings_ap_info_h ap_info_h, int *channel); 01219 01238 int smartthings_devinfo_get_language(smartthings_device_prov_info_h dev_prov_h, char **language); 01239 01258 int smartthings_devinfo_get_country(smartthings_device_prov_info_h dev_prov_h, char **country); 01259 01278 int smartthings_devinfo_get_datetime(smartthings_device_prov_info_h dev_prov_h, char **datetime); 01279 01297 int smartthings_aplist_create(smartthings_ap_list_h *ap_list_h, unsigned int count); 01298 01312 int smartthings_aplist_destroy(smartthings_ap_list_h ap_list_h); 01313 01330 int smartthings_aplist_set_ssid(smartthings_ap_list_h ap_list_h, int idx, const char *ssid); 01331 01348 int smartthings_aplist_set_bssid(smartthings_ap_list_h ap_list_h, int idx, const char *bssid); 01349 01366 int smartthings_aplist_set_authtype(smartthings_ap_list_h ap_list_h, int idx, smartthings_wifi_authtype_e authtype); 01367 01384 int smartthings_aplist_set_enctype(smartthings_ap_list_h ap_list_h, int idx, smartthings_wifi_enctype_e enctype); 01385 01402 int smartthings_aplist_set_channel(smartthings_ap_list_h ap_list_h, int idx, int channel); 01403 01420 int smartthings_aplist_set_signal_level(smartthings_ap_list_h ap_list_h, int idx, int signal_level); 01421 01438 int smartthings_aplist_set_max_rate(smartthings_ap_list_h ap_list_h, int idx, int max_rate); 01439 01465 int smartthings_send_ap_list(smartthings_h handle, smartthings_ap_list_h ap_list_h, int req_id); 01466 01483 int smartthings_cloudinfo_create(smartthings_cloud_info_h *cloud_info_h); 01484 01498 int smartthings_cloudinfo_destroy(smartthings_cloud_info_h cloud_info_h); 01499 01515 int smartthings_cloudinfo_set_region(smartthings_cloud_info_h cloud_info_h, const char *region); 01516 01529 int smartthings_cloudinfo_set_auth_provider(smartthings_cloud_info_h cloud_info_h, const char *auth_provider); 01530 01543 int smartthings_cloudinfo_set_access_token(smartthings_cloud_info_h cloud_info_h, const char *access_token); 01544 01557 int smartthings_cloudinfo_set_refresh_token(smartthings_cloud_info_h cloud_info_h, const char *refresh_token); 01558 01571 int smartthings_cloudinfo_set_user_id(smartthings_cloud_info_h cloud_info_h, const char *user_id); 01572 01585 int smartthings_cloudinfo_set_client_id(smartthings_cloud_info_h cloud_info_h, const char *client_id); 01586 01606 int smartthings_sign_up_cloud(smartthings_h handle, smartthings_cloud_info_h cloud_info_h); 01607 01626 int smartthings_set_preconfigured_pin(smartthings_h handle, const char* pin); 01627 01646 int smartthings_set_mot_status(smartthings_h handle, bool enable); 01647 01652 #ifdef __cplusplus 01653 } 01654 #endif 01655 01656 #endif /* __SAMSUNG_EXPERIENCE_SERVICE_SMARTTHINGS_H__ */