Материал из Module developer
Перейти к: навигация, поиск

IR.EVENT_DEVICE_BLE_FOUND

the event: the BLE device is found

Syntax

IR.AddListener(IR.EVENT_DEVICE_BLE_FOUND, 0, function, [pointer]);

input sample description
function function(in_uuid, in_name, in_rssi, in_advertisementData) {} type: function
the unnamed function or reference to the function
pointer - type: object
the pointer to the object which serves the function (optional)
output
in_uuid "550e8400-e29b-41d4-a716-446655440000" type: string
the device identifier: for Android or iOS
in_name "My_BLE_device" type: String
the device name
in_rssi -73 type: Number
the signal strength
in_advertisementData type: Object
advertisement information (at the moment it is not implemented on Android as an object)


Example:

IR.AddListener(IR.EVENT_DEVICE_BLE_FOUND, 0, function(in_uuid, in_name, in_rssi, in_advertisementData){
   IR.Log(in_uuid + " " + in_name + " " + in_rssi + " " + in_advertisementData.LocalName + " " + in_advertisementData.Connectable)
}) // print all callback parameters

The fields of the object in_advertisementData (the OPTIONAL marker means you are not required to fill in the field):

  • LocalName: (String) - The name wired in the advertisement information (it usually duplicates the device name from the scanner);
  • Connectable: (Bool) - The flag of supporting connection to the device
  • ManufacturerData: (Array) - OPTIONAL, the array of bytes containing information from the manufacturer - the protocol is provided by the device manufacturer
  • ServiceData: (Array) - OPTIONAL, the array of services (service - object)
  • TxPowerLevel: (Unsigned) - OPTIONAL, the battery charge
  • ServiceUUIDsKey: (String) - OPTIONAL, the identifier of the device class (coincides with in_uuid from the scanner)