講義說明案例_第1頁
講義說明案例_第2頁
講義說明案例_第3頁
講義說明案例_第4頁
講義說明案例_第5頁
已閱讀5頁,還剩100頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

FR801xHSDKUserBluetoothLowEnergySOCwithSIG2020-03概 FR801xHSDK結 空間分 地址空 空間分 代碼流 user_custom_parameters函 user_entry_before_ble_init函 user_entry_after_ble_init函 睡眠喚醒用戶接 SDK項目工 燒 基于Keil+J-Link的燒錄方 采用PC燒錄工具+串口進行燒 量產燒 低功耗管 工作模 程序運行流 喚醒條 BLE協議 GAP GAP事 GAPEventType GAPGATTMTU GAPMessage GAPAdvertisingMode GAPAdvertisingFilterMode GAPScanMode GAPScanResultType GAPScan GAPPairingMode GAPIOCapabilities GAPSecurity GAP函 GAPSetAdvertising GAPSetAdvertising GAPStart GAPStop GAPStart GAPStop GAPConnect GAPCancelConnection GAPGetLocal GAPSetLocal GAPGetConnection GAPGetEncryption GAPSetDevice GAPGetDevice GAPSetDevice GAPGetDevice GAPGetConnection GAPGetLink GAPEnableRSSIreportinreal GATT事 GATT函 GATTAdd GATTAdd Mesh Mesh事 MeshProvisionInputOOB MeshPublishMessage MeshReceiveMessage MeshModel MeshModelMessage NetworkKeyisNOT NetworkKeyis ApplicationKeyisNOT Mesh函 Mesh MeshSet Mesh Mesh MeshModelBind MeshAdd MeshClearInformationIn Security函 GAPBondManager GAPBondManagerDeleteAll GAPBondManagerDeleteSingle GAPSetSecurity GAPSendingPairing GAPPairing GAPEncrypt GAPGetBond GAPSecurity BLE HIDservice事 HIDservice函 DIS事 DIS函 Battery BATT事 BATT函 OTA函 Task函 OSMessage Clock Clock函 OSTimer OSTimer OSTimer Memory Memory函 OS OSGetFreeHeap OSShowMessage OSShowKernelMalloc OSShowMemory MCU外設驅 IO 普通IO接 IO功能設 IO上拉設 支持低功耗模式的IO接 IO使能低功耗模 IO關閉低功耗模 IO低功耗模式功能設 IO低功耗模式輸入輸出設 IO低功耗模式上拉設 IO使能低功耗喚 IO低功耗模式中斷 普通GPIO接 GPIO輸 GPIO設置整個port輸入輸 GPIO獲取整個port輸入輸出配 GPIO設置單個IO輸入輸 GPIO低功耗模式輸出 GPIO低功耗模式輸入 UART初始 UART等待發送FIFO為 從串口數 從串口發送數 UART發送一個字節且等待完 UART發送一個字節且立即返 UART發送多個字節且等待完 UART特定個數字 UART特定個數字節,諾FIFO為空則先返 UART0讀數 UART0發數 UART1讀數 UART1寫數 SPI初始 SPI發送并接 SPI發 SPI接 I2C初始 I2C發送一個字 I2C發送多個字 I2C一個字 I2C多個字 Timer初始 Timer啟 Timer停 Timer獲取load Timer獲取當前計數 Timer清中 普 接 啟 停 低功 初始 低功 低功 啟 低功 停 ADC初始 ADC開始采 ADC停止采 ADC結 WDT初始 WDT喂 WDT啟 WDT停 WDT中斷處理接 RTC初始 RTC啟 RTC停 RTC中斷處理接 QDEC初始 QDEC設置引 QDEC設置清零條 QDEC設置中斷閥 QDEC設置中斷類 QDEC去 QDEC旋轉計 QDEC中斷處理接 Key KeyScan結構體定 KeyScan參 KeyScan函 KeyScan初始 KeyScan中斷處理接 PMU配置系統電 PMU判斷系統是否第一次上 PMU使能中 PMU關閉中 PMU使能Codec供 PMU關閉Codec供 PMU設置LDO_OUT和IO電壓 PMU設置32K時鐘 PMU設置內部RC頻 PMUCharger中斷接 PMU低電壓監測中斷接 PMU高溫監測中斷接 OTA OTA交互包格 OTA主機端的請求包格式(通過write 獲取新固件的可用 獲取當前固件版本 擦除扇區 寫入數 重啟FR801xH的回復包格式(通過Notify 獲取新固件的可用 獲取當前固件版本 擦除扇區 寫入數 重啟 103勘誤記 概包含了BLE5.0的完整協議棧,的外設驅動以及操作系統抽象層OSAL。FR801xHSDK分。MCU外設驅動和profile,以及應用層的例程代碼,都是以源碼的形式提供,圖中為綠色部分。FR801xHSDK空間分FR801xH的地址空間如下(48KB(48KB(512KB/1MB(128KBFR801xH其中內置128KBROM,主要內容為啟動代碼、BLEcontroller部分協議棧;FLASH空間用于用戶程序、用戶數據等;RAM用于各種變量、堆棧、重新映射后的中斷向量地址、對運行速度較為敏感的代碼(中斷響應等)等,該空間都支持低功耗的retention功能;外設地址空間是各種外設的地址映射,用于進行外設的配置。在FR801xH中FLASH空間和RAM空間的分配由指定,具體分配如下USERAPP(runningspace FR801xHflashRAM其中JUMP_TABLE的是配置信息;APPCODE和RODATA可以通過XIP被MCU直接;CRITICALCODE和EXCEPTIONandINTERRUPTHANDLERflashRAM中;RWDATA需要進行初始化;ZI0SDK內部進行處理,用戶無需做額外操作。代碼流LIB中進行部分硬件初LIB中進行baseband和協議棧的初LIB中進入主SDK包含了四大部分,Application部分,藍牙協議棧部分,操作系統抽象層OSAL部分MCU外設驅動部分。整個代碼結構比較簡單,執行流程也很清晰易懂。SDK的main函數主體位于lib庫中,對于應用層以源LIB中進行部分硬件初LIB中進行baseband和協議棧的初LIB中進入主用戶可以實現該函數進行profile的,main該函數示例void{jump_table.addr.addr[0]=0x01;jump_table.addr.addr[1]=0x01;jump_table.addr.addr[2]=0x01;jump_table.addr.addr[3]=0x01;jump_table.addr.addr[4]=0x01;jump_table.addr.addr[5]=jump_table.image_size=0x19000;//100KBjump_table.firmware_version=0x }48M;配置協議棧中使用的0x30000該函數示例void{/*setsystempowersupplyinBUCKmode*/||||||該函數實現了配置供電模式為BUCK,使能了一系列PMU部分的中斷,配置了AT指令所使用的的串口user_entry_after_ble_initbondmanager的初始化,GAP事件處理回調函數的,BLE廣播參數的設置,GATTservice的創建,用戶task的創建等。user_entry_after_ble_init()在系統使能睡眠后,LIB中主代碼會判斷是否滿足進入睡眠條件,針對開始睡眠前和喚醒后分別提供了供用在系統喚醒后,用戶可以在該函數中重新進行外設的初始化(進入睡眠后外設的狀態因為掉電都會丟失等操作jump_table結構體中保存了一些配置信息名值功-OTA的備份區域。例如該值為0x10000,那OTA雙區域在flash中的址就分別為00x10000。因此該值在一個項-版本號來判斷OTA雙區域中的代碼哪一個的版本-本機的藍牙系統工作主SDK項目工樣的結構,如下圖所示:工程結applicationprofile等;driver中為外設驅動;platform中為異常向量和部分異常的處理函數;patchROMcode中的一些補丁代碼;lib中為封裝好的庫文件,其中所提供的接口在gatt_api.h、gap_api.h等文件中。在當前的SDK中提供了一下幾種sample工程HIDMesh主機例程從機例程燒燒錄方式主要有兩種PC燒錄工具+用戶將文件FR8010H.FLM存放在Keil安 下的ARM\Flash路徑中,然后在Keil工程中進行如下配J-Link作為調試工配置調試方式為在flashdownload選項卡中配置選通過以上配置就可以實現在KeilIDE中進行flash的調試和燒錄PC燒錄工具+串口在的J-Link調試口被復用成別的功能,或者系統會進入睡眠時,則無法通過上述方法進行燒錄。這時可以采用打開PC端串口燒錄工具,選擇正確的串,導入DAT文件(選擇要燒錄的bin文件),然后打開串口,進入將串口工具的TX連接到PA2(端的RX,RX連接到的PA3(端的TX與時與PC到中注意事項:因為串口工具的TX會串電到端,所以接線連接順序要符合上面的2和3步驟所描述的流程 系列有完善的量產燒錄工具,可以支持燒錄片、也可燒錄PCBA,具體實施方式可以聯系商低功耗管工作模耗模式,FR801xH支持兩種低功耗模式:工作模深睡深睡眠(RAM不保100%不保可數字邏輯(包括外設資源不保不保RTC等可選保保(Mtin)7AOn,DERC等模塊喚醒,且M中數據保持,這種模式適用于正常連接狀態、或者周期性廣播狀態等。在這種模式下,喚CUF深睡眠模式下系統底電流大致為4uA(Mtin主程序的運行流程如下圖在該流程中用戶在睡眠前和喚醒后各有一個可以進行自定義的操作該函數在進入睡眠前被調用,用戶可在里面實現控制GPIO的狀態保持(針對GPIO在系統工作和睡眠狀態下的控制參見外設驅動章節),配置睡眠喚醒條件等行為。在系統喚醒后,用戶可以在該函數中重新進行外設的初始化(進入睡眠后外設的狀態因為掉電都會丟失等操作睡眠的喚醒有同步和異步兩種:同步喚醒來自一個硬件timer,這個timer的設置由協議棧中代碼完成,主要取決于廣播間隔、連接間隔等參數,在應用層代碼中無需關注;異步主要來PMU(電源管理單元)的中斷信號,PMU這兩行代碼可以配置PMU中的GPIO狀態監測模塊開始監測GPIO_PD4和GPIO_PD5的狀態,一旦發生電平高低的變化,就可以產生PMU中斷。如果在睡眠中產生PMU中斷,則系統會被喚醒,喚醒后可在PMU的中斷處理函typedeftypedef{BLE上層應用開發調用。Profile則是以源碼的形式提供。GAPGAPAPIcomponents\ble\include\gap\gap_api.hGAPGAPEventType//typedef{mtuGAPLinkEstablished//Linkestablishedevent //!<號 //!<對端的mac地址 //!<對端mac地址的類型 //!<握手間隔參數。單位 //!<lantency參數 //!<超時斷開的參數。單位}GAPLinkDisconnect//Linkdisconnecteventtypedef{ //!< hl}GAPLinkParameterUpdateReject//Linkparameterupdaterejecteventtypedef{ 號 //!}GAPLinkParameterUpdateSuccess//Linkparameterupdatesuccesseventtypedef{ lantency }GAPAdvertisingReport//Advreportindication //!<收到廣播的類型,見@GAP_SCAN_EVT_TYPE_DEFINES //!<廣播的mac地址。 //!<廣播的 //!<廣播的rssi值。 //!<廣播的數據長度uint8_t buffer}GAPPeerFeature//Peerfeaturersptypedef{ //!<事件對應的號 feature}GAPGATTMTU//Mtuexchangedeventtypedef{//!<事件對應的號//!<mtu}GAPSecurityMasterAuthenticationRequest//Gotauth_reqeventtypedef{ //!<事件對應的號 //!<是否要進行加密。0:不加密。1:}GAPMessage//GAPmessageeventtypedef{GATTevent的類型,見 做為slave建立事件對應參數。 收到對端feature回復時對應的參數。 mtu交換完畢事件對應的參數。 收到對端rssi時的值。 master加密事件對應的號 GAPAdvertisingModeGAPAdvertisingType//GAPAdvertisingChannel//GAPAdvertisingFilterMode//GAPAdvertising//Gapadvparametertypedef{廣播的模式,見@廣播的通道選擇。見@廣播的過濾設置。見@GAPScanMode// //!<scanrsp //!<掃描,不能收到scanrsp包GAPScanResultType//GAPScan//Gapscantypedef{ 掃描的模式,見@ //!<掃描接收到的包是否要過濾重復包.1:過濾;0:不過濾 //!<掃描間隔。必須大于等于scan_window。范圍4~16384 //!<掃描開窗間隔。范圍4~16384 //!<掃描持續時間。單位:10ms。0GAPPairingMode// //!< //!<GAPIOCapabilities////!<GAPSecurity//Gapsecuritytypedef{ //!<是否啟用安全。保留。不用填 //!<ble 是否初始化配對,或等待配對。見@ 是否使能配對時的綁定檢查。True //!<GAPGAPSetEventCallbackvoidgap_set_cb_func(gap_callback_func_t {{case{}}}GAPSetAdvertisingvoidgap_set_advertising_param(gap_adv_param_t 2.1.1事件中的gap_adv_param_t類型定義。參數取值需adv_intv_min需要小于等于adv_intv_maxadv_intv_minadv_intv_max的取值范圍//GAP-Advertisementdata(maxsize=31bytes,thoughthis//bestkeptshorttoconservepowerwhilestaticuint8_tadv_data[]={//serviceUUID,tonotifycentraldeviceswhatservicesare//inthisperipheral.告訴central本機有什么服務,但這里先只放一個主要的. //lengthofthisdata //someoftheUUID's,butnot0xFF,//GAP-Scanresponsedata(maxsize=31bytes,thoughthis//bestkeptshorttoconservepowerwhilestaticuint8_tscan_rsp_data[]={completename //lengthofthis 'S','i','m','p','l','e','','P','e','r','i','p','h','e','r','a',//Txpowerlevel //lengthofthisdata //adv_param.adv_mode=GAP_ADV_MODE_UNDIRECT;adv_param.adv_addr_type=GAP_ADDR_TYPE_PUBLIC;adv_param.adv_chnl_map=GAP_ADV_CHAN_ALL;adv_param.adv_intv_min=300;adv_param.adv_intv_max=300;uint8_tadv_data[]=adv_data;uint8_trsp_data[]=scan_rsp_data;gap_set_advertising_data(adv_data,sizeof(adv_data));GAPSetAdvertisingvoidgap_set_advertising_data(uint8_t*p_adv_data,uint8_t 指向廣播數據buffer 廣播數據長度值。取值范圍:1~GAPSetAdvertisingResponsevoidgap_set_advertising_rsp_data(uint8_t*p_rsp_data,uint8_t 廣播掃描回復數據長度值。取值范圍:1~GAPStartvoidgap_start_advertising(uint16_t 其他:廣播持續duration*10msGAPStopvoidGAPStartvoidgap_start_scan(gap_scan_param_t 2.1.1事件中的gap_scan_param_tscan_intv和scan_window0x4 取值范圍為 ~65535其他:掃描持續duration*10msgap_scan_param_tscan_param;scan_param.dup_filt_pol=0;scan_param.scan_intv=32;//scaneventon-goingtimescan_param.scan_window=20;scan_param.duration=GAPStopvoidBLEcentralobserverperipheraladvertiserGAPConnect central設備發起對peripheral設備的BLE連接。建立時會產生GAP_EVT_SLAVE_CONNECT或 GAP_ADDR_TYPE_PUBLIC structmac_addraddr=GAPCancelConnectionvoid停止正在由gap_start_conn發起的連接的過程,central設備發起。本函數停止正在進行連接的動作,不是斷開已經建立的。正在的動作被停止后,產生GAP_EVT_CONN_END事件。GAPDisconnectvoidgap_disconnect_req(uint8_t 要被斷開連接的號。號從0開始一直到app_config,h定義的最大數-1GAPGetLocalblelocalmac macbuffmacstructmac_addraddr;show_reg(&addr.addr[0],6,1);//printflocalmacGAPSetLocalvoidgap_address_set(structmac_addrblelocalmac BDADDR。Mac6structmac_addraddr=GAPGetConnectionboolgap_get_connect_status(uint8_t要查詢的號。號從0開始一直到app_config,h定義的最True,該號處于狀--GAPGetEncryptionboolgap_get_encryption_status(uint8_t要查詢的號。號從0開始一直到app_config,h定義的最True,該號處于已加密狀--GAPSetDevicevoidgap_set_dev_name(uint8_t*p_name,uint8_tblegapprofiledevname buff GAPGetDeviceuint8_tuint8_tgap_get_dev_name(uint8_t* 指向設備名字buffGAPSetDevicevoidgap_set_dev_appearance(uint16_tblegapprofiledevappearance GAPGetDevice 設備的外觀。見@defgroupGAPGetConnectionuint8_t 0~app_config,hGAPGetLinkvoidgap_get_link_rssi(uint8_trssirssigap_event:GAP_EVT_LINK_RSSI 要查詢的號。號從0開始一直到app_config,h定義的最GAPEnableRSSIreportinrealattribute((section("ram_code")))voidgap_rssi_ind(int8_trssi,uint8_t{co_printf("rssi:link=%d,rssi=%d.\r\n",conidx,} GAPConnectionParametersUpdateGAP_EVT_LINK_PARAM_REJECT 要進行參數更新的號。號從0開始一直到app_config,h定義的最大數-1 最小的間隔取值。必須小于等于max_intv。取值大于6。單位:0.625us 最大的間隔取值。取值大于6。單位:0.625us 做為slave角色時,允許忽略握手的間隔個數。slave_latency*max_intv<=6400 GATTGATTAPIcomponents\ble\include\gatt\gatt_api.hGATTGATTPropertyBitmap//對prop變量值att attwrite_cmd att attwrite_cmd att att attwritewithno//對attnotificationattindication//!<attwrite_with_responseattwrite_without_responseattread//GATTmessageeventstypetypedef{gattattinfo//GATTmessageeventoperationdonetypedef{GATT操作的類型seevoid//GATTmessageeventdatatypedef{ GATTvoid //!<GATT//GATTmessageeventtypedef{GATTevent//!<Gattevent對應的GatteventserviceGattevnetattributeidxGatteventGattevent//BLEattributedefineformattypedef{Attribute權限seeAttributeuint8_tAttributebufferprofileserviceattmax_sizep_datamax_size>0,p_dataNULL。創建profile時內部會分配內存,并拷貝p_data max_size==0,p_dataNULLatt不能被讀。或者讀該att會返回Nullmax_size==0,p_dataNULLattGATT_PRIMARY_SERVICE_UUID1attidxmax_size填serviceuuidp_dataservice_uuidbufferp_databuffer推薦定義為constramGATTService//Profileservicedefinetypedef{constgatt_attribute_t//!<profileserviceattprofileserviceattprofileservice//Profileclientdefinetypedef{constprofileclientattuuidprofileclientattprofileclient//BLEclientreadtypedef{ //!<Profileclient讀操作對應的號 profileclientclient_id profileclientattidxGATTClientEnable//BLEclientenablentftypedef{ //!<Profileclient進行使能ntf操作對應的號。 //!<profileclient進行使能ntf操作對應的client_id。 //!<profileclient進行使能ntf操作對應的attidx號//BLEnotificationtypedef{profileclientnotificationattidxuint8_t//!<profileclientnotification//BLEindicationtypedef{//!<Profileclientindication操作對應的號profileclientindicationattidxuint8_t//!<profileclientindicationGATTGATTAdduint8_tgatt_add_service(gatt_service_tprofileservice 0xff,創建失敗profileGATTAddprofileclientclientattuuid均放在一個client 0xff,創建失敗profileGATTChangeServicevoidgatt_change_svc_uuid(uint8_tsvc_id,uint8_tatt_idx,uint8_t*new_uuid,uint8_tprofileserviceattuuid uuidprofile attidx uuidbuffer uuidvoidgatt_change_client_uuid(uint8_tclient_id,uint8_tatt_idx,uint8_t*new_uuid,uint8_tprofileclientattuuid uuidprofile attidx uuidbuffer uuidGATTDiscoverPeerDeviceAllvoidgatt_discover_all_peer_svc(uint8_tclient_id,uint8_t profileclient_id 要進行掃描操作的號。號從0開始一直到app_config,h定義的最大數-{{case{externuint8_t}}}GATTDiscoverPeerDeviceServiceByperipheral-profileclient_id-要進行掃描操作的號。號從0開始一直到app_config,h定義的最-serviceuuid-serviceuuidvoidgatt_client_write_req(gatt_client_write_t voidgatt_client_write_cmd(gatt_client_write_t {{case{{gatt_client_write_twrite;write.client_id=client_id;write.att_idx=1;write.data_len=7;}}}return}GATTEnablevoidgatt_client_enable_ntf(gatt_client_enable_ntf_t 要進行使能notification{{case{{gatt_client_enable_ntf_tntf_enable;ntf_enable.client_id=client_id;ntf_enable.att_idx=0;}}}return}GATTReadvoidgatt_client_read(gatt_client_read_t {{case{{gatt_client_read_tread;read.client_id=client_id;read.att_idx=0;}}}return}voidgatt_notification(gatt_ntf_tcentralnotificationntf gatt_ntf_tntf_att;ntf_att.att_idx=ntf_att.svc_id=svc_id;ntf_att.data_len=4;ntf_att.p_data=tmp;voidgatt_indication(gatt_ind_t GATTMTUExchangevoidgatt_mtu_exchange_req(uint8_t mtu0開始一直到app_config,hGATTGetnegotiatedMTUuint16_tgatt_get_mtu(uint8_tMTU 要進行mtu交換的號0開始一直到app_config,h GATTdealmessagefromHOST(condition:RTOSRTOSGATTtask,HOSTtasktask 從MeshMesh的相關APIcomponents\ble\include\mesh\mesh_api.hMeshMeshEventType//Mesheventtypeenum{MeshMesh//!<provisionerresetMeshModelgroup//!<從provisioner收到provisionparameterrequest//!<從provisioner收到authenticationdatarequest//!<收到provision//!<//!<mesh//!<provisionercompositiondatarequest//!<BLEMeshnetworkinformation//Meshnetworkinformationupdateenum{NetworkkeyNetworkkeyApplicationkeyApplicationkeyModelpublicationModelsubscriptionlistModel/applicationkey//!<MeshSupported//Meshsupportedfeaturetypeenum{ Relay Proxy Friendly LowPowerNode //!<GATTbearerMeshProvisionOutputOOB//Meshprovisionoutoobenum{=Bit[0]:=Bit[1]:=Bit[2]:=Bit[3]:=Bit[4]:Bit[5-15]:MeshProvisionInputOOB///InputOOBActionfieldenum{=Bit[0]:=Bit[1]:=Bit[2]:=Bit[3]:Bit[4-15]:MeshProvision//Meshprovisionenum{=(1<<//!<unprovisioneddevicebeaconURIHashMeshProvision///Stateoftheenum{ProvisioningProvisioningProvisioningMeshPublishMessage//Meshpublishmessagetypetypedef{ Elementindex ModelID Operationcode(1,2or3operationcode) //!< //!<}MeshResponseMessage//Meshresponsemessagetypetypedef{ Appkey operationcode(1,23operation }MeshReceiveMessage//Meshreceivemessagetypetypedef{ ModelID Operationcode(1,2or3operationcode) //!< //!<}MeshModel//Meshmodeltypedef{ModelIDSIGmodelmodel//!<Elementindex}MeshProvisionStateChange//MeshProvisioningstatechangetypedef{ Provision狀態。(@seeenum Provision}MeshModelMessage//Informreceptionofaspecificmeshtypedef{ Modelid elementindex AppKeyLocalidentifierRequiredforaresponse) //!<PDURSSI 1=0=relay Operationcode(1,2or3字節長度的operationcode) //!<消息源設備的地址。(Requiredfora //!<const //!<}NetworkKeyisNOT//Networkkeyinformationentrystructureifnetworkkeyisnotbeingtypedef{//!<Entry//!<//!<NetKey//!<Network}NetworkKeyis//Networkkeyinformationentrystructureifnetworkkeyisbeingtypedef{//!<Entry//!<//!<NetKey//!<Network//!<NewnetworkApplicationKeyisNOT//Applicationkeyinformationentrystructureifapplicationkeyisnotbeingtypedef{//!<Entry//!<//!<NetKey//!<AppKey//!<Network}ApplicationKeyis//Applicationkeyinformationentrystructureifapplicationkeyisbeingtypedef{//!<Entry//!< //!<NetKey //!<AppKey //!<Network //!<NewnetworkModelpublicationparameterforNOTvirtualpublication//Modelpublicationparameterentrystructureifpublicationaddressisnotavirtualtypedef{//!<Entry//!<//!<Element//!<Model//!<Publication//!<AppKey//!<//!<//!<Retransmission//!<FriendModelpublicationparameterforvirtualpublication//Modelpublicationparameterentrystructureifpublicationaddressisavirtualtypedef{//!<Entry//!<//!<Element//!<Model//!<Publication//!<AppKey//!<//!<//!<Retransmission//!<Friend//!<LabelModelsubscription//Modelsubscriptionlistentrytypedef{//!<Entry//!<//!<Element//!<Model//!<Keybinding//Model/Applicationkeybindingentrytypedef{//!<Entry//!<//!<Element//!<Model//!<ListofAppKeytypedef{//!<Update//!<Entry//!<EntryMeshEvent//Mesheventtypedef{enumMesh{ Provision //!<key Meshmodel //!<Meshcompositiondatarequestpage。 //!<BLE廣播包內容。}}MeshMeshSetApplicationCallbackvoidmesh_set_cb_func(mesh_callback_func_t Meshmesh meshlinkflashmeshlinknetworkkey,appkey,binding信息等。詳細參考4.3.1章節mesh_feature_t。MeshSetvoidMeshvoidMeshvoidmeshMeshModelBindmodelappkeyappkeyprovisioner 需要被綁定appkey的model。 model歸屬的element。 MeshModelSubscribeGroupvoidmesh_model_sub_group_addr(uint32_tmodel_id,uint8_telement,uint16_tmodelmodelgroup_addr MeshAddvoidmesh_add_model(constmesh_model_t MeshPublishvoidmesh_publish_msg(mesh_publish_msg_t MeshSendResponsevoidmesh_send_rsp(mesh_rsp_msg_t voidmesh_send_prov_param_rsp(uint8_t*uuid,uint32_turi_hash,uint16_toob_info,uint8_tpub_key_oob,uint8_tstatic_oob,uint8_tout_oob_size,uint8_tin_oob_size,uint16_tout_oob_action,uint16_tin_oob_action,uint8_tnb_elt,uint8_tprovisionrequest的回復。Provisionrequestprovisioner uri_hash oob信息。 Staticoob信息。 Outoobsize。 Inoobsize。 Inoobaction。 MeshProvisionAuthenticationDatavoidmesh_send_prov_auth_data_rsp(uint8_taccept,uint8_tauth_size,uint8_t MeshCompositionData compositiondatarequest MeshStoreInformationIntovoid至少2秒之后再調用此函數。MeshClearInformationInvoidSecuritySecurityAPI也位于components\ble\include\gap\gap_api.h文件Security函GAPBondManagervoidgap_bond_manager_init(uint32_tflash_addr,uint32_tsvc_flash_addr,uint8_tmax_dev_num,booluser_entry_before_ble_init()函數調用 指定綁定設備服務信息的flash地址,地址必須是4096整數倍。 指定最大能支持的綁定設備的個數。取值1~app_config,h定義的最大數。 是否啟用該功能。True,啟用綁定管理功能。False,綁定管理功能。GAPBondManagerDeleteAllvoiduser_entry_before_ble_init()函數調用GAPBondManagerDeleteSinglevoidgap_bond_manager_delete(uint8_t*mac_addr,uint8_tuser_entry_before_ble_init()函數調用GAPSetSecurityvoidgap_security_param_init(gap_security_param_t等。 gap_security_param_tparam{.mitm=.io_cap=.pair_init_mode=.bond=.password=GAPSendingPairingvoidgap_security_send_pairing_password(uint32_tconidx,uint32_tpin 號。號從0開始一直到app_config,h定義的最 GAPPairingvoidgap_security_pairing_req(uint8_t事件。 要發起綁定的號。號從0開始一直到app_config,h定義的最大數-1GAPEncryptvoidgap_security_enc_req(uint8_t操作。加密成功后,會產生GAP_SEC_EVT_MASTER_ENCRYPT事件。 要發起綁定的號。號從0開始一直到app_config,h定義的最大數-1GAPGetBondbool {{case{if}}}GAPSecurityvoidgap_security_req(uint8_t 要發送請求的號。號從0開始一直到app_config,h定義的最{{case{}}}BLESDK里面以源碼的形式實現了BLE常用profile,供用戶參考和修改。Profile可以在SDK安\components\ble\profiles下找到HumanInterfaceDevice。HID主要用于BLE鼠標鍵盤和的開發HIDservicehid_service.c文件中。HIDserviceservice定義和一系列特征值定義。HIDservice的特征值主要包含reportmapHID的input,outputreport這些特征值的內容可以根據不HID設備呈現出不同內容。SDKHIDservice//HIDDevicekeyboard備//!<hid//!<hidhidserverHIDinformationflags.const變量hid_info_value,HID_INFORMATION_UUID讀時的返回 //!<hidinformation標志位:可喚 hidinformationHIDprotocolmodevalues.PROTOCOL_MODE_UUID讀時的返回 //!<BootProtocolMode //!<ReportProtocolMode//對reportid//HIDreportmaptypedef{ ReportIDreportmap ReportTypereportid的屬性。參見HIDservicevoidhidserverprofile 要進行操作的號。號從0開始一直到app_config,h定義的最大數- 要進行操作的hid_rpt_info數組的序號。hid_rpt_info數組在hid_gatt_add_service()創建時賦值。內部[2reportid33]賦值為reportid3 DeviceInformationService。提供設備的產品信息以及軟硬件版本。代碼位于中DIS8設備模組名字string5SystemID8SystemID5設備PNP_ID定義7設備PNP_ID長度string5string設備IEEE數據定義6IEEE//Dissserverprofiledissserverdissserverdissserverdissserverdissserverdissserverdissserver包含Systemdissserver包含IEEEdissserver包含dissserverDISvoiddeviceinformationprofileBatteryBattery 用于實時電池電量。代碼位于components\ble\profiles\ble_batt中BATT//BatteryServerProfileattributestypedef{//!<Battserver//!<Battserverlevelcharact//!<Battserverlevelcharact//!<Battserverlevelcharact//!<BattserveridxBATTvoidbattserverprofilevoidbatt_gatt_notify(uint8_tconidx,uint8_t 要進行操作的號。號從0開始一直到app_config,h定義的最 OverTheAirdownload,空中固件升級。代碼位于components\ble\profiles\ble_otaOTAvoidOTAprofileOSAL 中Task位于components\modules\os\include\os_task.hTask函OSTaskuint16_tos_task_create(os_task_func_t 創建任務的id號,{{casecase1}return}void{user_task_id=}OSTaskvoidos_task_delete(uint8_t-OSMessagevoidos_msg_post(uint16_td

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論