Mesh: Add Bluetooth Framework API 34/237434/1
authorAnupam Roy <anupam.r@samsung.com>
Wed, 24 Jun 2020 19:02:45 +0000 (00:32 +0530)
committerAnupam Roy <anupam.r@samsung.com>
Tue, 30 Jun 2020 11:04:15 +0000 (16:34 +0530)
This patch defines all Mesh events &
structures for sharing data between
Mesh framework and Mesh service

Change-Id: I9a29c90c7dcfc3d7187ab08f2c5c5b8f5cca96a9
Signed-off-by: Anupam Roy <anupam.r@samsung.com>
include/bluetooth-api.h
include/bluetooth-mesh-api.h [new file with mode: 0644]

index a1335c1..65216c7 100644 (file)
@@ -713,6 +713,8 @@ typedef struct {
                                                                /**< Base ID for IPSP events */
 #define BLUETOOTH_EVENT_MAP_BASE  ((int)(BLUETOOTH_EVENT_IPSP_BASE + 0x0020))
                                                                /**< Base ID for MAP events */
+#define BLUETOOTH_EVENT_MESH_BASE  ((int)(BLUETOOTH_EVENT_MAP_BASE + 0x0020))
+                                                               /**< Base ID for MAP events */
 
 /**
  * Bluetooth event type
@@ -949,6 +951,21 @@ typedef enum {
        BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL,     /* OTP Write Value Response */
        BLUETOOTH_EVENT_OTP_INDICATION, /* OTP Indication */
        BLUETOOTH_EVENT_OTC_STATE_CHANGED,              /* OTC Connection State Changed Event */
+       BLUETOOTH_EVENT_MESH_SCAN_STARTED = BLUETOOTH_EVENT_MESH_BASE,
+       BLUETOOTH_EVENT_MESH_SCAN_FINISHED,
+       BLUETOOTH_EVENT_MESH_SCAN_RESULT,
+       BLUETOOTH_EVENT_MESH_AUTHENTICATION_REQUEST,
+       BLUETOOTH_EVENT_MESH_PROVISIONING_FINISHED,
+       BLUETOOTH_EVENT_MESH_NODE_BROWSED,
+       BLUETOOTH_EVENT_MESH_NODE_VENDOR_FEATURES,
+       BLUETOOTH_EVENT_MESH_NODE_KEY_CONFIGURED,
+       BLUETOOTH_EVENT_MESH_NODE_TTL_CONFIGURED,
+       BLUETOOTH_EVENT_MESH_NODE_MODEL_APPKEY_BIND,
+       BLUETOOTH_EVENT_MESH_MODEL_APPKEY_LIST,
+       BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_LIST,
+       BLUETOOTH_EVENT_MESH_MODEL_SUBSCRIPTION_CONFGURED,
+       BLUETOOTH_EVENT_MESH_MODEL_VIRTUAL_SUBSCRIPTION_CONFGURED,
+       BLUETOOTH_EVENT_MESH_MODEL_PUBLICATION_STATUS,
 } bluetooth_event_type_t;
 
  /**
diff --git a/include/bluetooth-mesh-api.h b/include/bluetooth-mesh-api.h
new file mode 100644 (file)
index 0000000..c83a99e
--- /dev/null
@@ -0,0 +1,440 @@
+/*
+ * Bluetooth-frwk
+ *
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * @author: Anupam Roy (anupam.r@samsung.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *              http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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.
+ *
+ */
+
+#ifndef __BLUETOOTH_MESH_API_H
+#define __BLUETOOTH_MESH_API_H
+
+#include <stdint.h>
+#include <glib.h>
+#include <dlog.h>
+
+#include <bluetooth-api.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define        BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX  100
+#define        BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH       32
+#define        BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH      16
+#define        BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH    50
+#define        BLUETOOTH_MESH_AUTH_VALUE_LENGTH_MAX    50
+
+typedef enum {
+       BLUETOOTH_MESH_NODE_KEY_ADD,
+       BLUETOOTH_MESH_NODE_KEY_UPDATE,
+       BLUETOOTH_MESH_NODE_KEY_DELETE,
+} bluetooth_mesh_node_key_conf_e;
+
+typedef enum {
+       BLUETOOTH_MESH_MODEL_SUB_ADD,
+       BLUETOOTH_MESH_MODEL_SUB_DELETE,
+       BLUETOOTH_MESH_MODEL_SUB_DELETE_ALL,
+       BLUETOOTH_MESH_MODEL_SUB_OVERWRITE,
+} bluetooth_mesh_model_sub_op_e;
+
+typedef struct {
+       int event;
+       int result;
+       void *param_data;
+       void *user_data;
+} mesh_event_param_t;
+
+typedef struct {
+       uint16_t elem_index;
+       uint32_t model_id;
+} bluetooth_mesh_model_t;
+
+typedef struct {
+       uint16_t index;
+       uint16_t num_models;
+} bluetooth_mesh_element_t;
+
+typedef struct {
+       uint16_t companyid;
+       uint16_t vendorid;
+       uint16_t versionid;
+       uint16_t crpl;
+} bluetooth_mesh_vendor_info_t;
+
+typedef struct {
+       int relay;
+       int proxy;
+       int frnd;
+       int lpn;
+} bluetooth_mesh_features_t;
+
+typedef struct {
+       bluetooth_mesh_vendor_info_t vendor_info;
+       uint16_t num_elements;
+       uint16_t primary_unicast;
+       uint8_t uuid[16];
+       union {
+               uint8_t u8[8];
+               uint64_t u64;
+       } token;
+} bluetooth_mesh_node_t;
+
+
+typedef struct {
+       char token[BLUETOOTH_MESH_NETWORK_TOKEN_STRING_LENGTH +1];
+} bluetooth_mesh_token_t;
+
+typedef struct {
+       char name[BLUETOOTH_MESH_NETWORK_NAME_STRING_MAX +1];
+} bluetooth_mesh_network_name_t;
+
+typedef struct {
+       bluetooth_mesh_network_name_t name;
+       bluetooth_mesh_token_t token;
+       char uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char app_cred[BLUETOOTH_MESH_APP_UNIQUE_CRED_STRING_LENGTH + 1];
+} bluetooth_mesh_network_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       int rssi;
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint8_t oob_info[2];
+       uint8_t uri_hash[4];
+} bluetooth_mesh_scan_result_t;
+
+typedef struct {
+       uint16_t scan_time;
+} bluetooth_mesh_scan_param_t;
+
+
+typedef struct {
+       bool public_oob;
+       bool static_oob;
+       uint16_t out_oob;
+       uint16_t  in_oob;
+} bluetooth_mesh_provisioner_caps_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t unicast;
+       int count;
+       int netkey_idx;
+} bluetooth_mesh_node_discover_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t unicast;
+       int elem_count;
+       bluetooth_mesh_vendor_info_t vendor_info;
+       bluetooth_mesh_features_t features;
+} bluetooth_mesh_node_features_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t unicast;
+       uint8_t ttl;
+       bool is_set;
+} bluetooth_mesh_node_ttl_info_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t primary_unicast;
+       int elem_index;
+       uint32_t model;
+       uint16_t netkey_idx;
+       uint16_t appkey_idx;
+       uint16_t **appkey_list;
+       int appkeylist_count;
+       bool is_bind;
+
+       /* For Subscription Configuration */
+       bluetooth_mesh_model_sub_op_e op;
+       bool is_virtual_sub;
+       uint16_t sub_addr;
+       uint16_t **sub_list;
+       int sublist_count;
+
+       /* For Publication Configuration */
+       uint16_t pub_addr;
+       uint8_t ttl;
+       uint8_t period;
+       uint8_t retransmit;
+} bluetooth_mesh_model_configure_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       bool is_virtual;
+       uint16_t group_addr;
+       char label_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH +1];
+} bluetooth_mesh_network_group_info_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t primary_unicast;
+       uint16_t netkey_idx;
+       uint16_t appkey_idx;
+       bool is_netkey;
+       bluetooth_mesh_node_key_conf_e op;
+} bluetooth_mesh_key_configure_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+} bluetooth_mesh_provisioning_request_t;
+
+typedef struct {
+       int result;
+       int reason;
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       char dev_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       uint16_t unicast;
+       uint8_t count;
+} bluetooth_mesh_provisioning_result_t;
+
+typedef struct {
+       char net_uuid[BLUETOOTH_MESH_NETWORK_UUID_STRING_LENGTH + 1];
+       int auth_type;
+       char auth_value[50];
+} bluetooth_mesh_authentication_request_t;
+
+typedef struct {
+       uint16_t primary_unicast;
+       int num_elements;
+} bluetooth_mesh_node_info_t;
+
+/**
+ * Mesh Event handler callback
+ */
+typedef void (*mesh_cb_func_ptr)(int, mesh_event_param_t *, void *);
+
+/**
+ * Mesh Init
+ */
+int bluetooth_mesh_init(mesh_cb_func_ptr callback_ptr, void *user_data);
+
+/**
+ * Mesh De-Init
+ */
+int bluetooth_mesh_deinit(void);
+
+/**
+ * Create Local Mesh Network
+ */
+int bluetooth_mesh_network_create(const char *net_name,
+               bluetooth_mesh_node_t *node, uint16_t total_models,
+                       bluetooth_mesh_model_t **models,
+                               bluetooth_mesh_network_t *network);
+
+/**
+ * Load already created Network
+ */
+int bluetooth_mesh_network_load(const char *token,
+               bluetooth_mesh_network_t *network);
+
+/**
+ * Scan for Unprovisioned Devices
+ */
+int bluetooth_mesh_network_scan(bluetooth_mesh_network_t *network,
+               bluetooth_mesh_scan_param_t *scan_param);
+
+/**
+ * Cancel the ongoing Scan
+ */
+int bluetooth_mesh_network_cancel_scan(bluetooth_mesh_network_t *network);
+
+/**
+ * Set Local Network Provisioning Capabilities
+ */
+int bluetooth_mesh_network_set_capabilities(
+               bluetooth_mesh_network_t *network,
+                       bluetooth_mesh_provisioner_caps_t *caps);
+
+/**
+ * Povision a Device
+*/
+int bluetooth_mesh_network_provision_device(
+               bluetooth_mesh_provisioning_request_t *req);
+
+/**
+ * Reply to Authentication request
+ */
+int bluetooth_mesh_authentication_reply(int auth_type,
+               const char *auth_val, gboolean reply);
+
+/**
+ * Set Local Mesh Network name
+ */
+int bluetooth_mesh_network_set_name(bluetooth_mesh_network_t *network);
+
+/**
+ * Add Subnet key in local Network
+ */
+int bluetooth_mesh_network_add_netkey(bluetooth_mesh_network_t *network,
+               uint16_t *netkey_idx);
+
+/**
+ * Delete Subnet key in local Network
+ */
+int bluetooth_mesh_network_delete_netkey(
+               bluetooth_mesh_network_t *network, uint16_t netkey_idx);
+
+/**
+ * Update Subnet key in local Network
+ */
+int bluetooth_mesh_network_update_netkey(bluetooth_mesh_network_t *network,
+               uint16_t netkey_idx);
+
+/**
+ * Add Application Key in local Network
+ */
+int bluetooth_mesh_network_add_appkey(bluetooth_mesh_network_t *network,
+               uint16_t netkey_idx, uint16_t *appkey_index);
+
+/**
+ * Update Application Key in local Network
+ */
+int bluetooth_mesh_network_update_appkey(bluetooth_mesh_network_t *network,
+               uint16_t netkey_index, uint16_t appkey_idx);
+
+/**
+ * Delete Application Key in local Network
+ */
+int bluetooth_mesh_network_delete_appkey(bluetooth_mesh_network_t *network,
+               uint16_t netkey_index, uint16_t appkey_idx);
+
+/**
+ * Get All Netkeys in Local Network
+ */
+int bluetooth_mesh_network_get_all_netkey(bluetooth_mesh_network_t *network,
+                       GPtrArray **netkeys);
+
+/**
+ * Get All Appkeys Bound to a Netkey in Local Network
+ * Mesh Init
+ */
+int bluetooth_mesh_netkey_get_all_appkey(bluetooth_mesh_network_t *network,
+               uint16_t netkey_idx,  GPtrArray **appkeys);
+
+/**
+ * Get All nodes's basic information, that are added in the local Network
+ */
+int bluetooth_mesh_network_get_all_nodes(bluetooth_mesh_network_t *network,
+               GPtrArray **nodes);
+
+/**
+ * Get all Model information
+ */
+int bluetooth_mesh_element_get_all_models(bluetooth_mesh_network_t *network,
+                uint16_t node_addr, int elem_idx, GPtrArray **models);
+
+
+/**
+ * Get All Netkeys bound to a node
+ */
+int bluetooth_mesh_node_get_all_netkeys(bluetooth_mesh_node_discover_t *req,
+                       GPtrArray **netkeys);
+
+/**
+ * Get All Application Keys bound to a node
+ */
+int bluetooth_mesh_node_get_all_appkeys(bluetooth_mesh_node_discover_t *req,
+                       GPtrArray **appkeys);
+
+/**
+ * Discover remote node exported informations (E.g: Models)
+ */
+int bluetooth_mesh_browse_remote_node(bluetooth_mesh_node_discover_t *req);
+
+/**
+ * Configure Key to a node
+ */
+int bluetooth_mesh_node_configure_key(bluetooth_mesh_key_configure_t *req);
+
+/**
+ * Confiure Appplication key to a model of a node
+ */
+int bluetooth_mesh_model_configure_appkey(
+               bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Get all application keys added to a model of a node
+ */
+int bluetooth_mesh_model_get_all_appkeys(
+               bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Get full subscription list added to a Model in a node
+ */
+int bluetooth_mesh_model_get_subscriptopn_list(
+               bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Get/Set Time To Live value of a node
+ */
+int bluetooth_mesh_node_ttl_execute(
+               bluetooth_mesh_node_ttl_info_t *req);
+
+/**
+ * Get all groups available in local Network
+ */
+int bluetooth_mesh_network_get_all_groups(
+               bluetooth_mesh_network_t *network,
+               GPtrArray **groups);
+
+/**
+ * Create a group in a network
+ */
+int bluetooth_mesh_network_create_group(bluetooth_mesh_network_t *network,
+               bool is_virtual, uint16_t grp_addr,
+                       bluetooth_mesh_network_group_info_t *info);
+
+/**
+ * Configure a Mesh group to a Mesh odel
+ */
+int bluetooth_mesh_model_configure_group_sub(
+       bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Confgure Virtual group to a Mesh Model
+ */
+int bluetooth_mesh_model_configure_virtual_group_sub(
+               bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Set Publication Information to a model of a node
+ */
+int bluetooth_mesh_model_set_publication(bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Get Publication Information from a model of a node
+ */
+int bluetooth_mesh_model_get_publication(bluetooth_mesh_model_configure_t *req);
+
+/**
+ * Browse Vendor specific features from node
+ */
+int bluetooth_mesh_node_browse_vendor_features(bluetooth_mesh_node_features_t *req);
+
+#ifdef __cplusplus
+}
+#endif
+#endif /* __BLUETOOTH_MESH_API_H */