中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當(dāng)前位置: 首頁 > news >正文

網(wǎng)頁傳奇手游排行榜前十名吉林關(guān)鍵詞優(yōu)化的方法

網(wǎng)頁傳奇手游排行榜前十名,吉林關(guān)鍵詞優(yōu)化的方法,湖州 網(wǎng)站建設(shè)公司哪家好,北京金創(chuàng)網(wǎng)站建設(shè)以下兩個宏定義是我添加的。其中USING_128BIT_UUID的條件編譯部分是SDK原生部分,USING_16BIT_UUID條件編譯部分則是由我修改,通過這樣的修改,128BIT UUID就變更為16BIT UUID了。如果你的廣播、掃描響應(yīng)有涉及UUID,不要忘記更改它?!?article class="baidu_pl">

以下兩個宏定義是我添加的。其中USING_128BIT_UUID的條件編譯部分是SDK原生部分,USING_16BIT_UUID條件編譯部分則是由我修改,通過這樣的修改,128BIT UUID就變更為16BIT UUID了。如果你的廣播、掃描響應(yīng)有涉及UUID,不要忘記更改它。

#define USING_128BIT_UUID (0)//使用128bit UUID,請定義為1.
#define USING_16BIT_UUID ?(1)//使用16bit UUID,請定義為1.

/******************************************************************************************** @file otas.c** @brief Over The Air Server Implementation.****************************************************************************************** @attention#####Copyright (c) 2019 GOODIXAll rights reserved.Redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditions are met:* Redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclaimer.* Redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.* Neither the name of GOODIX nor the names of its contributors may be usedto endorse or promote products derived from this software withoutspecific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THEIMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSEARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BELIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, ORCONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OFSUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESSINTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THEPOSSIBILITY OF SUCH DAMAGE.******************************************************************************************//** INCLUDE FILES*****************************************************************************************/
#include "otas.h"
#include "ble_prf_types.h"
#include "ble_prf_utils.h"
#include "utility.h"#define USING_128BIT_UUID (0)//使用128bit UUID,請定義為1.
#define USING_16BIT_UUID  (1)//使用16bit UUID,請定義為1.
/** DEFINES*****************************************************************************************/
/**@brief Proprietary UUIDs. */
#if(USING_128BIT_UUID==1)#define OTA_SERVICE_UUID         {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80, 0x0A, 0x46, 0x44, 0xD3, 0x01, 0x04, 0xED, 0xA6}#define OTA_SERVICE_TX_UUID      {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80, 0x0A, 0x46, 0x44, 0xD3, 0x02, 0x04, 0xED, 0xA6}#define OTA_SERVICE_RX_UUID      {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80, 0x0A, 0x46, 0x44, 0xD3, 0x03, 0x04, 0xED, 0xA6}#define OTA_SERVICE_CTRL_UUID    {0x1B, 0xD7, 0x90, 0xEC, 0xE8, 0xB9, 0x75, 0x80, 0x0A, 0x46, 0x44, 0xD3, 0x04, 0x04, 0xED, 0xA6}
#elif(USING_16BIT_UUID==1)#define OTA_SERVICE_UUID         0xFF00#define OTA_SERVICE_TX_UUID      0xFF01#define OTA_SERVICE_RX_UUID      0xFF02#define OTA_SERVICE_CTRL_UUID    0xFF03
#endif/**@brief Macros for conversion of 128bit to 16bit UUID. */
#if(USING_128BIT_UUID==1)#define ATT_128_PRIMARY_SERVICE     BLE_ATT_16_TO_128_ARRAY(BLE_ATT_DECL_PRIMARY_SERVICE)#define ATT_128_CHARACTERISTIC      BLE_ATT_16_TO_128_ARRAY(BLE_ATT_DECL_CHARACTERISTIC)#define ATT_128_CLIENT_CHAR_CFG     BLE_ATT_16_TO_128_ARRAY(BLE_ATT_DESC_CLIENT_CHAR_CFG)
#elif(USING_16BIT_UUID==1)#endif
/** ENUMERATIONS*****************************************************************************************/
/**@brief OTA Service Attributes Indexes. */
enum otas_attr_idx_tag
{OTAS_IDX_SVC,OTAS_IDX_TX_CHAR,OTAS_IDX_TX_VAL,OTAS_IDX_TX_CFG,OTAS_IDX_RX_CHAR,OTAS_IDX_RX_VAL,OTAS_IDX_CTRL_CHAR,OTAS_IDX_CTRL_VAL,OTAS_IDX_NB,
};/** STRUCT DEFINE*****************************************************************************************/
struct otas_env_t
{otas_init_t             otas_init;uint16_t                ntf_cfg[OTAS_CONNECTION_MAX];uint16_t                start_hdl;ble_gatts_create_db_t   otas_att_db;
};/** LOCAL VARIABLE DEFINITIONS*****************************************************************************************/
static struct otas_env_t s_otas_env;
static uint16_t          s_char_mask = 0xff;
#if(USING_128BIT_UUID==1)static const uint8_t     s_otas_svc_uuid[] = {BLE_UUID_OTA_SERVICE};
#elif(USING_16BIT_UUID==1)static const uint8_t     s_otas_svc_uuid[] = BLE_ATT_16_TO_16_ARRAY(OTA_SERVICE_UUID);
#endif/**@brief Full OTAS Database Description - Used to add attributes into the database. */
#if(USING_128BIT_UUID==1)static const ble_gatts_attm_desc_128_t otas_att_db[OTAS_IDX_NB] = {static const ble_gatts_attm_desc_t otas_att_db[OTAS_IDX_NB] = {// OTA service[OTAS_IDX_SVC] = {ATT_128_PRIMARY_SERVICE, BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA TX Characteristic Declaration[OTAS_IDX_TX_CHAR] = {ATT_128_CHARACTERISTIC,BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA TX Characteristic Value[OTAS_IDX_TX_VAL]  = {OTA_SERVICE_TX_UUID,BLE_GATTS_NOTIFY_PERM_UNSEC, (BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_128)),OTAS_MAX_DATA_LEN},// OTA TX Characteristic - Client Characteristic Configuration Descriptor[OTAS_IDX_TX_CFG]  = {ATT_128_CLIENT_CHAR_CFG,BLE_GATTS_READ_PERM_UNSEC| BLE_GATTS_WRITE_REQ_PERM_UNSEC,0,0},// OTA RX Characteristic Declaration[OTAS_IDX_RX_CHAR] = {ATT_128_CHARACTERISTIC, BLE_GATTS_READ_PERM_UNSEC, 0, 0 },// OTA RX Characteristic Value[OTAS_IDX_RX_VAL]  = {OTA_SERVICE_RX_UUID,BLE_GATTS_WRITE_CMD_PERM_UNSEC,(BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_128)),OTAS_MAX_DATA_LEN},// OTA CTRL Characteristic Declaration[OTAS_IDX_CTRL_CHAR] = {ATT_128_CHARACTERISTIC, BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA CTRL Characteristic Value[OTAS_IDX_CTRL_VAL]  = {OTA_SERVICE_CTRL_UUID,BLE_GATTS_WRITE_CMD_PERM_UNSEC,(BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_128)),sizeof(uint32_t)},
};
#elif(USING_16BIT_UUID==1)
static const ble_gatts_attm_desc_t otas_att_db[OTAS_IDX_NB] = {// OTA service[OTAS_IDX_SVC] = {BLE_ATT_DECL_PRIMARY_SERVICE, BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA TX Characteristic Declaration[OTAS_IDX_TX_CHAR] = {BLE_ATT_DECL_CHARACTERISTIC,BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA TX Characteristic Value[OTAS_IDX_TX_VAL]  = {OTA_SERVICE_TX_UUID,BLE_GATTS_NOTIFY_PERM_UNSEC, (BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_16)),OTAS_MAX_DATA_LEN},// OTA TX Characteristic - Client Characteristic Configuration Descriptor[OTAS_IDX_TX_CFG]  = {BLE_ATT_DESC_CLIENT_CHAR_CFG,BLE_GATTS_READ_PERM_UNSEC| BLE_GATTS_WRITE_REQ_PERM_UNSEC,0,0},// OTA RX Characteristic Declaration[OTAS_IDX_RX_CHAR] = {BLE_ATT_DECL_CHARACTERISTIC, BLE_GATTS_READ_PERM_UNSEC, 0, 0 },// OTA RX Characteristic Value[OTAS_IDX_RX_VAL]  = {OTA_SERVICE_RX_UUID,BLE_GATTS_WRITE_CMD_PERM_UNSEC,(BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_16)),OTAS_MAX_DATA_LEN},// OTA CTRL Characteristic Declaration[OTAS_IDX_CTRL_CHAR] = {BLE_ATT_DECL_CHARACTERISTIC, BLE_GATTS_READ_PERM_UNSEC, 0, 0},// OTA CTRL Characteristic Value[OTAS_IDX_CTRL_VAL]  = {OTA_SERVICE_CTRL_UUID,BLE_GATTS_WRITE_CMD_PERM_UNSEC,(BLE_GATTS_ATT_VAL_LOC_USER | BLE_GATTS_ATT_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_16)),sizeof(uint32_t)},
};
#endif
/** LOCAL FUNCTION DEFINITIONS*****************************************************************************************/
/******************************************************************************************** @brief Handles reception of the attribute info request message.** @param[in] conn_idx: Connection index* @param[in] p_param:  The parameters of the read request.******************************************************************************************/
static void otas_read_att_evt_handler(uint8_t conn_idx, const ble_gatts_evt_read_t *p_param)
{ble_gatts_read_cfm_t    cfm;uint8_t                 handle     = p_param->handle;uint8_t                 tab_index  = 0;tab_index = prf_find_idx_by_handle(handle, s_otas_env.start_hdl, OTAS_IDX_NB, (uint8_t*)&s_char_mask);cfm.handle = handle;cfm.status = BLE_SUCCESS;switch(tab_index){case OTAS_IDX_TX_CFG:cfm.length = sizeof(uint16_t);cfm.value = (uint8_t *)(&s_otas_env.ntf_cfg[conn_idx]);break;default:cfm.length = 0;cfm.status = BLE_ATT_ERR_INVALID_HANDLE;break;}ble_gatts_read_cfm(conn_idx,&cfm);
}/******************************************************************************************** @brief Handles reception of the write request.** @param[in] conn_idx: of connection index* @param[in] p_param: Pointer to the parameters of the write request.******************************************************************************************/
static void otas_write_att_evt_handler(uint8_t conn_idx, const ble_gatts_evt_write_t *p_param)
{ble_gatts_write_cfm_t   cfm;uint8_t                 handle     = p_param->handle;uint8_t                 tab_index  = 0;uint16_t                cccd_value = 0;otas_evt_t              event;tab_index = prf_find_idx_by_handle(handle, s_otas_env.start_hdl, OTAS_IDX_NB, (uint8_t*)&s_char_mask);cfm.handle = handle;cfm.status = BLE_SUCCESS;switch(tab_index){case OTAS_IDX_RX_VAL:if(s_otas_env.otas_init.evt_handler != NULL){event.conn_idx = conn_idx;event.evt_type = OTAS_EVT_RX_RECEIVE_DATA;event.p_data = (uint8_t*)p_param->value;event.length = p_param->length;s_otas_env.otas_init.evt_handler(&event);}break;case OTAS_IDX_TX_CFG:cccd_value = le16toh(&p_param->value[0]);if(s_otas_env.otas_init.evt_handler != NULL){event.conn_idx = conn_idx;event.evt_type = (cccd_value == PRF_CLI_START_NTF) ?\OTAS_EVT_TX_NOTIFICATION_ENABLED :OTAS_EVT_TX_NOTIFICATION_DISABLED;s_otas_env.otas_init.evt_handler(&event);}s_otas_env.ntf_cfg[conn_idx] = cccd_value;break;case OTAS_IDX_CTRL_VAL:if(le32toh(&p_param->value[0]) == OTAS_CTRL_ENTER_DFU){if(s_otas_env.otas_init.evt_handler != NULL){event.conn_idx = conn_idx;event.evt_type = OTAS_EVT_DFU_MODE_ENTER;s_otas_env.otas_init.evt_handler(&event);}}break;default:cfm.status = BLE_ATT_ERR_INVALID_HANDLE;break;}ble_gatts_write_cfm(conn_idx,&cfm);
}/******************************************************************************************** @brief Handles reception of the cccd recover request.** @param[in]: conn_idx:   Connection index* @param[in]: handle:     The handle of cccd attribute.* @param[in]: cccd_value: The value of cccd attribute.******************************************************************************************/
static void otas_cccd_set_evt_handler(uint8_t conn_idx, uint16_t handle, uint16_t cccd_value)
{uint8_t           tab_index  = 0;otas_evt_t        event;if (!prf_is_cccd_value_valid(cccd_value)){return;}tab_index = prf_find_idx_by_handle(handle, s_otas_env.start_hdl, OTAS_IDX_NB, (uint8_t*)&s_char_mask);switch(tab_index){case OTAS_IDX_TX_CFG:if(s_otas_env.otas_init.evt_handler != NULL){event.conn_idx = conn_idx;event.evt_type = (cccd_value == PRF_CLI_START_NTF) ?\OTAS_EVT_TX_NOTIFICATION_ENABLED :OTAS_EVT_TX_NOTIFICATION_DISABLED;s_otas_env.otas_init.evt_handler(&event);}s_otas_env.ntf_cfg[conn_idx] = cccd_value;break;default:break;}
}/******************************************************************************************** @brief Handles reception of the complete event.** @param[in] conn_idx: Connection index* @param[in] p_param:  Pointer to the parameters of the complete event.** @return If the event was consumed or not.******************************************************************************************/
static void otas_ntf_cplt_evt_handler(uint8_t conn_idx, uint8_t status, const ble_gatts_evt_ntf_ind_t *p_ntf_ind)
{if(s_otas_env.otas_init.evt_handler != NULL){otas_evt_t event;event.conn_idx = conn_idx;if(status == BLE_SUCCESS){if(p_ntf_ind->type == BLE_GATT_NOTIFICATION){event.evt_type = OTAS_EVT_NOTIFY_COMPLETE;s_otas_env.otas_init.evt_handler(&event);}}}}static void otas_ble_evt_handler(const ble_evt_t *p_evt)
{if (NULL == p_evt){return;}switch (p_evt->evt_id){case BLE_GATTS_EVT_READ_REQUEST:otas_read_att_evt_handler(p_evt->evt.gatts_evt.index, &p_evt->evt.gatts_evt.params.read_req);break;case BLE_GATTS_EVT_WRITE_REQUEST:otas_write_att_evt_handler(p_evt->evt.gatts_evt.index, &p_evt->evt.gatts_evt.params.write_req);break;case BLE_GATTS_EVT_NTF_IND:otas_ntf_cplt_evt_handler(p_evt->evt.gatts_evt.index, p_evt->evt_status, &p_evt->evt.gatts_evt.params.ntf_ind_sended);break;case BLE_GATTS_EVT_CCCD_RECOVERY:otas_cccd_set_evt_handler(p_evt->evt.gatts_evt.index, p_evt->evt.gatts_evt.params.cccd_recovery.handle, p_evt->evt.gatts_evt.params.cccd_recovery.cccd_val);break;}
}/** GLOBAL FUNCTION DEFINITIONS*****************************************************************************************/
sdk_err_t otas_notify_tx_data(uint8_t conn_idx,uint8_t* p_data,uint16_t len)
{sdk_err_t            error_code = SDK_ERR_NTF_DISABLED;ble_gatts_noti_ind_t send_cmd;if(s_otas_env.ntf_cfg[conn_idx] == PRF_CLI_START_NTF){// Fill in the parameter structuresend_cmd.type = BLE_GATT_NOTIFICATION;send_cmd.handle = prf_find_handle_by_idx(OTAS_IDX_TX_VAL, s_otas_env.start_hdl, (uint8_t*)&s_char_mask);// pack measured value in databasesend_cmd.length = len;send_cmd.value  = p_data;// send notification to peer deviceerror_code = ble_gatts_noti_ind(conn_idx,&send_cmd);}   return error_code;
}sdk_err_t otas_service_init(otas_init_t *p_otas_init)
{if (NULL == p_otas_init){return SDK_ERR_POINTER_NULL;}s_otas_env.otas_init.evt_handler = p_otas_init->evt_handler;memset(&s_otas_env.otas_att_db, 0, sizeof(ble_gatts_create_db_t));s_otas_env.start_hdl = PRF_INVALID_HANDLE;s_otas_env.otas_att_db.shdl                  = &s_otas_env.start_hdl;s_otas_env.otas_att_db.uuid                  = s_otas_svc_uuid;s_otas_env.otas_att_db.attr_tab_cfg          = (uint8_t *)&s_char_mask;s_otas_env.otas_att_db.max_nb_attr           = OTAS_IDX_NB;#if(USING_128BIT_UUID==1)s_otas_env.otas_att_db.srvc_perm             = BLE_GATTS_SRVC_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_128);s_otas_env.otas_att_db.attr_tab_type         = BLE_GATTS_SERVICE_TABLE_TYPE_128;s_otas_env.otas_att_db.attr_tab.attr_tab_128 = otas_att_db;#elif(USING_16BIT_UUID==1)s_otas_env.otas_att_db.srvc_perm             = BLE_GATTS_SRVC_UUID_TYPE_SET(BLE_GATTS_UUID_TYPE_16);s_otas_env.otas_att_db.attr_tab_type         = BLE_GATTS_SERVICE_TABLE_TYPE_16;s_otas_env.otas_att_db.attr_tab.attr_tab_16 = otas_att_db;#endifreturn ble_gatts_prf_add(&s_otas_env.otas_att_db, otas_ble_evt_handler);
}

http://www.risenshineclean.com/news/7182.html

相關(guān)文章:

  • 企業(yè)商務(wù)網(wǎng)站建設(shè)論文保定百度推廣聯(lián)系電話
  • 做視頻網(wǎng)站怎么掙錢上海關(guān)鍵詞優(yōu)化推薦
  • 網(wǎng)站建設(shè)河南優(yōu)化合作平臺
  • jquery 案例網(wǎng)站騰訊與中國聯(lián)通
  • 長沙長沙h5網(wǎng)站建設(shè)百度網(wǎng)頁鏈接
  • 學(xué)做美食網(wǎng)站哪個好文案短句干凈治愈
  • wordpress 換域名插件關(guān)鍵詞排名優(yōu)化江蘇的團(tuán)隊(duì)
  • asp網(wǎng)站圖片輪播代碼衡陽seo優(yōu)化推薦
  • python做網(wǎng)站 jsp網(wǎng)站企業(yè)網(wǎng)站推廣方案
  • 手機(jī)上怎么建網(wǎng)站怎么推廣軟件
  • 企業(yè)建設(shè)網(wǎng)站專業(yè)服務(wù)百度推廣怎么弄
  • 響應(yīng)式網(wǎng)站適合用什么框架做龍網(wǎng)網(wǎng)絡(luò)推廣軟件
  • 廈門維品網(wǎng)站建設(shè)手機(jī)優(yōu)化軟件哪個好用
  • 超炫html5網(wǎng)站模板windows優(yōu)化大師要會員
  • 深圳梵高網(wǎng)站建設(shè)服務(wù)域名購買哪個網(wǎng)站好
  • 網(wǎng)站收錄了怎么做排名手機(jī)網(wǎng)頁制作app
  • 好的網(wǎng)站設(shè)計作品seo搜索引擎推廣什么意思
  • 做網(wǎng)站Linux百度推廣下載安裝
  • 賭博游戲網(wǎng)站怎么做吉林黃頁電話查詢
  • 廣州網(wǎng)站建設(shè)服務(wù)哪家好公司網(wǎng)站建設(shè)公司好
  • 建站abc做的網(wǎng)站穩(wěn)定國內(nèi)手機(jī)怎么上google瀏覽器
  • 建網(wǎng)站操作流程泰州seo網(wǎng)絡(luò)公司
  • 宜昌永東建設(shè)網(wǎng)站今日新聞 最新消息 大事
  • 公司就兩個開發(fā)百度seo教程網(wǎng)
  • 廣西桂林為什么窮優(yōu)化網(wǎng)站排名技巧
  • 龍華做棋牌網(wǎng)站建設(shè)多少錢網(wǎng)絡(luò)口碑營銷名詞解釋
  • 自己做的網(wǎng)站顯示不出來國際最新新聞熱點(diǎn)事件
  • WordPress碎語山東服務(wù)好的seo
  • 一個完整的動態(tài)網(wǎng)站開發(fā)東莞seo整站優(yōu)化火速
  • dede5.7 做的網(wǎng)站 下 加一個discuz論壇網(wǎng)站統(tǒng)計分析工具