《10(100%开源)蓝牙心率防水运动手环_蓝牙BLE收发.docx》由会员分享,可在线阅读,更多相关《10(100%开源)蓝牙心率防水运动手环_蓝牙BLE收发.docx(11页珍藏版)》请在第一文库网上搜索。
1、蓝牙心率防水运动手环蓝牙BLE收发智能穿戴开发系列配套资料:https:/www.fengke.club/GeekMart/su_fkZyGYgrp.jsp配套视频:https:/www.fengke.club/GeekMart/su_fTSgUL3y3.jsp蓝牙收发1相关简介DA14580内部集成了射频模块,同时官方也提供了一套SDK,里面包含了蓝牙协议栈部分。本节蓝牙收发就是通过修改官方提供的SDK,完成蓝牙收发功能。关于蓝牙的基本知识,大家可以参考前面的蓝牙基础。2 硬件设计DA14580内部集成了射频模块,这里只需要从PFlOp脚接一根天线。IA一br年图13软件设计打开SDK,从路
2、径:SDK5.0.4DA1458x_SDK5.0.4projecttarget_appsble_examplesble_app_profileKeil_5 中打开 ble_app_profile 工程文件。首先修改user_custl_def.h文件,该文件对服务的参数进行了声明,我们这里需要修改服务和特征值的UUID等参数,并将多余的特征值删除。 LOCAL VARIABLE DEFINITIONS/ Custom Server Attributes Values Dotinixionscacic constcu3sl_9vc= DZF_CUST1_SVC_UUID;conaz struct
3、 as匕 cha= deac cuasl indicaeable char - ATT CHAR:ATT CHAS PROP RD I ATT CHAa PROP WR NO RZSF I ATT CHAR PROP NTF,0,DZF-CUSTi-INDICATEABLZ-UUID);3ZAZ1C const struct atjchajdegu cu9cs 1_1 ong_value.char= ATT_CHAR ATT_CHAR_P3OP_RD I ATT_CHAS_PROP_WR_NO_R2:SP I ATT_CHAR_P20P_NTF.,DZF.CUSTi-LONGJLUZ-UUID
4、);static conax uinxB-t custsl-indicataablc-dcsc CUSTl-IirDICATZABLE-USHDZSC;static CQV.9ZC33:_long_va【ue_dsu】=CUS1:_SNG_UALUJCHA2_CSM2_BSC;T CUSTSl ATTaiBUTZS-ATT DZCL rIHARY S-RTICZ; static ccnsL uin?lG t att deci sve图20x93, GxA6, 0x3D, 0xD8再修改user_custl_def.c文件,该文件对文件和特征值的属性进行了定义,这里需要对耍使用的服务和特征值进行
5、修改,异删除多余的特征值定义。define DEF_CUST 1_SVC_UUIDdefine DEF_CUST1_INDICATEA3LE_UUIDdefine DEF二CUST1二LCNG_VALUE_而工D0XFFF1 / (0x28, 0x)5,0XFFF4 / 0x3Cz Ox,9,OxEl,OxEO,OxCi, OxEl, 0xC5OxDl, 0x31, 0x54nIndLcat sable11rfLcng Vai二e”/ Cuscoml Service Data Sase Characteristic enurcdefine DEF_CUST1-INDICATEA3LE_CHAR
6、_LEN20define DEf2cUST12lONG_VALUE_CMAR_LEN20define CUST1_IMDICATEA3LE_USER_DESCdefine CUST12lONG VALUE CHAR USER DESCCUST1_IDX_SVC = 0,CUST1_IDX_INDICATEABLE_CHAR,CUST 匚工 DX二工 ND 工 CATEA3LE 二VAL,CUSTQDX 二工 NDICATEABLE 二工 ND_CFG,CUST:二:IDX 二工 ND 工 CATEA3LE 二 USE a _DESC,CUST1_I DX_LONG_VALUE_CHAR,cus
7、ti2i dxlong二valueval ,CUSTl2I DXLONG二VALUE 二 NT F_C FG,CUST 匚工 DX二 LONG 二VA 二 UE 二 US ER_DE S C,CUST1 IDX N3const struct attm_desc custsl_att_dbCUST1_IDX_NB=/ CUST0M1 Service DeclaratioCUST1_IDX_SVC = ATT_DECL_PRIMARY_SERVICE, PERM(RD, ENABLE), sizeof(custsl_svc),sizeof(custsl_svc), (uint8_t*)&custs
8、l_svc, Indicateable Characteristic DeclarationCUST1JDX_INDICATEABLE_CHAR = ATT_DECL_CHARACTERISTIC, PERM(RD, ENABLE),sizeof(custsl_indicateable_char),sizeof(custsljndicateable_char)/(uint8_t*)&custsljndicateable_char,/ Indicateable Characteristic ValueCUST1_IDX_INDICATEABLE_VAL = DEFUSTIJNDICATEABLE
9、.UUID, PERM(RDZ ENABLE) |PERM(WR, ENABLE) | PERMfNTF, ENABLE), DEF_CUST1_INDICATEABLE_CHAR_LEN, 0, NULL,/ Indicateable Client Characteristic Configuration DescriptorCUST1_IDX_INDICATEABLE_IND_CFG = ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)| PERMfWR, ENABLE), sizeof(uintl6_t), 0, NULL,/ Indicateable
10、 Characteristic User DescriptionCUST1_IDX_INDICATEABLE_USER_DESC =ATT_DESC_CHAR_USER_DESCRIPTION, PERMfRD,ENABLE), sizeof(CUSTl_INDICATEABLE_USER_DESC) -1, sizeof(CUSTl_INDICATEABLE_USER_DESC)-1, (uint8_t*)&custsl_indicateable_desc,/ Long Value Characteristic DeclarationCUST1_IDX_LONG_VALUE_CHAR = A
11、TT_DECL_CHARACTERISTIC, PERM(RDZ ENABLE),sizeof(custsl_long_value_char)/sizeof(custsl_long_value_char)/(uint8_t*)&custsl_long_value_char),/ Long Value Characteristic ValueCUST1JDX_LONG_VALUE_VAL = DEF_CUST1_LONG_VALUE_UUID, PERMfRD, ENABLE) |PERMfWR, ENABLE) | PERM(NTF, ENABLE), DEF_CUST1_LONG_VALUE
12、_CHAR_LEN, 0, NULL,/ Long Value Client Characteristic Configuration DescriptorCUST1_IDX_LONG_VALUE_NTF_CFG = ATT_DESC_CLIENT_CHAR_CFG, PERM(RD, ENABLE)| PERMfWR, ENABLE), sizeof(uintl6_t), 0, NULL,/ Long Value Characteristic User DescriptionCUST1_IDX_LONG_VALUE_USER_DESC = ATT_DESC_CHAR_USER_DESCRIP
13、TION, PERM(RD,ENABLE),sizeof(CUSTl_IDX_LONG_VALUE_USER_DESC-)lzsizeof(CUSTl_IDX_LONG_VALUE_USER_DESC) -1, (uint8_t*)&custsl_long_value_desc/);代码1最后要修改的是custl_task.c文件,该文件定义了 custl服务的一些任务函数,需要将原来定义为128位的修改为16位。另外,由于前面删除了多余的特征值服务,这里还需要修改接受函数。sa-ic ltlz gar*c_Arize_ciLd_ind_handier (ke_nLsg_id_r ccnsu
14、agNci,struct qasc_wr工_CKd_ind ccns parar./const dest_id,ke_cask *d_c consc src id)3handle - custsl_env. shell;switch (at j工dx)4 hanciler pararr.-length/ (uintS_tw) 4 (pararr.-value(C );atrcdb_at_3ec_valuc ( (cusrsl_env. shdl*CUSTi_IDX_LCNG_VALUE_VAL), parax-lengchr (心工& (pareun-X/alue (0J);prf_server_5end_event(prf_env_struct )&(cu5tsl_env.con_info), flser (cus13l_env.shdl+CUST1_IDX_LCNG_VAL7E_VAL);break;default:break;