Bluetooth Plugin

This plugin allows you search, connect, send, and communicate with bluetooth devices.

Platforms:

this plugin only works on android and iOS (not simulator)

Limitations:

You have to ask for location on android 6.0+

Functions:

bt.init(listener)

-- handles all events

  • event.type==
    "discovery finished"
    -- returned when .search() is complete
  • event.type==
    "device found"
    -- device found on .search()
    • event.deviceName --(string) name of device found
    • event.deviceID --(string) mac address on android and UDID on iOS
    • event.deviceState --(string) state of device: "connected", "connecting", or "not connected"
  • event.type==
    "device paired"
    -- device paired with .connect()
    • event.deviceName --(string) name of device found
    • event.deviceID --(string) mac address on android and UDID on iOS
    • event.deviceState --(string) state of device: "connected", "connecting", or "not connected"
  • event.type==
    "device unpaired"
    • event.deviceName --(string) name of device found
    • event.deviceID --(string) mac address on android and UDID on iOS
    • event.deviceState --(string) state of device: "connected", "connecting", or "not connected"
  • event.type==
    "error"
    • event.error --(string) error message
  • event.type==
    "connected"
    -- connected to device
    • event.deviceName --(string) name of device found
    • event.deviceID --(string) mac address on android and UDID on iOS
    • event.deviceState --(string) state of device: "connected", "connecting", or "not connected"
  • event.type==
    "message"
    -- message received
    • event.message --(string) message received
  • event.type==
    "connection error"
    • event.deviceName --(string) name of device found
    • event.deviceID --(string) mac address on android and UDID on iOS
    • event.deviceState --(string) state of device: "connected", "connecting", or "not connected"
    • event.error --(string) error message

bt.isEnabled()

-- returns boolean, if true bluetooth is enabled

bt.search()

-- search for bluetooth devices

bt.send(message, deviceID)

-- send message to devices (deviceID is only supported on iOS)

bt.enable(enabled)

-- enable bluetooth (android only)

enabled(boolean) if true bluetooth will be enabled, if false bluetooth will be disabled

bt.connect(deviceID)

-- connect with with deviceID(string)

bt.disconnect(deviceID)

-- disconnect from device with deviceID(string)

bt.getDevices()

-- get configured devices, returns array with data in each table (only works on Android)

  • event.deviceName --(string) name of device found
  • event.deviceID --(string) mac address on android and UDID on iOS
  • event.deviceState --(string) returns "connected"

Build Settings:

Helpful Links:

Example

Support

Get Plugin