我一直在使用带有传感器标签 cc2650stk 的react-native-ble-plx进行工作,并且在获取加速度计和陀螺仪数据时遇到问题。
.section __TEXT,__text,regular,pure_instructions
.build_version macos, 10, 14
.globl _foo ## -- Begin function foo
.p2align 4, 0x90
_foo: ## @foo
Lfunc_begin0:
.file 1 "me.c"
.loc 1 3 0 ## me.c:3:0
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $160, %rsp
leaq -272(%rbp), %rax
movl %edi, -4(%rbp)
movl %esi, -8(%rbp)
movl %edx, -12(%rbp)
Ltmp0:
##DEBUG_VALUE: foo:buff <- [%rax+0]
.loc 1 7 19 prologue_end ## me.c:7:19
addq $256, %rax ## imm = 0x100
Ltmp1:
.loc 1 7 25 is_stmt 0 ## me.c:7:25
addq $8, %rax
.loc 1 7 12 ## me.c:7:12
movq %rax, -280(%rbp)
.loc 1 8 10 is_stmt 1 ## me.c:8:10
movq -280(%rbp), %rax
.loc 1 8 15 is_stmt 0 ## me.c:8:15
movq (%rax), %rcx
addq $5, %rcx
movq %rcx, (%rax)
.loc 1 9 5 is_stmt 1 ## me.c:9:5
addq $160, %rsp
popq %rbp
retq
Ltmp2:
Lfunc_end0:
.cfi_endproc
## -- End function
.globl _main ## -- Begin function main
.p2align 4, 0x90
_main: ## @main
Lfunc_begin1:
.loc 1 11 0 ## me.c:11:0
.cfi_startproc
## %bb.0:
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset %rbp, -16
movq %rsp, %rbp
.cfi_def_cfa_register %rbp
subq $16, %rsp
movl $1, %edi
movl $2, %esi
movl $3, %edx
Ltmp3:
.loc 1 13 9 prologue_end ## me.c:13:9
movb $48, -1(%rbp)
.loc 1 14 7 ## me.c:14:7
callq _foo
leaq L_.str(%rip), %rdi
.loc 1 15 9 ## me.c:15:9
movb $49, -1(%rbp)
.loc 1 16 21 ## me.c:16:21
movsbl -1(%rbp), %esi
.loc 1 16 7 is_stmt 0 ## me.c:16:7
movb $0, %al
callq _printf
xorl %edx, %edx
.loc 1 17 5 is_stmt 1 ## me.c:17:5
movl %eax, -8(%rbp) ## 4-byte Spill
movl %edx, %eax
addq $16, %rsp
popq %rbp
retq
Ltmp4:
Lfunc_end1:
.cfi_endproc
## -- End function
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "%c\n"
.section __DWARF,__debug_str,regular,debug
对于ticc2650传感器标签的所有其他传感器,一切正常。例如湿度,温度,气压计等。
Error: Characteristic "f000aa82-0451-4000-b000-000000000000" write failed for device xxxxxx and service "f000aa80-0451-4000-b000-000000000000"
我的sensortag Movemnet UUIDS是:
constructor() {
super();
this.manager = new BleManager()
this.state = {info: "", values: {}}
this.prefixUUID = "f000aa"
this.suffixUUID = "-0451-4000-b000-000000000000"
this.sensors = {
0: "Temperature",
8: "Accelerometer",
2: "Humidity",
7: "Magnetometer",
4: "Barometer",
// 5: "Gyroscope"
}
}
serviceUUID(num) {
return this.prefixUUID + num + "0" + this.suffixUUID
}
notifyUUID(num) {
return this.prefixUUID + num + "1" + this.suffixUUID
}
writeUUID(num) {
return this.prefixUUID + num + "2" + this.suffixUUID
}
对于其他传感器,但对陀螺仪和加速度计而言,效果很好。
答案 0 :(得分:1)
当我们在十六进制中编写“ AQ ==“ / 0x01”时,其他传感器工作正常/但是对于运动传感器,我们需要在通知功能中为“ 0x01”添加“ MDE =”
const characteristic = await device.writeCharacteristicWithResponseForService(
service, characteristicW, "AQ==" /* 0x01 in hex */
)
我不知道他们为什么这样做,但这为我解决了这个问题。