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

20.5.7 write

error = characteristic:write(data, [isRequest])

Sets the data string attribute as the new characteristic value. Based on the supported write procedure of the device characteristic, the form of a request or a commend might be required or not allowed. If both procedures are supported by the device characteristic, it is an author’s choice which procedure to use. There is currently no function to retrieve the characteristic property and it is therefore the author’s responsibility to either find out the information about the device characteristic or use trial-and-error. A write request – as opposed to a write command – will send back an information about the success, please see subsection 20.5.3.

Parameter

Type

Description

data

in string

Data to be written. Data with zero length is not supported.

isRequest

in boolean

If true a write request will be send otherwise a write command

error

out string (optional)

If successful nil is returned, an error message otherwise

Introduced in platform.apiLevel = '2.5'