tmui-cli 5.3.2 → 5.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/data/components.json +1 -1
  2. package/data/config.json +1 -1
  3. package/data/doc-index.json +7 -2
  4. package/data/guides//345/201/234/346/255/242/345/205/254/345/221/212.md +29 -0
  5. package/data/guides//346/233/264/346/226/260/346/227/245/345/277/227.md +5 -1
  6. package/data/tmui4x/01./346/225/231/347/250/213/02./346/233/264/346/226/260/346/227/245/345/277/227.md +1214 -1183
  7. package/data/tmui4x/10./346/217/222/344/273/266/345/272/223/xCorrectS /346/226/207/346/241/243/346/240/241/346/255/243/344/270/216/350/257/206/345/210/253.md" +1 -1
  8. package/data/tmui4x/10./346/217/222/344/273/266/345/272/223/xOfficeU Office /346/226/207/346/241/243/347/274/226/350/276/221.md" +1 -1
  9. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//344/272/214/347/273/264/347/240/201 xQrcoder.md" +1 -1
  10. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//345/212/250/347/224/273 xAnimation.md" +1 -1
  11. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//345/216/237/347/224/237/345/233/276/350/241/250 Chart.md" +1 -1
  12. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//345/233/276/347/211/207/350/243/201/345/211/252 xImageResizer.md" +3 -3
  13. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//345/233/276/350/241/250 xEchart.md" +2 -2
  14. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//345/256/211/345/205/250/351/252/214/350/257/201 xSafeVerify.md" +1 -1
  15. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//346/200/235/347/273/264/345/257/274/345/233/276 xTreeFlat.md" +1 -1
  16. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//346/211/213/345/212/277/345/272/223 xFinger.md" +1 -1
  17. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//346/217/220/345/217/212 xMention.md" +1 -1
  18. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//346/235/241/347/240/201 xBarcode.md" +1 -1
  19. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//346/273/221/345/212/250/351/252/214/350/257/201 xSlideVerify.md" +1 -1
  20. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//347/255/276/345/220/215/346/235/277 xSignBoard.md" +1 -1
  21. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//351/242/234/350/211/262/351/200/211/346/213/251 xColorView.md" +1 -1
  22. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/205/266/345/256/203/347/273/204/344/273/266//351/252/214/350/257/201/347/240/201/350/276/223/345/205/245/346/241/206 xCodeInput.md" +1 -1
  23. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//344/270/213/346/213/211/345/210/267/346/226/260 xPullRefresh.md" +1 -1
  24. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//344/270/213/346/213/211/350/217/234/345/215/225 xDropdownMenu.md" +1 -1
  25. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//344/270/213/346/213/211/350/217/234/345/215/225/345/255/220/347/273/204/344/273/266 xDropdownItem.md" +1 -1
  26. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/212/240/350/275/275/344/270/255 xLoading.md" +1 -1
  27. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/212/250/344/275/234/350/217/234/345/215/225/351/235/242/346/235/277 xActionMenu.md" +1 -1
  28. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/257/271/350/257/235/346/241/206 xModal.md" +1 -1
  29. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/267/246/346/273/221/350/217/234/345/215/225 xSwitchSlider.md" +1 -1
  30. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/272/225/351/203/250/345/257/271/350/257/235/346/241/206 xActionModal.md" +1 -1
  31. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/274/271/345/271/225 Barrage.md" +1 -1
  32. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//345/274/271/345/271/225/345/255/220/350/212/202/347/202/271 xBarrageItem.md" +1 -1
  33. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/212/275/345/261/211 xDrawer.md" +1 -1
  34. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/213/226/346/213/275/346/216/222/345/272/217 xDrag.md" +1 -1
  35. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/213/226/346/213/275/346/216/222/345/272/217/345/255/220/347/273/204/344/273/266 xDragItem.md" +1 -1
  36. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/261/275/346/263/241/350/217/234/345/215/225 xPopover.md" +1 -1
  37. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/265/256/345/212/250/351/235/242/346/235/277 FloatDrawer.md" +1 -1
  38. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/265/256/347/220/203 xFloatButton.md" +1 -1
  39. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/266/210/346/201/257/346/235/241 xSnackbar.md" +1 -1
  40. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/266/210/346/201/257/346/235/241/345/255/220/350/212/202/347/202/271 xSnackbarItem.md" +1 -1
  41. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//346/266/210/346/201/257/351/200/232/347/237/245 xMsgNotice.md" +1 -1
  42. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/217/215/351/246/210/347/273/204/344/273/266//351/201/256/347/275/251 xOverlay.md" +1 -1
  43. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//344/276/247/350/276/271/345/210/206/347/261/273 xSliderTree.md" +1 -1
  44. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//344/276/247/350/276/271/345/210/206/347/261/273/345/255/220/350/212/202/347/202/271 xSliderTreeChildren.md" +1 -1
  45. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//344/276/247/350/276/271/350/217/234/345/215/225 xSliderMenu.md" +1 -1
  46. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/215/225/351/200/211/346/214/211/351/222/256/347/273/204 xRadioButton.md" +1 -1
  47. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/256/253/346/240/274 xGrid.md" +1 -1
  48. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/256/253/346/240/274/345/255/220/347/273/204/344/273/266 xGridItem.md" +1 -1
  49. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/272/225/351/203/250/345/257/274/350/210/252 xTabbar.md" +1 -1
  50. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/274/225/345/257/274 xGuid.md" +1 -1
  51. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//345/274/225/345/257/274/345/255/220/347/273/204/344/273/266 xGuidItem.md" +1 -1
  52. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//346/220/234/347/264/242/346/240/217 xSearch.md" +1 -1
  53. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//346/227/266/351/227/264/345/221/250 xWeekbar.md" +1 -1
  54. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//346/240/207/347/255/276/345/257/274/350/210/252 xTabs.md" +1 -1
  55. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//346/240/207/351/242/230/345/257/274/350/210/252 xNavbar.md" +1 -1
  56. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//347/262/230/346/200/247/345/270/203/345/261/200 Sticky.md" +1 -1
  57. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//347/264/242/345/274/225 xIndexbar.md" +1 -1
  58. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/257/274/350/210/252/347/273/204/344/273/266//350/277/224/345/233/236/351/241/266/351/203/250 xBacktop.md" +1 -1
  59. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266/markdown xCmarkdown.md" +1 -1
  60. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/200/222/350/256/241/346/227/266 xCountdown.md" +1 -1
  61. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/210/206/345/211/262/347/272/277 xDivider.md" +1 -1
  62. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/210/227/350/241/250 xCell.md" +1 -1
  63. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/212/250/346/200/201/345/205/250/345/261/217 xViewTofull.md" +1 -1
  64. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/215/241/347/211/207 xCard.md" +1 -1
  65. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/233/276/347/211/207 xImage.md" +1 -1
  66. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/233/276/351/233/206 xImageGroup.md" +1 -1
  67. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/234/206/345/275/242/350/277/233/345/272/246/347/216/257 xCircleProgress.md" +1 -1
  68. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/244/264/345/203/217/347/273/204 xAvatarGroup.md" +1 -1
  69. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/257/214/346/226/207/346/234/254 xHtml.md" +3 -3
  70. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//345/257/214/346/226/207/346/234/254/345/255/220/347/273/204/344/273/266 xHtmlNode.md" +3 -3
  71. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/212/230/345/217/240/351/235/242/346/235/277 xCollapse.md" +1 -1
  72. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/212/230/345/217/240/351/235/242/346/235/277/345/255/220/347/273/204/344/273/266 xCollapseItem.md" +1 -1
  73. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/225/260/345/255/227/347/277/273/346/273/232 xRollingNumber.md" +1 -1
  74. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/237/245/347/234/213/346/233/264/345/244/232 xMore.md" +1 -1
  75. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/250/252/345/220/221/346/273/232/345/212/250 xScrollx.md" +1 -1
  76. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/255/245/351/252/244/346/235/241 xSteps.md" +1 -1
  77. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/255/245/351/252/244/346/235/241/345/255/220/347/273/204/344/273/266 xStepsItem.md" +1 -1
  78. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//346/260/264/345/215/260 xWatermark.md" +1 -1
  79. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//347/200/221/345/270/203/346/265/201 xWaterfall.md" +1 -1
  80. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//347/251/272/347/212/266/346/200/201 xEmpty.md" +1 -1
  81. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/231/232/346/213/237/345/210/227/350/241/250 xVirtualList.md" +1 -1
  82. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/241/250/346/240/274 xTable.md" +1 -1
  83. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/241/250/346/240/274/345/210/227 xTableCol.md" +1 -1
  84. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/247/222/346/240/207 xBadge.md" +1 -1
  85. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/255/246/345/221/212 xAlert.md" +1 -1
  86. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/257/215/344/272/221 xTextCloud.md" +8 -3
  87. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//350/277/233/345/272/246/346/235/241 xProgress.md" +1 -1
  88. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//351/200/232/347/237/245/346/240/217 xNotice.md" +1 -1
  89. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//351/207/221/351/242/235/346/240/205/346/240/274 xMoney.md" +1 -1
  90. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//351/223/276/346/216/245 xLink.md" +1 -1
  91. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/261/225/347/244/272/347/273/204/344/273/266//351/252/250/346/236/266/345/261/217 xSkeleton.md" +1 -1
  92. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//345/223/215/345/272/224/345/274/217/345/270/203/345/261/200 xLayout.md" +15 -25
  93. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//345/233/276/346/240/207 xIcon.md" +1 -1
  94. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//345/256/271/345/231/250 xSheet.md" +1 -1
  95. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//345/270/203/345/261/200 xRow.md" +1 -1
  96. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//345/270/203/345/261/200/345/255/220/347/273/204/344/273/266 xCol.md" +1 -1
  97. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//346/214/211/351/222/256 xButton.md" +74 -72
  98. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//346/226/207/346/234/254 xText.md" +1 -1
  99. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//345/270/270/347/224/250/347/273/204/344/273/266//346/240/207/347/255/276 xTag.md" +1 -1
  100. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/215/225/346/273/221/345/235/227 xSlider.md" +1 -1
  101. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/215/225/351/200/211/346/241/206 xRadio.md" +1 -1
  102. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/215/225/351/200/211/346/241/206/347/273/204 xRadioGroup.md" +1 -1
  103. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/217/214/345/220/221/346/273/221/345/235/227 xSliderDouble.md" +1 -1
  104. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/233/276/347/211/207/344/270/212/344/274/240 xUploadMedia.md" +1 -1
  105. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/237/216/345/270/202/351/200/211/346/213/251/345/231/250 xPickerCity.md" +1 -1
  106. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/244/232/351/200/211/346/227/245/345/216/206 xCalendarMultiple.md" +1 -1
  107. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/244/232/351/200/211/346/241/206 xCheckbox.md" +1 -1
  108. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/244/232/351/200/211/346/241/206/347/273/204 xCheckboxGroup.md" +1 -1
  109. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/257/206/347/240/201/351/224/256/347/233/230 xKeyboard.md" +1 -1
  110. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/257/214/346/226/207/346/234/254/347/274/226/350/276/221/345/231/250 xEditor.md" +1 -1
  111. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/265/214/345/205/245/345/274/217/346/227/245/346/234/237/351/200/211/346/213/251/345/231/250 xDateView.md" +1 -1
  112. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//345/274/200/345/205/263 xSwitch.md" +1 -1
  113. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/220/234/347/264/242/351/200/211/346/213/251 xpickerSelected.md" +1 -1
  114. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/225/260/345/255/227/351/224/256/347/233/230 xKeyboardNumber.md" +1 -1
  115. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/226/207/344/273/266/351/200/211/346/213/251 xUploadFile.md" +1 -1
  116. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/227/245/345/216/206 xCalendar.md" +1 -1
  117. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/227/245/346/234/237/351/200/211/346/213/251/345/231/250 xPickerDate.md" +1 -1
  118. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/227/266/351/227/264/345/214/272/351/227/264/351/200/211/346/213/251 xBetweenTime.md" +1 -1
  119. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/227/266/351/227/264/351/200/211/346/213/251/345/231/250 xPickerTime.md" +1 -1
  120. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/236/201/350/201/224/345/231/250 xCascader.md" +1 -1
  121. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/240/207/347/255/276/350/276/223/345/205/245/346/241/206 xInputTag.md" +1 -1
  122. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/240/221 xTree.md" +1 -1
  123. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//346/255/245/350/277/233/345/231/250 xStepper.md" +1 -1
  124. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//347/277/273/351/241/265/345/231/250 xPagination.md" +1 -1
  125. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/241/250/345/215/225 xForm.md" +139 -3
  126. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/241/250/345/215/225/345/255/220/347/273/204/344/273/266 xFormItem.md" +139 -4
  127. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/257/204/345/210/206 xRate.md" +1 -1
  128. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/272/253/344/273/275/350/257/201/351/224/256/347/233/230 xKeyboardIdcard.md" +1 -1
  129. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/275/246/347/211/214/351/224/256/347/233/230 xKeyboardCar.md" +1 -1
  130. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/276/223/345/205/245/346/241/206 xInput.md" +2 -2
  131. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//350/276/223/345/205/245/346/241/206 xInputNumber.md" +1 -1
  132. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//351/200/211/346/213/251/345/231/250 xPicker.md" +1 -1
  133. package/data/tmui4x/30./347/273/204/344/273/266/345/272/223//350/241/250/345/215/225/347/273/204/344/273/266//351/200/211/346/213/251/345/231/250/345/256/271/345/231/250 xPickerView.md" +1 -1
  134. package/data/tmui4x/60.AI/350/207/252/345/212/250/345/214/226/06.tokens/350/207/252/347/224/261.md +2 -6
  135. package/data/tmui4x-doc-index.json +1 -1
  136. package/data/uni-app-x-docs/.vuepress/utils/customTypeJson.json +1 -1
  137. package/data/uni-app-x-docs/.vuepress/utils/utsApiJson.json +1 -1
  138. package/data/uni-app-x-docs/.vuepress/utils/utsComJson.json +1 -1
  139. package/data/uni-app-x-docs/.vuepress/utils/utsJson.json +1 -1
  140. package/data/uni-app-x-docs/_sidebar.md +1 -0
  141. package/data/uni-app-x-docs/api/_sidebar.md +3 -0
  142. package/data/uni-app-x-docs/api/bluetooth-general.md +280 -0
  143. package/data/uni-app-x-docs/api/bluetooth-le-central.md +376 -0
  144. package/data/uni-app-x-docs/api/keyboard.md +6 -0
  145. package/data/uni-app-x-docs/api/memory.md +1 -1
  146. package/data/uni-app-x-docs/api/scrollviewcontext.md +111 -0
  147. package/data/uni-app-x-docs/api/unicloud/README.md +1 -1
  148. package/data/uni-app-x-docs/app-vapor.md +2 -41
  149. package/data/uni-app-x-docs/collocation/manifest-android.md +1 -1
  150. package/data/uni-app-x-docs/component/_sidebar.md +2 -1
  151. package/data/uni-app-x-docs/component/common.md +48 -2
  152. package/data/uni-app-x-docs/component/datacom.md +823 -0
  153. package/data/uni-app-x-docs/component/input.md +2 -2
  154. package/data/uni-app-x-docs/component/label.md +1 -1
  155. package/data/uni-app-x-docs/component/map.md +12 -12
  156. package/data/uni-app-x-docs/component/text.md +7 -3
  157. package/data/uni-app-x-docs/component/textarea.md +2 -6
  158. package/data/uni-app-x-docs/component/uni-ui-x/uni-expandable-text.md +22 -0
  159. package/data/uni-app-x-docs/component/web-view.md +65 -0
  160. package/data/uni-app-x-docs/css/common/style-isolation.md +8 -0
  161. package/data/uni-app-x-docs/css/word-break.md +3 -0
  162. package/data/uni-app-x-docs/native/download/android.md +83 -103
  163. package/data/uni-app-x-docs/native/download/ios.md +10 -10
  164. package/data/uni-app-x-docs/readme.md +2 -1
  165. package/data/uni-app-x-docs/release-note-alpha.md +39 -0
  166. package/data/uni-app-x-docs/release.md +144 -1
  167. package/data/uni-app-x-docs/sample.md +15 -12
  168. package/data/uni-app-x-docs/static/bluetooth-general-flow.svg +69 -0
  169. package/data/uni-app-x-docs/static/bluetooth-le-central-flow.svg +102 -0
  170. package/data/uniappx/_sidebar.md +1 -0
  171. package/data/uniappx/api/_sidebar.md +3 -0
  172. package/data/uniappx/api/app-route.md +10 -10
  173. package/data/uniappx/api/bluetooth-general.md +822 -0
  174. package/data/uniappx/api/bluetooth-le-central.md +1044 -0
  175. package/data/uniappx/api/calendar.md +4 -4
  176. package/data/uniappx/api/compress-image.md +1 -1
  177. package/data/uniappx/api/contact.md +0 -4
  178. package/data/uniappx/api/convert2-abs-full-path.md +4 -0
  179. package/data/uniappx/api/create-canvas-context-async.md +0 -4
  180. package/data/uniappx/api/create-inner-audio-context.md +1 -1
  181. package/data/uniappx/api/get-app-base-info.md +1 -1
  182. package/data/uniappx/api/get-location.md +2 -2
  183. package/data/uniappx/api/get-recorder-manager.md +1 -1
  184. package/data/uniappx/api/get-video-info.md +1 -1
  185. package/data/uniappx/api/gyroscope.md +8 -8
  186. package/data/uniappx/api/install-wgt.md +4 -0
  187. package/data/uniappx/api/keyboard.md +6 -0
  188. package/data/uniappx/api/loading.md +2 -2
  189. package/data/uniappx/api/memory.md +1 -1
  190. package/data/uniappx/api/modal.md +1 -1
  191. package/data/uniappx/api/preview-image.md +4 -4
  192. package/data/uniappx/api/report.md +0 -4
  193. package/data/uniappx/api/request-system-permission.md +2 -2
  194. package/data/uniappx/api/screen-brightness.md +6 -6
  195. package/data/uniappx/api/scrollviewcontext.md +3 -0
  196. package/data/uniappx/api/toast.md +2 -2
  197. package/data/uniappx/api/uasm.md +4 -4
  198. package/data/uniappx/api/unicloud/README.md +1 -1
  199. package/data/uniappx/api/uniresizeobserver.md +144 -27
  200. package/data/uniappx/api/vibrate.md +8 -0
  201. package/data/uniappx/app-vapor.md +2 -41
  202. package/data/uniappx/collocation/manifest-android.md +1 -1
  203. package/data/uniappx/component/_sidebar.md +2 -1
  204. package/data/uniappx/component/animation-view.md +2 -2
  205. package/data/uniappx/component/camera.md +1 -1
  206. package/data/uniappx/component/canvas.md +2 -2
  207. package/data/uniappx/component/common.md +48 -1
  208. package/data/uniappx/component/datacom.md +683 -0
  209. package/data/uniappx/component/editor.md +1 -1
  210. package/data/uniappx/component/image.md +1 -1
  211. package/data/uniappx/component/input.md +2 -2
  212. package/data/uniappx/component/label.md +1 -1
  213. package/data/uniappx/component/map.md +12 -12
  214. package/data/uniappx/component/progress.md +3 -3
  215. package/data/uniappx/component/radio.md +1 -1
  216. package/data/uniappx/component/rich-text.md +3 -3
  217. package/data/uniappx/component/swiper.md +1 -1
  218. package/data/uniappx/component/switch.md +2 -2
  219. package/data/uniappx/component/text.md +9 -5
  220. package/data/uniappx/component/textarea.md +2 -6
  221. package/data/uniappx/component/uni-ui-x/README.md +21 -19
  222. package/data/uniappx/component/uni-ui-x/uni-collapse.md +8 -0
  223. package/data/uniappx/component/uni-ui-x/uni-combox.md +19 -0
  224. package/data/uniappx/component/uni-ui-x/uni-drag-cell.md +4 -0
  225. package/data/uniappx/component/uni-ui-x/uni-expandable-text.md +120 -0
  226. package/data/uniappx/component/uni-ui-x/uni-fab-button.md +4 -0
  227. package/data/uniappx/component/uni-ui-x/uni-icons.md +60 -18
  228. package/data/uniappx/component/uni-ui-x/uni-index-bar.md +4 -0
  229. package/data/uniappx/component/uni-ui-x/uni-link.md +4 -0
  230. package/data/uniappx/component/uni-ui-x/uni-nav-bar.md +4 -0
  231. package/data/uniappx/component/uni-ui-x/uni-number-box.md +4 -0
  232. package/data/uniappx/component/uni-ui-x/uni-rate.md +2 -2
  233. package/data/uniappx/component/uni-ui-x/uni-refresh-box.md +4 -0
  234. package/data/uniappx/component/uni-ui-x/uni-tab.md +16 -0
  235. package/data/uniappx/component/uni-ui-x/uni-time-format.md +4 -0
  236. package/data/uniappx/component/view.md +1 -1
  237. package/data/uniappx/component/waterflow.md +1 -1
  238. package/data/uniappx/component/web-view.md +54 -1
  239. package/data/uniappx/css/common/style-isolation.md +8 -0
  240. package/data/uniappx/css/word-break.md +3 -0
  241. package/data/uniappx/native/download/android.md +80 -100
  242. package/data/uniappx/native/download/ios.md +10 -10
  243. package/data/uniappx/readme.md +2 -1
  244. package/data/uniappx/release-note-alpha.md +39 -0
  245. package/data/uniappx/release.md +143 -0
  246. package/data/uniappx/sample.md +15 -12
  247. package/data/uniappx/uts/buildin-object-api/global.md +2 -2
  248. package/data/uniappx/uts/buildin-object-api/utsjsonobject.md +4 -0
  249. package/data/uniappx-doc-index.json +99 -25
  250. package/package.json +1 -1
@@ -0,0 +1,1044 @@
1
+ ::: warning 注意事项
2
+
3
+ 使用前,需先按[蓝牙-通用](./bluetooth-general.md)中的流程初始化适配器并发现目标设备。建立连接后,先发现服务和特征值,再进行读写或开启通知;断开连接后需重新连接并重新发现服务与特征值。
4
+
5
+ ## 模块介绍
6
+
7
+ 蓝牙低功耗(BLE)中心设备相关接口,用于与蓝牙设备建立连接、发现其服务与特征值,并对特征值进行读写、订阅通知等操作。
8
+
9
+ - **服务**:设备对外提供的一组功能,由 UUID 标识,可包含一个或多个特征值;
10
+ - **特征值**:服务下的数据点,由 UUID 标识,其 `properties` 描述支持的操作,如 read、write、notify、indicate 等;
11
+ - **UUID**:用于标识服务和特征值。调用接口时,使用 uni.getBLEDeviceServices 和 uni.getBLEDeviceCharacteristics 返回的 UUID。
12
+
13
+ 本文负责连接与数据通信,[蓝牙-通用](./bluetooth-general.md)负责适配器管理与设备发现。各接口及参数的支持范围以对应的兼容性表为准。
14
+
15
+ ## 使用流程
16
+
17
+ <a href="../static/bluetooth-le-central-flow.svg" target="_blank" rel="noopener"></a>
18
+
19
+ 1. 注册 [uni.onBLEConnectionStateChange](#onbleconnectionstatechange) 和 [uni.onBLECharacteristicValueChange](#onblecharacteristicvaluechange),分别接收连接状态变化和特征值数据。
20
+ 2. 使用扫描返回的 `deviceId`,调用 [uni.createBLEConnection](#createbleconnection) 连接目标设备。
21
+ 3. 连接成功后,调用 [uni.getBLEDeviceServices](#getbledeviceservices) 发现服务,再调用 [uni.getBLEDeviceCharacteristics](#getbledevicecharacteristics) 获取目标服务的特征值及其属性。
22
+ 4. 按特征值属性调用 [uni.readBLECharacteristicValue](#readblecharacteristicvalue) 或 [uni.writeBLECharacteristicValue](#writeblecharacteristicvalue)。调用 `readBLECharacteristicValue` 前需先注册 `onBLECharacteristicValueChange`,读取结果通过该事件的 `value` 返回;读取不要求先开启通知。
23
+ 5. 如需接收外设主动发送的数据,调用 [uni.notifyBLECharacteristicValueChange](#notifyblecharacteristicvaluechange) 开启通知,通过已注册的特征值变化事件监听接收数据。
24
+ 6. 按需调用 [uni.getBLEDeviceRSSI](#getbledevicerssi) 获取信号强度;iOS 写入长度与 MTU 的说明见 [uni.getBLEMTU](#getblemtu) 和 [uni.setBLEMTU](#setblemtu)。
25
+ 7. 不再需要通知时将其关闭;通信结束后调用 [uni.closeBLEConnection](#closebleconnection),并移除当前页面或组件注册的事件监听。
26
+
27
+ ## 权限@permission
28
+
29
+ 蓝牙权限与[蓝牙-通用](./bluetooth-general.md#permission)一致,请先按该页完成各端权限配置。
30
+
31
+ ## 注意事项@tips
32
+
33
+ ### 通用
34
+
35
+ - **以特征值属性为准**:读、写和通知分别要求特征值支持对应的操作;支持读取不代表支持通知或写入。
36
+ - **重新连接后重新发现**:断线重连后,应重新获取服务与特征值,并按需开启通知,不要直接沿用上次连接的结果。
37
+ - **区分通知与事件监听**:关闭外设通知需调用 `notifyBLECharacteristicValueChange` 并传入 `state: false`;`offBLECharacteristicValueChange` 只移除事件监听,不能代替关闭通知。
38
+ - **按监听所属范围清理**:不再使用时移除自身注册的特征值和连接状态监听。当前 iOS 插件可保存 `on*` 返回的监听 ID,并将该 ID 传给对应的 `off*`,避免清空其他页面的监听。
39
+ - **控制写入长度与时序**:单次写入长度由平台和当前连接决定,超长数据需由业务分包;同一连接上的读写与通知配置操作宜按完成回调依次执行。
40
+
41
+ ::: sourceCode
42
+ ## uni.createBLEConnection(options) @createbleconnection
43
+
44
+ 连接低功耗蓝牙设备
45
+
46
+ 文档: [http://uniapp.dcloud.io/api/system/ble?id=createbleconnection](http://uniapp.dcloud.io/api/system/ble?id=createbleconnection)
47
+
48
+ ### 参数
49
+
50
+ | 名称 | 类型 | 必填 |
51
+ | :- | :- | :- |
52
+ | options | [UniNamespace.CreateBLEConnectionOptions](#uninamespace-values) | 是 |
53
+ | 名称 | 类型 | 必备 | 描述 |
54
+ | :- | :- | :- | :- |
55
+ | deviceId | string | 是 | 蓝牙设备 id,参考 getDevices 接口 |
56
+ | timeout | number | 否 | 超时时间 |
57
+ | success | (result: any) => void | 否 | 成功则返回本机蓝牙适配器状态 |
58
+ | fail | (result: any) => void | 否 | 接口调用失败的回调函数 |
59
+ | complete | (result: any) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
60
+
61
+ ### 参见
62
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.createBLEConnection)
63
+ - [微信小程序文档](https://developers.weixin.qq.com/doc/search.html?source=enter&query=createBLEConnection&doc_type=miniprogram)
64
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=createBLEConnection&pageIndex=1&pageSize=10&source=doc_top&type=all)
65
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=createBLEConnection&scope=devdocs&source=docs)
66
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=createBLEConnection&secondType=all&type=1)
67
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=createBLEConnection&topicFilter=)
68
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=createBLEConnection)
69
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
70
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=createBLEConnection&from=docs)
71
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
72
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
73
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
74
+
75
+ ### iOS 使用说明
76
+
77
+ - 先初始化适配器并扫描到目标设备,再传入扫描返回的 `deviceId`。能扫描到设备只表示收到了广播,不保证外设当前接受连接。
78
+ - 先注册 `onBLEConnectionStateChange`,再发起连接。同一设备不要并行调用多次 `createBLEConnection`,避免重复连接导致失败。
79
+ - 在 `success` 回调后调用 `getBLEDeviceServices` 和 `getBLEDeviceCharacteristics`,再开始读写或开启通知。连接成功不代表服务发现、特征值发现或业务认证已完成。
80
+ - `timeout` 的单位是毫秒,应设置为大于 0 的数值,并结合真机耗时确定。当前 iOS 插件不传时不设置连接超时期限,但仍可能因系统报告失败或适配器状态变化而结束。
81
+ - 当前 iOS 插件对已经连接的设备再次调用连接会返回成功。
82
+
83
+ ### iOS 连接失败与超时排查 @ios-connection-troubleshooting
84
+
85
+ `createBLEConnection` 失败时,先确认适配器已初始化且可用,并使用扫描返回的 `deviceId`。连接成功后的服务发现、读写和通知问题,应按对应接口排查。
86
+
87
+ 连接超时表示未在指定时间内完成连接,不代表设备已关机或停止广播;等待上一次断开完成也可能超时。能扫描到设备,不代表设备当前接受连接。
88
+
89
+ 可按以下方向排查:
90
+
91
+ | 可能原因 | 检查与处理方式 |
92
+ | --- | --- |
93
+ | 信号弱或干扰 | 靠近外设,在干扰较少的环境中重试。 |
94
+ | 外设被占用或不可连接 | 断开其他手机、App 或调试工具的连接,确认外设处于可连接模式。 |
95
+ | 重复连接或断开未完成 | 同一设备只保留一个连接流程,避免并行连接或立即反复重连。 |
96
+ | 超时时间过短 | 结合正常连接耗时,适当增加 `timeout` 后对比。 |
97
+ | 外设重启或配对信息变化 | 重新扫描;若提示配对异常,按设备说明重新配对。持续失败时检查外设日志。 |
98
+ | 连接过多或系统暂不可用 | 关闭不必要的连接和扫描,通过 `onBluetoothAdapterStateChange` 确认可用后再试。 |
99
+
100
+ 重试应设置间隔和次数上限,持续失败时提示用户检查设备。重连成功后,需重新发现服务和特征值,并按需开启通知。仍无法定位时,可按[调试建议](#调试建议)使用蓝牙工具对照验证。
101
+
102
+ ::: sourceCode
103
+ ## uni.closeBLEConnection(options) @closebleconnection
104
+
105
+ 断开与低功耗蓝牙设备的连接
106
+
107
+ 文档: [http://uniapp.dcloud.io/api/system/ble?id=closebleconnection](http://uniapp.dcloud.io/api/system/ble?id=closebleconnection)
108
+
109
+ ### 参数
110
+
111
+ | 名称 | 类型 | 必填 |
112
+ | :- | :- | :- |
113
+ | options | [UniNamespace.CloseBLEConnectionOptions](#uninamespace-values) | 是 |
114
+ | 名称 | 类型 | 必备 | 描述 |
115
+ | :- | :- | :- | :- |
116
+ | success | (result: any) => void | 否 | 接口调用成功的回调函数 |
117
+ | fail | (result: any) => void | 否 | 接口调用失败的回调函数 |
118
+ | complete | (result: any) => void | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
119
+ | deviceId | string | 是 | 蓝牙设备 id,参考 device 对象 |
120
+
121
+ ### 参见
122
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.closeBLEConnection)
123
+ - [微信小程序文档](https://developers.weixin.qq.com/doc/search.html?source=enter&query=closeBLEConnection&doc_type=miniprogram)
124
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=closeBLEConnection&pageIndex=1&pageSize=10&source=doc_top&type=all)
125
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=closeBLEConnection&scope=devdocs&source=docs)
126
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=closeBLEConnection&secondType=all&type=1)
127
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=closeBLEConnection&topicFilter=)
128
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=closeBLEConnection)
129
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
130
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=closeBLEConnection&from=docs)
131
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
132
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
133
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
134
+
135
+ ::: sourceCode
136
+ ## uni.onBLEConnectionStateChange(callback) @onbleconnectionstatechange
137
+
138
+ 监听低功耗蓝牙设备连接状态变化事件
139
+
140
+ 文档: [http://uniapp.dcloud.io/api/system/ble?id=onbleconnectionstatechange](http://uniapp.dcloud.io/api/system/ble?id=onbleconnectionstatechange)
141
+
142
+ ### 参数
143
+
144
+ | 名称 | 类型 | 必填 |
145
+ | :- | :- | :- |
146
+ | callback | (result: [UniNamespace.OnBLEConnectionStateChangeSuccess](#uninamespace-values)) => void | 是 |
147
+
148
+ ### UniNamespace.OnBLEConnectionStateChangeSuccess 的属性值 @uninamespace-values
149
+
150
+ | 名称 | 类型 | 必备 | 描述 |
151
+ | :- | :- | :- | :- |
152
+ | deviceId | string | 是 | 蓝牙设备 id,参考 device 对象 |
153
+ | connected | boolean | 是 | 连接目前的状态 |
154
+
155
+ ### 参见
156
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.onBLEConnectionStateChange)
157
+ - [微信小程序文档](https://developers.weixin.qq.com/doc/search.html?source=enter&query=onBLEConnectionStateChange&doc_type=miniprogram)
158
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=onBLEConnectionStateChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
159
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=onBLEConnectionStateChange&scope=devdocs&source=docs)
160
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=onBLEConnectionStateChange&secondType=all&type=1)
161
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=onBLEConnectionStateChange&topicFilter=)
162
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=onBLEConnectionStateChange)
163
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
164
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=onBLEConnectionStateChange&from=docs)
165
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
166
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
167
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
168
+
169
+ ::: sourceCode
170
+ ## uni.offBLEConnectionStateChange(listener?) @offbleconnectionstatechange
171
+
172
+ 移除 BLE 连接状态变化监听。传 ID 删除对应监听,否则清空全部监听。
173
+
174
+ ### offBLEConnectionStateChange 兼容性
175
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
176
+ | :- | :- | :- | :- | :- | :- | :- |
177
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
178
+
179
+ ### 参数
180
+
181
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
182
+ | :- | :- | :- | :-: | :- |
183
+ | listener | number \| (result: **BLEConnectionStateChangeResult**) => void | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
184
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
185
+ | :- | :- | :- | :-: | :- |
186
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
187
+ | connected | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 是否处于已连接状态。 |
188
+
189
+ ### 参见
190
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.offBLEConnectionStateChange)
191
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEConnectionStateChange.html)
192
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=offBLEConnectionStateChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
193
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=offBLEConnectionStateChange&scope=devdocs&source=docs)
194
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=offBLEConnectionStateChange&secondType=all&type=1)
195
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=offBLEConnectionStateChange&topicFilter=)
196
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=offBLEConnectionStateChange)
197
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
198
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=offBLEConnectionStateChange&from=docs)
199
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
200
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
201
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
202
+
203
+ ::: sourceCode
204
+ ## uni.getBLEDeviceRSSI(options) @getbledevicerssi
205
+
206
+ 获取蓝牙低功耗设备的信号强度 (Received Signal Strength Indication, RSSI)。
207
+
208
+ ### getBLEDeviceRSSI 兼容性
209
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
210
+ | :- | :- | :- | :- | :- | :- | :- |
211
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
212
+
213
+ ### 参数
214
+
215
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
216
+ | :- | :- | :- | :-: | :- |
217
+ | options | **GetBLEDeviceRSSIOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
218
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
219
+ | :- | :- | :- | :-: | :- |
220
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
221
+ | success | (result: [GetBLEDeviceRSSISuccess](#getbledevicerssisuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
222
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
223
+ | complete | (result: [GetBLEDeviceRSSISuccess](#getbledevicerssisuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
224
+
225
+ #### GetBLEDeviceRSSISuccess 的属性值 @getbledevicerssisuccess-values
226
+
227
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
228
+ | :- | :- | :- | :-: | :- |
229
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
230
+ | RSSI | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 信号强度,单位 dBm。 |
231
+
232
+ #### BluetoothFail 的属性值 @bluetoothfail-values
233
+
234
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
235
+ | :- | :- | :- | :-: | :- |
236
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
237
+ | 合法值 | 兼容性 | 描述 |
238
+ | :- | :-: | :- |
239
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
240
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
241
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
242
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
243
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
244
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
245
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
246
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
247
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
248
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
249
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
250
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
251
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
252
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
253
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
254
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
255
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
256
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
257
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
258
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
259
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
260
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
261
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
262
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
263
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
264
+
265
+ ### 参见
266
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.getBLEDeviceRSSI)
267
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceRSSI.html)
268
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=getBLEDeviceRSSI&pageIndex=1&pageSize=10&source=doc_top&type=all)
269
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=getBLEDeviceRSSI&scope=devdocs&source=docs)
270
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=getBLEDeviceRSSI&secondType=all&type=1)
271
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=getBLEDeviceRSSI&topicFilter=)
272
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=getBLEDeviceRSSI)
273
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
274
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=getBLEDeviceRSSI&from=docs)
275
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
276
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
277
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
278
+
279
+ ::: sourceCode
280
+ ## uni.getBLEMTU(options) @getblemtu
281
+
282
+ 获取蓝牙低功耗的最大传输单元。需在 uni.createBLEConnection 调用成功后调用。
283
+
284
+ ### getBLEMTU 兼容性
285
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
286
+ | :- | :- | :- | :- | :- | :- | :- |
287
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
288
+
289
+ ### 参数
290
+
291
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
292
+ | :- | :- | :- | :-: | :- |
293
+ | options | **GetBLEMTUOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
294
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
295
+ | :- | :- | :- | :-: | :- |
296
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
297
+ | writeType | string | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 写模式,仅 iOS 使用。可选值为 write、writeNoResponse,默认值为 write。 |
298
+ @@| 合法值 | 兼容性 | 描述 |
299
+ @@| :- | :-: | :- |
300
+ @@| "write" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 强制回复写,不支持时报错 |
301
+ @@| "writeNoResponse" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 强制无回复写,不支持时报错 |
302
+ | success | (result: [GetBLEMTUSuccess](#getblemtusuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
303
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
304
+ | complete | (result: [GetBLEMTUSuccess](#getblemtusuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
305
+
306
+ #### GetBLEMTUSuccess 的属性值 @getblemtusuccess-values
307
+
308
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
309
+ | :- | :- | :- | :-: | :- |
310
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
311
+ | mtu | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 最大传输单元,单位 bytes。 |
312
+
313
+ #### BluetoothFail 的属性值 @bluetoothfail-values
314
+
315
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
316
+ | :- | :- | :- | :-: | :- |
317
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
318
+ | 合法值 | 兼容性 | 描述 |
319
+ | :- | :-: | :- |
320
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
321
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
322
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
323
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
324
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
325
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
326
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
327
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
328
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
329
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
330
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
331
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
332
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
333
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
334
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
335
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
336
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
337
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
338
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
339
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
340
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
341
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
342
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
343
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
344
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
345
+
346
+ ### 参见
347
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.getBLEMTU)
348
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEMTU.html)
349
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=getBLEMTU&pageIndex=1&pageSize=10&source=doc_top&type=all)
350
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=getBLEMTU&scope=devdocs&source=docs)
351
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=getBLEMTU&secondType=all&type=1)
352
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=getBLEMTU&topicFilter=)
353
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=getBLEMTU)
354
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
355
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=getBLEMTU&from=docs)
356
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
357
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
358
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
359
+
360
+ ### iOS 注意事项
361
+
362
+ - 当前 iOS 插件返回的 `mtu` 是指定 `writeType` 对应的最大可写数据长度,单位为字节,不是 ATT MTU;不传 `writeType` 时按 `write` 查询。
363
+ - 直接以返回值作为该写模式的单次写入长度上限,无需再减 3,也不能通过加 3 推算 ATT MTU。查询时的 `writeType` 应与实际写入时一致。
364
+ - 返回的长度上限不代表外设业务协议支持任意长度的数据,分包还需遵循设备协议。
365
+
366
+ ::: sourceCode
367
+ ## uni.setBLEMTU(options) @setblemtu
368
+
369
+ 设置最大传输单元,仅 Android 支持。
370
+
371
+ ### setBLEMTU 兼容性
372
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
373
+ | :- | :- | :- | :- | :- | :- | :- |
374
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
375
+
376
+ ### 参数
377
+
378
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
379
+ | :- | :- | :- | :-: | :- |
380
+ | options | **SetBLEMTUOptions** | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 仅 Android 支持。 |
381
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
382
+ | :- | :- | :- | :-: | :- |
383
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
384
+ | mtu | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 最大传输单元,取值范围为 (22, 512),单位 bytes。 |
385
+ | success | (result: [SetBLEMTUSuccess](#setblemtusuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
386
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
387
+ | complete | (result: [SetBLEMTUSuccess](#setblemtusuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
388
+
389
+ #### SetBLEMTUSuccess 的属性值 @setblemtusuccess-values
390
+
391
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
392
+ | :- | :- | :- | :-: | :- |
393
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
394
+ | mtu | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值,与传入参数一致,单位 bytes。 |
395
+
396
+ #### BluetoothFail 的属性值 @bluetoothfail-values
397
+
398
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
399
+ | :- | :- | :- | :-: | :- |
400
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
401
+ | 合法值 | 兼容性 | 描述 |
402
+ | :- | :-: | :- |
403
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
404
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
405
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
406
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
407
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
408
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
409
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
410
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
411
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
412
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
413
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
414
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
415
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
416
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
417
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
418
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
419
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
420
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
421
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
422
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
423
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
424
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
425
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
426
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
427
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
428
+
429
+ ### 参见
430
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.setBLEMTU)
431
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.setBLEMTU.html)
432
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=setBLEMTU&pageIndex=1&pageSize=10&source=doc_top&type=all)
433
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=setBLEMTU&scope=devdocs&source=docs)
434
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=setBLEMTU&secondType=all&type=1)
435
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=setBLEMTU&topicFilter=)
436
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=setBLEMTU)
437
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
438
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=setBLEMTU&from=docs)
439
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
440
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
441
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
442
+
443
+ ### iOS 注意事项
444
+
445
+ iOS 不支持主动设置 MTU,当前插件调用此接口会执行 `fail` 和 `complete`,返回不支持错误。写入前可通过 `getBLEMTU` 查询对应写模式的最大可写长度。
446
+
447
+ ::: sourceCode
448
+ ## uni.onBLEMTUChange(listener) @onblemtuchange
449
+
450
+ 监听 MTU 变化,仅 Android 支持。
451
+
452
+ ### onBLEMTUChange 兼容性
453
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
454
+ | :- | :- | :- | :- | :- | :- | :- |
455
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
456
+
457
+ ### 参数
458
+
459
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
460
+ | :- | :- | :- | :-: | :- |
461
+ | listener | (result: [BLEMTUChangeResult](#blemtuchangeresult-values)) => void | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
462
+
463
+ ### BLEMTUChangeResult 的属性值 @blemtuchangeresult-values
464
+
465
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
466
+ | :- | :- | :- | :-: | :- |
467
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
468
+ | mtu | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 最大传输单元,单位 bytes。 |
469
+
470
+ ### 返回值
471
+
472
+ | 类型 |
473
+ | :- |
474
+ | number |
475
+
476
+ ### 参见
477
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.onBLEMTUChange)
478
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLEMTUChange.html)
479
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=onBLEMTUChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
480
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=onBLEMTUChange&scope=devdocs&source=docs)
481
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=onBLEMTUChange&secondType=all&type=1)
482
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=onBLEMTUChange&topicFilter=)
483
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=onBLEMTUChange)
484
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
485
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=onBLEMTUChange&from=docs)
486
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
487
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
488
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
489
+
490
+ ::: sourceCode
491
+ ## uni.offBLEMTUChange(listener?) @offblemtuchange
492
+
493
+ 移除 MTU 变化监听,仅 Android 支持。传 ID 删除对应监听,否则清空全部监听。
494
+
495
+ ### offBLEMTUChange 兼容性
496
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
497
+ | :- | :- | :- | :- | :- | :- | :- |
498
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
499
+
500
+ ### 参数
501
+
502
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
503
+ | :- | :- | :- | :-: | :- |
504
+ | listener | number \| (result: **BLEMTUChangeResult**) => void | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
505
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
506
+ | :- | :- | :- | :-: | :- |
507
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
508
+ | mtu | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 最大传输单元,单位 bytes。 |
509
+
510
+ ### 参见
511
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.offBLEMTUChange)
512
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLEMTUChange.html)
513
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=offBLEMTUChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
514
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=offBLEMTUChange&scope=devdocs&source=docs)
515
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=offBLEMTUChange&secondType=all&type=1)
516
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=offBLEMTUChange&topicFilter=)
517
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=offBLEMTUChange)
518
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
519
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=offBLEMTUChange&from=docs)
520
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
521
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
522
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
523
+
524
+ ::: sourceCode
525
+ ## uni.getBLEDeviceServices(options) @getbledeviceservices
526
+
527
+ 获取蓝牙低功耗设备所有服务 (service)。
528
+
529
+ ### getBLEDeviceServices 兼容性
530
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
531
+ | :- | :- | :- | :- | :- | :- | :- |
532
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
533
+
534
+ ### 参数
535
+
536
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
537
+ | :- | :- | :- | :-: | :- |
538
+ | options | **GetBLEDeviceServicesOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
539
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
540
+ | :- | :- | :- | :-: | :- |
541
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
542
+ | success | (result: [GetBLEDeviceServicesSuccess](#getbledeviceservicessuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
543
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
544
+ | complete | (result: [GetBLEDeviceServicesSuccess](#getbledeviceservicessuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
545
+
546
+ #### GetBLEDeviceServicesSuccess 的属性值 @getbledeviceservicessuccess-values
547
+
548
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
549
+ | :- | :- | :- | :-: | :- |
550
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
551
+ | services | Array&lt;**BLEService**&gt; | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 设备服务列表。 |
552
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
553
+ | :- | :- | :- | :-: | :- |
554
+ | uuid | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备服务的 UUID。 |
555
+ | isPrimary | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该服务是否为主服务。 |
556
+
557
+ #### BluetoothFail 的属性值 @bluetoothfail-values
558
+
559
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
560
+ | :- | :- | :- | :-: | :- |
561
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
562
+ | 合法值 | 兼容性 | 描述 |
563
+ | :- | :-: | :- |
564
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
565
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
566
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
567
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
568
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
569
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
570
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
571
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
572
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
573
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
574
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
575
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
576
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
577
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
578
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
579
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
580
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
581
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
582
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
583
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
584
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
585
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
586
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
587
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
588
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
589
+
590
+ ### 参见
591
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.getBLEDeviceServices)
592
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceServices.html)
593
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=getBLEDeviceServices&pageIndex=1&pageSize=10&source=doc_top&type=all)
594
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=getBLEDeviceServices&scope=devdocs&source=docs)
595
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=getBLEDeviceServices&secondType=all&type=1)
596
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=getBLEDeviceServices&topicFilter=)
597
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=getBLEDeviceServices)
598
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
599
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=getBLEDeviceServices&from=docs)
600
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
601
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
602
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
603
+
604
+ ::: sourceCode
605
+ ## uni.getBLEDeviceCharacteristics(options) @getbledevicecharacteristics
606
+
607
+ 获取蓝牙低功耗设备某个服务中所有特征 (characteristic)。
608
+
609
+ ### getBLEDeviceCharacteristics 兼容性
610
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
611
+ | :- | :- | :- | :- | :- | :- | :- |
612
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
613
+
614
+ ### 参数
615
+
616
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
617
+ | :- | :- | :- | :-: | :- |
618
+ | options | **GetBLEDeviceCharacteristicsOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
619
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
620
+ | :- | :- | :- | :-: | :- |
621
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
622
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙服务 UUID,需要先调用 getBLEDeviceServices 获取。 |
623
+ | success | (result: [GetBLEDeviceCharacteristicsSuccess](#getbledevicecharacteristicssuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
624
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
625
+ | complete | (result: [GetBLEDeviceCharacteristicsSuccess](#getbledevicecharacteristicssuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
626
+
627
+ #### GetBLEDeviceCharacteristicsSuccess 的属性值 @getbledevicecharacteristicssuccess-values
628
+
629
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
630
+ | :- | :- | :- | :-: | :- |
631
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
632
+ | characteristics | Array&lt;**BLECharacteristic**&gt; | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 设备特征列表。 |
633
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
634
+ | :- | :- | :- | :-: | :- |
635
+ | uuid | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备特征的 UUID。 |
636
+ | properties | **BLECharacteristicProperties** | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征支持的操作类型。 |
637
+ @@| 名称 | 类型 | 必备 | 兼容性 | 描述 |
638
+ @@| :- | :- | :- | :-: | :- |
639
+ @@| read | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持 read 操作。 |
640
+ @@| write | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持 write 操作。 |
641
+ @@| notify | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持 notify 操作。 |
642
+ @@| indicate | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持 indicate 操作。 |
643
+ @@| writeNoResponse | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持无回复写操作。 |
644
+ @@| writeDefault | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 该特征是否支持有回复写操作。 |
645
+
646
+ #### BluetoothFail 的属性值 @bluetoothfail-values
647
+
648
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
649
+ | :- | :- | :- | :-: | :- |
650
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
651
+ | 合法值 | 兼容性 | 描述 |
652
+ | :- | :-: | :- |
653
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
654
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
655
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
656
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
657
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
658
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
659
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
660
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
661
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
662
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
663
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
664
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
665
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
666
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
667
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
668
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
669
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
670
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
671
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
672
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
673
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
674
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
675
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
676
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
677
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
678
+
679
+ ### 参见
680
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.getBLEDeviceCharacteristics)
681
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.getBLEDeviceCharacteristics.html)
682
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=getBLEDeviceCharacteristics&pageIndex=1&pageSize=10&source=doc_top&type=all)
683
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=getBLEDeviceCharacteristics&scope=devdocs&source=docs)
684
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=getBLEDeviceCharacteristics&secondType=all&type=1)
685
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=getBLEDeviceCharacteristics&topicFilter=)
686
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=getBLEDeviceCharacteristics)
687
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
688
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=getBLEDeviceCharacteristics&from=docs)
689
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
690
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
691
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
692
+
693
+ ::: sourceCode
694
+ ## uni.readBLECharacteristicValue(options) @readblecharacteristicvalue
695
+
696
+ 读取蓝牙低功耗设备特征值的二进制数据。注意:必须设备的特征支持 read 才可以成功调用;读取结果通过 onBLECharacteristicValueChange 返回。
697
+
698
+ ### readBLECharacteristicValue 兼容性
699
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
700
+ | :- | :- | :- | :- | :- | :- | :- |
701
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
702
+
703
+ ### 参数
704
+
705
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
706
+ | :- | :- | :- | :-: | :- |
707
+ | options | **ReadBLECharacteristicValueOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
708
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
709
+ | :- | :- | :- | :-: | :- |
710
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
711
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征对应服务的 UUID,需要先调用 getBLEDeviceServices 获取。 |
712
+ | characteristicId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征的 UUID,需要先调用 getBLEDeviceCharacteristics 获取。 |
713
+ | success | (result: [BLEOperationSuccess](#bleoperationsuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。特征值通过 onBLECharacteristicValueChange 返回。 |
714
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
715
+ | complete | (result: [BLEOperationSuccess](#bleoperationsuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
716
+
717
+ #### BLEOperationSuccess 的属性值 @bleoperationsuccess-values
718
+
719
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
720
+ | :- | :- | :- | :-: | :- |
721
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
722
+ | errCode | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误码<br/><br/>\| 错误码 \| 错误信息 \| 说明 \|<br/>\| - \| - \| - \|<br/>\| 0 \| ok \| 正常 \|<br/>\| -1 \| already connect \| 已连接 \|<br/>\| 10000 \| not init \| 未初始化蓝牙适配器 \|<br/>\| 10001 \| not available \| 当前蓝牙适配器不可用 \|<br/>\| 10002 \| no device \| 没有找到指定设备 \|<br/>\| 10003 \| connection fail \| 连接失败 \|<br/>\| 10004 \| no service \| 没有找到指定服务 \|<br/>\| 10005 \| no characteristic \| 没有找到指定特征 \|<br/>\| 10006 \| no connection \| 当前连接已断开 \|<br/>\| 10007 \| property not support \| 当前特征不支持此操作 \|<br/>\| 10008 \| system error \| 其余所有系统上报的异常 \|<br/>\| 10009 \| system not support \| Android 系统特有,系统版本低于 4.3 不支持 BLE \|<br/>\| 10012 \| operate time out \| 连接超时 \|<br/>\| 10013 \| invalid_data \| 连接 deviceId 为空或者是格式不正确 \|<br/> |
723
+
724
+ #### BluetoothFail 的属性值 @bluetoothfail-values
725
+
726
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
727
+ | :- | :- | :- | :-: | :- |
728
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
729
+ | 合法值 | 兼容性 | 描述 |
730
+ | :- | :-: | :- |
731
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
732
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
733
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
734
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
735
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
736
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
737
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
738
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
739
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
740
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
741
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
742
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
743
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
744
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
745
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
746
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
747
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
748
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
749
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
750
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
751
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
752
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
753
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
754
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
755
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
756
+
757
+ ### 参见
758
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.readBLECharacteristicValue)
759
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.readBLECharacteristicValue.html)
760
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=readBLECharacteristicValue&pageIndex=1&pageSize=10&source=doc_top&type=all)
761
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=readBLECharacteristicValue&scope=devdocs&source=docs)
762
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=readBLECharacteristicValue&secondType=all&type=1)
763
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=readBLECharacteristicValue&topicFilter=)
764
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=readBLECharacteristicValue)
765
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
766
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=readBLECharacteristicValue&from=docs)
767
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
768
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
769
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
770
+
771
+ ### 注意事项
772
+
773
+ - 先注册 `onBLECharacteristicValueChange`,再发起读取。读取结果通过该事件的 `value` 返回,`readBLECharacteristicValue` 的成功回调不包含特征值数据。
774
+ - 主动读取要求特征值支持 `read`,无需先调用 `notifyBLECharacteristicValueChange` 开启通知。
775
+ - 多设备或多特征值共用事件监听时,应按事件中的 `deviceId`、`serviceId` 和 `characteristicId` 匹配数据来源。
776
+
777
+ ::: sourceCode
778
+ ## uni.writeBLECharacteristicValue(options) @writeblecharacteristicvalue
779
+
780
+ 向蓝牙低功耗设备特征值中写入二进制数据。注意:必须设备的特征支持 write 才可以成功调用。
781
+
782
+ ### writeBLECharacteristicValue 兼容性
783
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
784
+ | :- | :- | :- | :- | :- | :- | :- |
785
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
786
+
787
+ ### 参数
788
+
789
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
790
+ | :- | :- | :- | :-: | :- |
791
+ | options | **WriteBLECharacteristicValueOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
792
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
793
+ | :- | :- | :- | :-: | :- |
794
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
795
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征对应服务的 UUID,需要先调用 getBLEDeviceServices 获取。 |
796
+ | characteristicId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征的 UUID,需要先调用 getBLEDeviceCharacteristics 获取。 |
797
+ | value | ArrayBuffer | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备特征对应的二进制值。 |
798
+ | writeType | string | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征值写模式。可选值为 write、writeNoResponse;不传时 iOS 优先 write,Android 优先 writeNoResponse。 |
799
+ @@| 合法值 | 兼容性 | 描述 |
800
+ @@| :- | :-: | :- |
801
+ @@| "write" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 强制回复写,不支持时报错 |
802
+ @@| "writeNoResponse" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 强制无回复写,不支持时报错 |
803
+ | success | (result: [BLEOperationSuccess](#bleoperationsuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
804
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
805
+ | complete | (result: [BLEOperationSuccess](#bleoperationsuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
806
+
807
+ #### BLEOperationSuccess 的属性值 @bleoperationsuccess-values
808
+
809
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
810
+ | :- | :- | :- | :-: | :- |
811
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
812
+ | errCode | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误码<br/><br/>\| 错误码 \| 错误信息 \| 说明 \|<br/>\| - \| - \| - \|<br/>\| 0 \| ok \| 正常 \|<br/>\| -1 \| already connect \| 已连接 \|<br/>\| 10000 \| not init \| 未初始化蓝牙适配器 \|<br/>\| 10001 \| not available \| 当前蓝牙适配器不可用 \|<br/>\| 10002 \| no device \| 没有找到指定设备 \|<br/>\| 10003 \| connection fail \| 连接失败 \|<br/>\| 10004 \| no service \| 没有找到指定服务 \|<br/>\| 10005 \| no characteristic \| 没有找到指定特征 \|<br/>\| 10006 \| no connection \| 当前连接已断开 \|<br/>\| 10007 \| property not support \| 当前特征不支持此操作 \|<br/>\| 10008 \| system error \| 其余所有系统上报的异常 \|<br/>\| 10009 \| system not support \| Android 系统特有,系统版本低于 4.3 不支持 BLE \|<br/>\| 10012 \| operate time out \| 连接超时 \|<br/>\| 10013 \| invalid_data \| 连接 deviceId 为空或者是格式不正确 \|<br/> |
813
+
814
+ #### BluetoothFail 的属性值 @bluetoothfail-values
815
+
816
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
817
+ | :- | :- | :- | :-: | :- |
818
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
819
+ | 合法值 | 兼容性 | 描述 |
820
+ | :- | :-: | :- |
821
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
822
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
823
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
824
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
825
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
826
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
827
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
828
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
829
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
830
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
831
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
832
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
833
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
834
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
835
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
836
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
837
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
838
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
839
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
840
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
841
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
842
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
843
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
844
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
845
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
846
+
847
+ ### 参见
848
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.writeBLECharacteristicValue)
849
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.writeBLECharacteristicValue.html)
850
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=writeBLECharacteristicValue&pageIndex=1&pageSize=10&source=doc_top&type=all)
851
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=writeBLECharacteristicValue&scope=devdocs&source=docs)
852
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=writeBLECharacteristicValue&secondType=all&type=1)
853
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=writeBLECharacteristicValue&topicFilter=)
854
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=writeBLECharacteristicValue)
855
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
856
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=writeBLECharacteristicValue&from=docs)
857
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
858
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
859
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
860
+
861
+ ### 注意事项
862
+
863
+ - 应根据特征值属性选择 `writeType`:`write` 为有响应写,`writeNoResponse` 为无响应写。当前 iOS 插件不传时使用 `write`,不会因特征值只支持无响应写而自动切换;此时需显式传入 `writeNoResponse`。
864
+ - 当前 iOS 插件不会自动分包。超过单次写入长度上限时,会调用 `fail` 和 `complete`,需按长度上限与设备协议自行分包,详见 [getBLEMTU 的 iOS 注意事项](#getblemtu)。
865
+ - 无响应写缺少外设对本次写入的协议层确认。若业务需要确认设备已接收或处理数据,应设计应用层应答机制。
866
+
867
+ ::: sourceCode
868
+ ## uni.notifyBLECharacteristicValueChange(options) @notifyblecharacteristicvaluechange
869
+
870
+ 启用蓝牙低功耗设备特征值变化时的 notify 功能,订阅特征。注意:必须设备的特征支持 notify 或者 indicate 才可以成功调用。另外,必须先启用 uni.notifyBLECharacteristicValueChange 才能监听到设备 characteristicValueChange 事件。
871
+
872
+ ### notifyBLECharacteristicValueChange 兼容性
873
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
874
+ | :- | :- | :- | :- | :- | :- | :- |
875
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
876
+
877
+ ### 参数
878
+
879
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
880
+ | :- | :- | :- | :-: | :- |
881
+ | options | **NotifyBLECharacteristicValueChangeOptions** | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
882
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
883
+ | :- | :- | :- | :-: | :- |
884
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID,需要已经通过 createBLEConnection 建立连接。 |
885
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征对应服务的 UUID,需要先调用 getBLEDeviceServices 获取。 |
886
+ | characteristicId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征的 UUID,需要先调用 getBLEDeviceCharacteristics 获取。 |
887
+ | state | boolean | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 是否启用特征值变化通知。 |
888
+ | type | string | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 特征订阅类型,可选值为 notification、indication,默认值为 indication。 |
889
+ @@| 合法值 | 兼容性 | 描述 |
890
+ @@| :- | :-: | :- |
891
+ @@| "notification" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 订阅类型 notification |
892
+ @@| "indication" | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 订阅类型 indication |
893
+ | success | (result: [BLEOperationSuccess](#bleoperationsuccess-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用成功的回调函数。 |
894
+ | fail | (result: [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用失败的回调函数。 |
895
+ | complete | (result: [BLEOperationSuccess](#bleoperationsuccess-values) \| [BluetoothFail](#bluetoothfail-values)) => void | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 接口调用结束的回调函数,调用成功、失败都会执行。 |
896
+
897
+ #### BLEOperationSuccess 的属性值 @bleoperationsuccess-values
898
+
899
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
900
+ | :- | :- | :- | :-: | :- |
901
+ | errMsg | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用结果信息。 |
902
+ | errCode | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误码<br/><br/>\| 错误码 \| 错误信息 \| 说明 \|<br/>\| - \| - \| - \|<br/>\| 0 \| ok \| 正常 \|<br/>\| -1 \| already connect \| 已连接 \|<br/>\| 10000 \| not init \| 未初始化蓝牙适配器 \|<br/>\| 10001 \| not available \| 当前蓝牙适配器不可用 \|<br/>\| 10002 \| no device \| 没有找到指定设备 \|<br/>\| 10003 \| connection fail \| 连接失败 \|<br/>\| 10004 \| no service \| 没有找到指定服务 \|<br/>\| 10005 \| no characteristic \| 没有找到指定特征 \|<br/>\| 10006 \| no connection \| 当前连接已断开 \|<br/>\| 10007 \| property not support \| 当前特征不支持此操作 \|<br/>\| 10008 \| system error \| 其余所有系统上报的异常 \|<br/>\| 10009 \| system not support \| Android 系统特有,系统版本低于 4.3 不支持 BLE \|<br/>\| 10012 \| operate time out \| 连接超时 \|<br/>\| 10013 \| invalid_data \| 连接 deviceId 为空或者是格式不正确 \|<br/> |
903
+
904
+ #### BluetoothFail 的属性值 @bluetoothfail-values
905
+
906
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
907
+ | :- | :- | :- | :-: | :- |
908
+ | errCode | number | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | uni 蓝牙适配器和 BLE 中心设备 API 可能返回的统一错误码。 |
909
+ | 合法值 | 兼容性 | 描述 |
910
+ | :- | :-: | :- |
911
+ | 1500101 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙适配器尚未初始化或运行时未就绪。 |
912
+ | 1500102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前蓝牙适配器不可用(如重置中/状态未知)。 |
913
+ | 1500103 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Service。 |
914
+ | 1500104 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 调用系统蓝牙能力失败,具体原因见 cause。 |
915
+ | 1500105 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前平台或系统不支持该 BLE 能力或操作。 |
916
+ | 1509000 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未知或无法归类的 BLE 错误,具体原因见 cause。 |
917
+ | 1509001 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接 BLE 设备失败。 |
918
+ | 1509002 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到对应的 Characteristic。 |
919
+ | 1509003 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未连接上该 BLE 设备。 |
920
+ | 1509004 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前特征不支持此操作(属性不匹配)。 |
921
+ | 1509005 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE 操作超时。 |
922
+ | 1509006 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未找到该设备,可能尚未扫描到或已移除。 |
923
+ | 1509007 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备已经连接。 |
924
+ | 1509008 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | Android 扫描需位置权限(未授予)。 |
925
+ | 1509010 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | iOS 等待蓝牙状态更新超时。 |
926
+ | 1509601 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | BLE API 参数无效。 |
927
+ | 1509602 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 未获得系统蓝牙权限。 |
928
+ | 1509603 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 系统蓝牙已关闭。 |
929
+ | 1509604 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 当前 BLE 设备仅可被扫描,不接受中心设备连接。 |
930
+ | 1510102 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 连接/设备数已达上限。 |
931
+ | mtu | number | 否 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 最终协商的 MTU 值。如果协商失败则无此参数。安卓客户端 8.0.9 开始支持。<br/> |
932
+ | errSubject | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 统一错误主题(模块)名称 |
933
+ | data | any | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | 错误信息中包含的数据 |
934
+ | cause | Error | 否 | | 源错误信息,可以包含多个错误,详见SourceError |
935
+ | errMsg | string | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | |
936
+
937
+ ### 参见
938
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.notifyBLECharacteristicValueChange)
939
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.notifyBLECharacteristicValueChange.html)
940
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=notifyBLECharacteristicValueChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
941
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=notifyBLECharacteristicValueChange&scope=devdocs&source=docs)
942
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=notifyBLECharacteristicValueChange&secondType=all&type=1)
943
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=notifyBLECharacteristicValueChange&topicFilter=)
944
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=notifyBLECharacteristicValueChange)
945
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
946
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=notifyBLECharacteristicValueChange&from=docs)
947
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
948
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
949
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
950
+
951
+ ### 注意事项
952
+
953
+ - 先注册 `onBLECharacteristicValueChange`,再传入 `state: true` 开启通知;特征值需支持 `notify` 或 `indicate`。
954
+ - 开启成功表示通知配置完成,不代表外设会立即发送数据;是否上报、何时上报由设备协议决定。
955
+ - 不再需要通知时传入 `state: false`。断线重连后如需继续接收通知,应重新发现服务和特征值并再次开启通知。
956
+
957
+ ::: sourceCode
958
+ ## uni.onBLECharacteristicValueChange(listener) @onblecharacteristicvaluechange
959
+
960
+ 监听蓝牙低功耗设备的特征值变化事件。必须先调用 uni.notifyBLECharacteristicValueChange 接口才能接收到设备推送的 notification。
961
+
962
+ ### onBLECharacteristicValueChange 兼容性
963
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
964
+ | :- | :- | :- | :- | :- | :- | :- |
965
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
966
+
967
+ ### 参数
968
+
969
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
970
+ | :- | :- | :- | :-: | :- |
971
+ | listener | (result: [BLECharacteristicValueChangeResult](#blecharacteristicvaluechangeresult-values)) => void | 是 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
972
+
973
+ ### BLECharacteristicValueChangeResult 的属性值 @blecharacteristicvaluechangeresult-values
974
+
975
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
976
+ | :- | :- | :- | :-: | :- |
977
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
978
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征对应服务的 UUID。 |
979
+ | characteristicId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征的 UUID。 |
980
+ | value | ArrayBuffer | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 特征最新的二进制值。 |
981
+
982
+ ### 返回值
983
+
984
+ | 类型 |
985
+ | :- |
986
+ | number |
987
+
988
+ ### 参见
989
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.onBLECharacteristicValueChange)
990
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.onBLECharacteristicValueChange.html)
991
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=onBLECharacteristicValueChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
992
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=onBLECharacteristicValueChange&scope=devdocs&source=docs)
993
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=onBLECharacteristicValueChange&secondType=all&type=1)
994
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=onBLECharacteristicValueChange&topicFilter=)
995
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=onBLECharacteristicValueChange)
996
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
997
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=onBLECharacteristicValueChange&from=docs)
998
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
999
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
1000
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
1001
+
1002
+ ::: sourceCode
1003
+ ## uni.offBLECharacteristicValueChange(listener?) @offblecharacteristicvaluechange
1004
+
1005
+ 移除 BLE 特征值变化监听。传 ID 删除对应监听,否则清空全部监听。
1006
+
1007
+ ### offBLECharacteristicValueChange 兼容性
1008
+ | Web | 微信小程序 | 支付宝小程序 | Android | iOS(VDOM) | iOS(Vapor) | HarmonyOS |
1009
+ | :- | :- | :- | :- | :- | :- | :- |
1010
+ | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 4.41 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> | 5.34 | <a style="color:unset;" href="https://vote.dcloud.net.cn/#/?name=uni-app%20x">x</a> |
1011
+
1012
+ ### 参数
1013
+
1014
+ | 名称 | 类型 | 必填 | 兼容性 | 描述 |
1015
+ | :- | :- | :- | :-: | :- |
1016
+ | listener | number \| (result: **BLECharacteristicValueChangeResult**) => void | 否 | Web x / 支付宝小程序 x / Android x / HarmonyOS x(部分支持,见上) | * |
1017
+ | 名称 | 类型 | 必备 | 兼容性 | 描述 |
1018
+ | :- | :- | :- | :-: | :- |
1019
+ | deviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙设备 ID。 |
1020
+ | serviceId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征对应服务的 UUID。 |
1021
+ | characteristicId | string | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 蓝牙特征的 UUID。 |
1022
+ | value | ArrayBuffer | 是 | Web x / 微信小程序 4.41 / 支付宝小程序 x / Android x / iOS(VDOM) x / iOS(Vapor) 5.34 / HarmonyOS x(部分支持,见上) | 特征最新的二进制值。 |
1023
+
1024
+ ### 参见
1025
+ - [相关 Bug](https://issues.dcloud.net.cn/?mid=api.device.ble.offBLECharacteristicValueChange)
1026
+ - [微信小程序文档](https://developers.weixin.qq.com/miniprogram/dev/api/device/bluetooth-ble/wx.offBLECharacteristicValueChange.html)
1027
+ - [支付宝小程序文档](https://open.alipay.com/portal/zhichi/search?keyword=offBLECharacteristicValueChange&pageIndex=1&pageSize=10&source=doc_top&type=all)
1028
+ - [百度小程序文档](https://smartprogram.baidu.com/forum/search?query=offBLECharacteristicValueChange&scope=devdocs&source=docs)
1029
+ - [抖音小程序文档](https://developer.open-douyin.com/search-page?keyword=offBLECharacteristicValueChange&secondType=all&type=1)
1030
+ - [飞书小程序文档](https://open.feishu.cn/search?from=header&page=1&pageSize=10&q=offBLECharacteristicValueChange&topicFilter=)
1031
+ - [钉钉小程序文档](https://open.dingtalk.com/search?keyword=offBLECharacteristicValueChange)
1032
+ - [QQ小程序文档](https://q.qq.com/wiki/develop/miniprogram/frame/)
1033
+ - [快手小程序文档](https://developers.kuaishou.com/page?keyword=offBLECharacteristicValueChange&from=docs)
1034
+ - [京东小程序文档](https://mp-docs.jd.com/doc/dev/framework/-1)
1035
+ - [华为快应用文档](https://developer.huawei.com/consumer/cn/doc/quickApp-References/webview-frame-overview-0000001124793625)
1036
+ - [360小程序文档](https://mp.360.cn/doc/miniprogram/dev/#/b770a184ff1f06c6b3393a0fd1132380)
1037
+
1038
+ ## 通用类型
1039
+
1040
+ ### GeneralCallbackResult @generalcallbackresult-values
1041
+
1042
+ | 名称 | 类型 | 必备 | 描述 |
1043
+ | :- | :- | :- | :- |
1044
+ | errMsg | string | 是 | 错误信息 |