Good evening
I’m using this LERG plugin.
I was able to connect to the bluetooth module and read the feature.
my code:
if event.name == ‘onConnectionStateChange’ then
event.gatt:discoverServices()
end
if event.name == ‘onServicesDiscovered’ and not event.isError then
local services = event.gatt:getServices()
for i = 1, #services do
print(‘Service:’, json.prettify(services[i]))
testo3.text = json.prettify(services[4])
testo1.text = #services
local characteristics = services[4]:getCharacteristics()
for j = 1, #characteristics do
timer.performWithDelay(j * 3000, function()
event.gatt:readCharacteristic(characteristics[j])
end)
end
end
end
if event.name == ‘onCharacteristicRead’ and not event.isError then
testo1.text = event.characteristic:getValue()
end
if event.name == ‘onCharacteristicWrite’ and not event.isError then
event.characteristic:SetValue("")
end
end
bluetooth.connect({
device = device,
autoconnect = true,
onCharacteristicChanged = listener,
onCharacteristicRead = listener,
onCharacteristicWrite = listener,
onConnectionStateChange = listener,
onDescriptorRead = listener,
onDescriptorWrite = listener,
onReadRemoteRssi = listener,
onReliableWriteCompleted = listener,
onServicesDiscovered = listener
})
end}
now the problem I could not write the feature.
I added the event ‘onCharacteristicWrite’ but I never go there.
can someone help me with a small code?
I need to write a string to the module’s characteristic
I really need it for a project to be delivered right away.
Please help me
Thank you all