You are here: Lua Scripting Resources eGuide > Lua Scripting API Reference Guide > Bluetooth® Smart Library > setValueUpdateListener

20.5.2 setValueUpdateListener

characteristic:setValueUpdateListener(callback [, object])

Sets or removes the value-update listener callback for read and notification updates. To remove the callback, use nil as callback parameter. Once the listener callback is called the result can be retrieved via getValue(). This function can be called at any time to update the value update listener callback for a discovered characteristic.

Parameter

Type

Description

callback

in function

The callback is called once the characteristic value is ready to be retrieved via the getValue() function

object

in any (optional)

If a callback is provided, optionally an object can be specified which will be passed as the first parameter to the specified callback function. The object can be of any type except nil.

Callback Function

callback([object,] characteristic [, error])

The callback function informs when the characteristic value is ready to be retrieved via the getValue() function. The callback should not be used to initiate another read for the same characteristic.

Parameter

Type

Description

object

in any (optional)

If an object was provided as a parameter to the function setValueUpdateListener, it will be passed as the first parameter to this callback function

characteristic

in characteristic object

The characteristic for which the value can be read

error

in string (optional) )

If successful the parameter will be nil, an error message otherwise

Introduced in platform.apiLevel = '2.5'