characteristics

该模块提供在服务中使用的核心 BLE 特征类。

class Characteristic(*, uuid=None, properties=0, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>, max_length=None, fixed_length=False, initial_value=None)

执行基本绑定的顶级特征类。

参数:
BROADCAST

属性:允许在广告包中

INDICATE

属性:服务器将在设置值时向客户端指示并等待响应

NOTIFY

属性:服务器会在设置值时通知客户端

READ

属性:客户端可以读取这个特性

WRITE

属性:客户端可以写这个特性;回复将被发回

WRITE_NO_RESPONSE

属性:客户端可以写这个特性;不会回复任何回复

class ComplexCharacteristic(*, uuid=None, properties=0, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>, max_length=20, fixed_length=False, initial_value=None)

进行复杂绑定的特征类,其中子类返回一个完整的对象以与特征数据进行交互。一旦特性被绑定到相应的实例属性,它就会被隐藏起来。

bind(service)

将特征绑定到给定的本地服务或远程特征对象。

class StructCharacteristic(struct_format, *, uuid=None, properties=0, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>, initial_value=None)

具有固定格式的结构的数据描述符。

参数:

int

该模块提供可直接用作属性的整数特征。

class IntCharacteristic(format_string, min_value, max_value, *, uuid=None, properties=0, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>, initial_value=None)

不同类型整数字段的超类。

class Int8Characteristic(*, min_value=-128, max_value=127, **kwargs)

Int8 number.

class Uint8Characteristic(*, min_value=0, max_value=255, **kwargs)

Uint8 number.

class Int16Characteristic(*, min_value=-32768, max_value=32767, **kwargs)

Int16 number.

class Uint16Characteristic(*, min_value=0, max_value=65535, **kwargs)

Uint16 number.

class Int32Characteristic(*, min_value=-2147483648, max_value=2147483647, **kwargs)

Int32 number.

class Uint32Characteristic(*, min_value=0, max_value=4294967295, **kwargs)

Uint32 number.

stream

该模块提供了将可读或可写对象绑定到它们所在的服务对象的流特性。

class BoundWriteStream(bound_characteristic)

将数据写出到对等方。

write(buf)

将数据从 buf 写出到 peer。

class StreamOut(*, uuid=None, timeout=1.0, buffer_size=64, properties=4, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>)

来自服务服务器的输出流。

bind(service)

将特征绑定到给定的服务。

class StreamIn(*, uuid=None, timeout=1.0, buffer_size=64, properties=48, write_perm=<Attribute.OPEN: 17>)

输入流到服务服务器。

bind(service)

将特征绑定到给定的服务。

string

该模块提供字符串特征。

class StringCharacteristic(*, uuid=None, properties=8, read_perm=<Attribute.OPEN: 17>, write_perm=<Attribute.OPEN: 17>, initial_value=None)

UTF-8 编码的字符串特征。

class FixedStringCharacteristic(*, uuid=None, read_perm=<Attribute.OPEN: 17>)

固定字符串在绑定时设置一次,之后不变。