国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符

這篇具有很好參考價值的文章主要介紹了Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

前言

??上一篇中了解了特性和屬性,同時顯示設(shè)備藍(lán)牙服務(wù)下的特性和屬性,本文中就需要來使用這些特性和屬性來完成一些功能。

目錄

  • Ble藍(lán)牙App(一)掃描
  • Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù)
  • Ble藍(lán)牙App(三)特性和屬性
  • Ble藍(lán)牙App(四)UI優(yōu)化和描述符
  • Ble藍(lán)牙App(五)數(shù)據(jù)操作

正文

??在進(jìn)行具體的功能開發(fā)之前,對于UI的優(yōu)化也是必不可少的,就拿主頁面來說,目前是比較奇怪的,如果你是第一次使用這個App的話,可能就會很疑惑,要怎么使用?基于這個點我們增加一個布局,優(yōu)化以下主頁面的提示。

一、UI優(yōu)化

① 主頁面提示優(yōu)化

??首先在layout下新建一個lay_empty_ble.xml,里面的代碼如下所示:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical"
    tools:ignore="UseCompoundDrawables">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="100dp"
        android:layout_height="100dp"
        app:srcCompat="@drawable/ic_empty_ble" />

    <TextView
        android:id="@+id/textView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:padding="24dp"
        android:text="暫無藍(lán)牙設(shè)備,請點擊頁面左上角藍(lán)牙圖標(biāo)按鈕,進(jìn)入掃描頁面,選擇設(shè)備連接后進(jìn)行操作"
        android:textColor="@color/gray"
        android:textSize="16sp" />
</LinearLayout>

這里使用到了一個圖標(biāo),ic_empty_ble.xml,代碼如下所示:

<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:width="100dp"
    android:height="100dp"
    android:viewportWidth="1024"
    android:viewportHeight="1024">
    <path
        android:fillColor="#e6e6e6"
        android:pathData="M997.9,516.6a488.4,488.4 0,0 1,-489.5 488.2,488.4 488.4,0 0,1 -489.5,-490.8C19.9,242.3 240.1,23.8 511,25.8a488.4,488.4 0,0 1,486.9 490.8zM534.7,726l99.2,-74.9 -99.2,-78.7v153.7zM633.9,379.4l-98.9,-73.2v151.8L633.9,379.4zM561.3,515.2l130.3,-103.6c29.2,-23.3 29.8,-42.8 0.8,-64.7 -54.2,-40.9 -108.3,-81.8 -163.8,-120.9 -10.2,-7.3 -29.4,-12.1 -39.1,-7.3 -9.6,4.9 -17.1,23.1 -17.5,35.7 -1.8,54.8 -0.8,109.7 -0.9,164.6 0,6.7 -1,13.3 -1.9,23.9L339.3,341l-37.4,46.4 160.3,127.8c-40.6,32.3 -79.9,62.5 -118,94.1 -45.2,37.4 -52.4,22.8 -6.9,77.9 0.9,1 2.9,1.1 4.4,1.6l129.5,-101.2c0,69 -0.9,131.3 0.9,193.4 0.3,11.8 8.7,27.9 18.4,33.6 7.8,4.6 25.6,0.3 34.7,-6.2a7693.4,7693.4 0,0 0,167.1 -124.8c29.3,-22.3 28.8,-41.2 -0.7,-64.8 -42.6,-34.2 -85.4,-68.1 -130.2,-103.7z" />
</vector>

然后在activity_main.xml中使用它,修改代碼如下所示:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.material.appbar.MaterialToolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/orange"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navigationIcon="@drawable/ic_scan_ble"
        app:title="GoodBle"
        app:titleCentered="true"
        app:titleTextColor="@color/white">

        <TextView
            android:id="@+id/tv_disconnect"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="end"
            android:layout_marginEnd="8dp"
            android:padding="8dp"
            android:text="斷開連接"
            android:textColor="@color/white"
            android:visibility="gone" />
    </com.google.android.material.appbar.MaterialToolbar>

    <TextView
        android:id="@+id/tv_device_info"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:padding="16dp"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar" />

    <include
        android:id="@+id/empty_ble_lay"
        layout="@layout/lay_empty_ble"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        android:layout_below="@id/toolbar"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/toolbar" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_service"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_device_info" />

</androidx.constraintlayout.widget.ConstraintLayout>

預(yù)覽的效果如下圖所示:
Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符
??服務(wù)列表在沒有數(shù)據(jù)的時候就是空白的,那么下面我們修改MainActivity中的代碼,因為默認(rèn)是顯示的,所以可以在連接藍(lán)牙設(shè)備發(fā)現(xiàn)服務(wù)之后就隱藏這個布局,修改如下圖所示:

Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符

然后就是在斷開連接的回調(diào)時,顯示空內(nèi)容布局,再清空服務(wù)列表,刷新適配器,修改代碼如下所示:

    override fun onConnectionStateChange(state: Boolean) {
        runOnUiThread {
            if (state) binding.tvDisconnect.visibility = View.VISIBLE
            else {
                binding.emptyBleLay.root.visibility = View.VISIBLE
                mServiceList.clear()
                mServiceAdapter?.notifyDataSetChanged()
            }
        }
    }

下面運行一下:

Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符

② UUID顯示優(yōu)化

??這樣看起來主頁面在沒有設(shè)備信息的時候不會顯得單調(diào),那么還有一個小細(xì)節(jié)就是,當(dāng)設(shè)備的藍(lán)牙服務(wù)和特性不屬于SIG定義的,是廠商自定義時,我們最好就顯示完成的UUID,為了方便使用,在ble包下新建一個BleConstant類,代碼如下所示:

object BleConstant {

    const val APP_NAME = "GoodBle"

    const val UNKNOWN_DEVICE = "Unknown device"

    const val UNKNOWN_SERVICE = "Unknown Service"

    const val UNKNOWN_CHARACTERISTICS = "Unknown Characteristics"

    const val UNKNOWN_DESCRIPTOR = "Unknown Descriptor"

    const val BROADCAST = "Broadcast"

    const val READ = "Read"

    const val WRITE_NO_RESPONSE = "Write No Response"

    const val WRITE = "Write"

    const val NOTIFY = "Notify"

    const val INDICATE = "Indicate"

    const val AUTHENTICATED_SIGNED_WRITES = "Authenticated Signed Writes"

    const val EXTENDED_PROPERTIES = "Extended Properties"
}

這里定義了一些常量,包括未知服務(wù)、未知特性,和一些其他的屬性,這樣做在修改的時候修改一個常量就可以了。下面我們分別修改一下BleUtils中的getServiceName()getCharacteristicsName()函數(shù)的else的值為常量中的常量名,剩下的就可以在服務(wù)適配器和特性適配器中去修改了,首先是服務(wù)適配器,修改

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val serviceName = BleUtils.getServiceName(services[position].uuid)
        holder.binding.tvServiceName.text = serviceName
        holder.binding.tvServiceUuid.text = if (serviceName != UNKNOWN_SERVICE) BleUtils.getShortUUID(services[position].uuid) else services[position].uuid.toString()
        ...
    }

services[position].uuid.toString()就是服務(wù)完整的uuid,默認(rèn)是小寫的,你也可以改成大寫。

那么同樣特性適配器也改一下:

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val characteristicName = BleUtils.getCharacteristicsName(characteristics[position].uuid)
        holder.binding.tvCharacterName.text = characteristicName
        holder.binding.tvCharacterUuid.text = if (characteristicName != UNKNOWN_CHARACTERISTICS) BleUtils.getShortUUID(characteristics[position].uuid) else characteristics[position].uuid.toString()
        ...
    }

再運行一下,對于未知設(shè)備服務(wù)和特性的UUID就會顯示完成的值。

③ 設(shè)備信息優(yōu)化

??當(dāng)前連接設(shè)備之后我們可以看到設(shè)備的服務(wù)信息,但是卻不知道是那個設(shè)備,沒有一個地方顯示設(shè)備的信息,最重要的當(dāng)然就是設(shè)備的名稱和Mac地址了,這里我們可以優(yōu)化一下,首先修改一下activity_main.xml中的MaterialToolbar控件的內(nèi)容,因為我想把設(shè)備名稱作為標(biāo)題,設(shè)備Mac地址作為子標(biāo)題,所以增加兩個子標(biāo)題的屬性值:

    <com.google.android.material.appbar.MaterialToolbar
        ...
        app:subtitleCentered="true"
        app:subtitleTextColor="@color/white">

這里就分別設(shè)置子標(biāo)題的顯示位置和文字顏色,下面要做的就是獲取設(shè)備,在BleCore中增加一個函數(shù),代碼如下所示:

	fun getDevice() = mGatt?.device

然后回到MainActivity中,只需要修改連接狀態(tài)的回調(diào)函數(shù)中的代碼即可,如下所示:

    @SuppressLint("MissingPermission")
    override fun onConnectionStateChange(state: Boolean) {
        runOnUiThread {
            if (state) {
                binding.tvDisconnect.visibility = View.VISIBLE
                bleCore.getDevice()?.apply {
                    binding.toolbar.title = name ?: UNKNOWN_DEVICE
                    binding.toolbar.subtitle = address
                }
            }
            else {
                binding.toolbar.title = APP_NAME
                binding.toolbar.subtitle = ""
                binding.tvDeviceInfo.text = ""
                binding.emptyBleLay.root.visibility = View.VISIBLE
                mServiceList.clear()
                mServiceAdapter?.notifyDataSetChanged()
            }
        }
    }

下面運行一下看看:
Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符

二、描述

??在上一篇中提到了特性和屬性,特性有那些功能是屬性決定的,那么描述又是做什么的呢?

① 概念

在藍(lán)牙低功耗(BLE)中,Descriptor(描述符)是用于提供有關(guān)特征值的額外信息的數(shù)據(jù)結(jié)構(gòu)。Descriptor 提供了特定特征的更詳細(xì)描述和配置選項。Descriptor 是特征(Characteristics)的子項,用于描述特征的特定屬性或行為。每個特征可以有一個或多個 Descriptor。

以下是一些常見的 BLE Descriptor 類型及其含義:

  1. 聲明 Descriptor:這個 Descriptor 用于描述特征的聲明信息,包括特征的唯一標(biāo)識符、權(quán)限、值的格式和其他標(biāo)志。它提供了特征的基本信息供其他設(shè)備了解。

  2. 用戶描述(User Description)Descriptor:用于提供特征的人類可讀描述信息。這個描述可以是特征的名稱、標(biāo)簽或其他有關(guān)特征的說明性文字。

  3. 配置 Descriptor:用于描述特征的配置選項。這個 Descriptor 可以包含特征的可選設(shè)置,例如采樣率、測量單位或閾值等。

  4. 通知 Descriptor:用于配置特征是否支持通知功能。這個 Descriptor 可以用于使設(shè)備可以接收特征值變化的通知。

  5. 線性區(qū)間 Descriptor:用于描述特征值的線性關(guān)系,例如數(shù)值范圍和步長等。

  6. 客戶端配置 Descriptor:用于允許遠(yuǎn)程設(shè)備(例如中心設(shè)備)訂閱特征值的變化通知,這個很重要。
    這些只是一些常見的 BLE Descriptor 類型和其含義的示例,實際上可以根據(jù)應(yīng)用需求定義自定義的 Descriptor。

    Descriptor 提供了對特征更詳細(xì)的描述和配置,它們可以通過藍(lán)牙協(xié)議進(jìn)行傳輸和訪問。在 BLE 應(yīng)用中,Descriptor 充當(dāng)了配置和元數(shù)據(jù)信息的重要角色,幫助設(shè)備之間準(zhǔn)確地交換和理解數(shù)據(jù)。

那么現(xiàn)在你已經(jīng)了解了描述符的作用了,而我們目前的特性下還沒有描述符的,注意不是每一個特性都有描述符,下面我們就來把描述符寫出來了。首先我們在item_characteristic.xml中增加一個描述的列表控件,代碼如下所示:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:foreground="?attr/selectableItemBackground"
    android:paddingStart="16dp">

    <TextView
        android:id="@+id/tv_character_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="8dp"
        android:text="特性"
        android:textColor="@color/black"
        android:textSize="16sp"
        android:textStyle="bold"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tv_uuid_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UUID:"
        app:layout_constraintStart_toStartOf="@+id/tv_character_name"
        app:layout_constraintTop_toBottomOf="@+id/tv_character_name" />

    <TextView
        android:id="@+id/tv_character_uuid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UUID"
        android:textColor="@color/black"
        app:layout_constraintBottom_toBottomOf="@+id/tv_uuid_title"
        app:layout_constraintStart_toEndOf="@+id/tv_uuid_title"
        app:layout_constraintTop_toTopOf="@+id/tv_uuid_title" />

    <TextView
        android:id="@+id/tv_property_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:text="Properties:"
        app:layout_constraintStart_toStartOf="@+id/tv_character_name"
        app:layout_constraintTop_toBottomOf="@+id/tv_uuid_title" />

    <androidx.recyclerview.widget.RecyclerView
        android:id="@+id/rv_property"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="@+id/tv_property_title"
        app:layout_constraintStart_toEndOf="@+id/tv_property_title"
        app:layout_constraintTop_toTopOf="@+id/tv_property_title" />

    <LinearLayout
        android:id="@+id/lay_descriptors"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginBottom="8dp"
        android:orientation="vertical"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/tv_property_title"
        tools:layout_editor_absoluteX="16dp">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Descriptors:"
            android:textColor="@color/black"
            android:textStyle="bold" />

        <androidx.recyclerview.widget.RecyclerView
            android:id="@+id/rv_descriptor"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

通過預(yù)覽圖得知,實際上就是這一塊內(nèi)容。

Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符

下面我們就可以正式去寫描述符的適配器了。

② 描述適配器

??首先在layout下增加一個item_descriptor.xml,代碼如下所示:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:id="@+id/tv_descriptor_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="描述"
        android:textColor="@color/black"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <TextView
        android:id="@+id/tv_uuid_title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UUID:"
        app:layout_constraintStart_toStartOf="@+id/tv_descriptor_name"
        app:layout_constraintTop_toBottomOf="@+id/tv_descriptor_name" />

    <TextView
        android:id="@+id/tv_descriptor_uuid"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="UUID"
        android:textColor="@color/black"
        app:layout_constraintBottom_toBottomOf="@+id/tv_uuid_title"
        app:layout_constraintStart_toEndOf="@+id/tv_uuid_title"
        app:layout_constraintTop_toTopOf="@+id/tv_uuid_title" />
</androidx.constraintlayout.widget.ConstraintLayout>

然后關(guān)于描述符的名稱,我們可以在BleUtils中寫一個函數(shù),代碼如下所示:

    fun getDescriptorName(uuid: UUID) =
        when ("0x${uuid.toString().substring(4, 8).uppercase(Locale.getDefault())}") {
            "0x2900" -> "Characteristic Extended Properties"
            "0x2901" -> "Characteristic User Description"
            "0x2902" -> "Client Characteristic Configuration"
            "0x2903" -> "Server Characteristic Configuration"
            "0x2904" -> "Characteristic Presentation Format"
            "0x2905" -> "Characteristic Aggregate Format"
            "0x2906" -> "Valid Range"
            "0x2907" -> "External Report Reference"
            "0x2908" -> "Report Reference"
            "0x2909" -> "Number of Digitals"
            "0x290A" -> "Value Trigger Setting"
            "0x290B" -> "Environmental Sensing Configuration"
            "0x290C" -> "Environmental Sensing Measurement"
            "0x290D" -> "Environmental Sensing Trigger Setting"
            "0x290E" -> "Time Trigger Setting"
            "0x290F" -> "Complete BR-EDR Transport Block Data"
            "0x2910" -> "Observation Schedule"
            "0x2911" -> "Valid Range and Accuracy"
            else -> BleConstant.UNKNOWN_DESCRIPTOR
        }

下面我們寫描述符適配器,在adapter包下新建一個DescriptorAdapter類,代碼如下所示:

class DescriptorAdapter(
    private val descriptors: List<BluetoothGattDescriptor>
) : RecyclerView.Adapter<DescriptorAdapter.ViewHolder>() {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        return ViewHolder(ItemDescriptorBinding.inflate(LayoutInflater.from(parent.context), parent, false))
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val descriptorName = BleUtils.getDescriptorName(descriptors[position].uuid)
        holder.binding.tvDescriptorName.text = descriptorName
        holder.binding.tvDescriptorUuid.text = if (descriptorName != BleConstant.UNKNOWN_DESCRIPTOR) BleUtils.getShortUUID(descriptors[position].uuid) else descriptors[position].uuid.toString()
    }

    override fun getItemCount() = descriptors.size

    class ViewHolder(itemView: ItemDescriptorBinding) : RecyclerView.ViewHolder(itemView.root) {
        var binding: ItemDescriptorBinding

        init {
            binding = itemView
        }
    }
}

這里的代碼同樣對于自定義UUID展示完整數(shù)據(jù),對于SIG的展示短UUID。

③ 顯示描述符

接下來就是在特性適配器中去加載顯示描述符數(shù)據(jù),修改CharacteristicAdapter中的onBindViewHolder()函數(shù),在里面增加如下所示代碼:

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        ...
        //加載特性下的描述
        if (characteristics[position].descriptors.isEmpty()) {
            holder.binding.layDescriptors.visibility = View.GONE
            return
        }
        holder.binding.rvDescriptor.apply {
            layoutManager = LinearLayoutManager(context)
            adapter = DescriptorAdapter(characteristics[position].descriptors)
        }
    }

這里的isEmpty()函數(shù)很重要,因為不是每一個特性都有描述符,這個前面已經(jīng)說過了,沒有的我們就直接隱藏對應(yīng)的描述符布局,否則就加載描述符數(shù)據(jù),下面運行看一下。

Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符,藍(lán)牙,Android 低功耗,BLE 描述符

通過這個圖就可以清晰的的看到特性下的描述符,本文就到這里了。

三、源碼

如果對你有所幫助的話,不妨 StarFork,山高水長,后會有期~

源碼地址:GoodBle文章來源地址http://www.zghlxwxcb.cn/news/detail-648656.html

到了這里,關(guān)于Android Ble藍(lán)牙App(四)UI優(yōu)化和描述符的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • Android Ble藍(lán)牙App(三)特性和屬性

    Android Ble藍(lán)牙App(三)特性和屬性

    ??在上一篇中我們完成了連接和發(fā)現(xiàn)服務(wù)兩個動作,那么再發(fā)現(xiàn)服務(wù)之后要做什么呢?發(fā)現(xiàn)服務(wù)只是讓你知道設(shè)備有什么服務(wù),可以做什么事情。 Ble藍(lán)牙App(一)掃描 Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù) Ble藍(lán)牙App(三)特性和屬性 Ble藍(lán)牙App(四)UI優(yōu)化和描述符 Ble藍(lán)牙App(五

    2024年02月14日
    瀏覽(22)
  • Android Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù)

    Android Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù)

    ??在上一篇中我們進(jìn)行掃描設(shè)備的處理,本文中進(jìn)行連接和發(fā)現(xiàn)服務(wù)的數(shù)據(jù)處理,運行效果圖如下所示: Ble藍(lán)牙App(一)掃描 Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù) Ble藍(lán)牙App(三)特性和屬性 Ble藍(lán)牙App(四)UI優(yōu)化和描述符 Ble藍(lán)牙App(五)數(shù)據(jù)操作 ??現(xiàn)在我們從MainActivity進(jìn)

    2024年01月16日
    瀏覽(26)
  • 低功耗藍(lán)牙(BLE)你入門了嗎

    低功耗藍(lán)牙(BLE)你入門了嗎

    ????????藍(lán)牙低功耗(Bluetooth Low Energy,或稱Bluetooth LE、BLE,舊商標(biāo)Bluetooth Smart),用于醫(yī)療保健、運動健身、安防、工業(yè)控制、家庭娛樂等領(lǐng)域。在如今的物聯(lián)網(wǎng)時代下大放異彩,扮演者重要一環(huán),是無線通信的主流技術(shù)之一(常見的無線通信技術(shù)有NFC、GPRS、Zigbee、Wi

    2024年02月02日
    瀏覽(33)
  • Android Ble藍(lán)牙App(六)請求MTU與顯示設(shè)備信息

    Android Ble藍(lán)牙App(六)請求MTU與顯示設(shè)備信息

    ??在上一篇文章中已經(jīng)了解了數(shù)據(jù)操作的方式,而數(shù)據(jù)交互的字節(jié)長度取決于我們手機(jī)與藍(lán)牙設(shè)備的最大支持長度。 Ble藍(lán)牙App(一)掃描 Ble藍(lán)牙App(二)連接與發(fā)現(xiàn)服務(wù) Ble藍(lán)牙App(三)特性和屬性 Ble藍(lán)牙App(四)UI優(yōu)化和描述符 Ble藍(lán)牙App(五)數(shù)據(jù)操作 Ble藍(lán)牙App(六)

    2024年02月04日
    瀏覽(25)
  • 微信小程序低功耗藍(lán)牙BLE快速開發(fā)js

    微信小程序低功耗藍(lán)牙BLE快速開發(fā)js

    目的: 1、為了能三分鐘快速開發(fā)BLE模塊,特此做一個筆記,按照筆記的順序開發(fā),能夠簡單、快速、規(guī)范。 2、如果以后覺得有必要改動的地方就在這里更改。 3、主要是記錄BLE連接的步驟。 https://note.youdao.com/ynoteshare/index.html?id=d662c9c1c58121ec28901d78d9aa5e80 比較完整的微信小程

    2024年02月10日
    瀏覽(109)
  • windows+python+bleak+BLE低功耗藍(lán)牙通訊連接

    windows+python+bleak+BLE低功耗藍(lán)牙通訊連接

    1.為什么選bleak ??參考這篇知乎:https://zhuanlan.zhihu.com/p/577687336 ??windows端使用python連接常規(guī)的BLE設(shè)備(藍(lán)牙4.0),僅考慮bleak模塊(排除pybluez、pybluez2、pygatt)。 2.本文主要參考 ??本文主要參考bleak的官方文檔:https://github.com/hbldh/bleak 3.本文所用設(shè)備 ??應(yīng)事先學(xué)習(xí)藍(lán)

    2024年02月02日
    瀏覽(22)
  • 深入淺出藍(lán)牙低功耗音頻BLE Audio--4-3 CIS

    深入淺出藍(lán)牙低功耗音頻BLE Audio--4-3 CIS

    ????????為了掌握核心規(guī)范中ISO新特性,先介紹單播且可連接的ISO流,即CIS,CIS的結(jié)構(gòu)框架相當(dāng)復(fù)雜,但是其建立在一些非常的原則之上。本節(jié)首先描述CIS如何被設(shè)計,解釋組成模塊如何配合工作,然后學(xué)習(xí)廣播模式的不同之處,為學(xué)習(xí)藍(lán)牙低功耗音頻方案奠定基礎(chǔ)。 ?

    2023年04月14日
    瀏覽(30)
  • 深入淺出藍(lán)牙低功耗音頻BLE Audio --4-2 ISO流和角色

    深入淺出藍(lán)牙低功耗音頻BLE Audio --4-2 ISO流和角色

    核心規(guī)范V5.2中增加ISO流特性是低功耗藍(lán)牙協(xié)議中一個全新的概念。熟悉A2DP和HFP協(xié)議的讀者都知道其拓?fù)浣Y(jié)構(gòu)局限不靈活。HFP具有雙向一對一的鏈路,典型場景是電話和耳機(jī)或免提設(shè)備之間。A2DP是一個更簡單的單播鏈路,定義Source設(shè)備產(chǎn)生音頻數(shù)據(jù),Sink設(shè)備通常是耳機(jī),揚聲

    2023年04月11日
    瀏覽(111)
  • Qt筆記---使用Qt開發(fā)低功耗藍(lán)牙BLE(Bluetooth low energy)程序

    Qt筆記---使用Qt開發(fā)低功耗藍(lán)牙BLE(Bluetooth low energy)程序

    在Qt項目中開發(fā)BLE通信程序,即低功耗藍(lán)牙設(shè)備通信,關(guān)于藍(lán)牙設(shè)備的通信分為普通藍(lán)牙設(shè)備和低功耗藍(lán)牙設(shè)備,此文只介紹低功耗藍(lán)牙設(shè)備的連接通信方式。 開發(fā)環(huán)境: 系統(tǒng):win10 Qt:5.15.2 MSVC:2019 注:使用此版本之前使用過其他低版本的Qt和MSVC,會出現(xiàn)搜索不到設(shè)備以及

    2024年04月16日
    瀏覽(183)
  • Android藍(lán)牙BLE開發(fā)

    Android藍(lán)牙BLE開發(fā)

    最近正在研究Android的藍(lán)牙BLE開發(fā)學(xué)習(xí),以下是自己做的個人總結(jié) 首先得說明什么是低功耗藍(lán)牙BLE,BLE的全稱為Bluetooth low energy(或稱Blooth LE,BLE),從英文全稱便可以知曉其是一種低功耗的藍(lán)牙技術(shù),是藍(lán)牙技術(shù)聯(lián)盟設(shè)計和銷售的一種個人局域網(wǎng)技術(shù),旨在用于醫(yī)療保健、運

    2023年04月09日
    瀏覽(38)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包