Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Bluetooth about notify setting
Started by royshen Mar 06 2019 10:50 PM

No replies to this topic
android bluetooth notify
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

royshen

[GLOBAL: userInfoPane.html]
royshen
  • Observer

  • 3 posts
  • Corona SDK

Hi,

    I am currently using the Bluetooth plugin.

https://marketplace.coronalabs.com/corona-plugins/bluetooth

 

I have some questions about the characteristic notify settings.

Notify setting should add descriptor(0x2902) to the characteristic.
 
I have been test this code successfully on android studio, and it can work notify function.

Here is my part of android studio code
if (mConnected) {
  // Enable local notifications
  characteristic = mBluetoothGatt.getService(UUID_USER_SERV).getCharacteristic(UUID_USER_DATA);
  mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
  // Enabled remote notifications
  descriptor = characteristic.getDescriptor(CLIENT_CONFIG_DESCRIPTOR);
  descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
  mBluetoothGatt.writeDescriptor(descriptor);
}

 
Here is my part of corona code
 
if event.name == 'onServicesDiscovered' and not event.isError then
local services = event.gatt:getServices()
for i = 1, #services do
 
if services[i].uuid == SERVICE_UUID then
BLE.TargetService = services[i]
print("Service Find!!!!!!!!!!!")
end
local characteristics = services[i]:getCharacteristics()
for j = 1, #characteristics do
 
if characteristics[j].uuid == CHARACTERISTIC_UUID_SETTING then
BLE.SettingCharacteristic = characteristics[j]
print("Setting characteristic Find!!!!!!!!!!")
elseif characteristics[j].uuid == CHARACTERISTIC_UUID_NOTIFY then
BLE.NotifyCharacteristic = characteristics[j]
BLE.TargetGatt:setCharacteristicNotification(BLE.NotifyCharacteristic, true)
BLE.descriptor = BLE.NotifyCharacteristic:getDescriptor( CLIENT_CONFIG_DESCRIPTOR )
 
-- Here!!!! How do I set this place?
BLE.descriptor:setValue()
 
BLE.TargetGatt:writeDescriptor(BLE.descriptor);
print("Notify characteristic Find!!!!!!!!!!")
end
end
end
 
How to write correctly about the descriptor:setValue() ?
 
Thank you



[topic_controls]
[/topic_controls]

Also tagged with one or more of these keywords: android, bluetooth, notify