bluetooth.* — Bluetooth


Type Library


Overview

The Bluetooth plugin enables Bluetooth communication. To get access to the plugin, you need to support me on Patreon https://www.patreon.com/lerg

  • This plugin is currently in beta. APIs and project configuration are subject to change without notice during this time.

  • This plugin is currently only available for Android, but iOS support is in development.

Syntax

local bluetooth = require( "plugin.bluetooth" )

Properties

bluetooth.isActive

bluetooth.isScanning

bluetooth.isMultipleAdvertisementSupported

bluetooth.isOffloadedFilteringSupported

bluetooth.isOffloadedScanBatchingSupported

Functions

bluetooth.init()

bluetooth.setName()

bluetooth.startScan()

bluetooth.stopScan()

bluetooth.connect()

bluetooth.disconnect()

bluetooth.newServer()

bluetooth.startAdvertising()

bluetooth.stopAdvertising()

Events

advertising

init

scan

Types

Gatt

Characteristic

Descriptor

Server

Service

Project Settings

To use this plugin, add an entry into the plugins table of build.settings. When added, the build server will integrate the plugin during the build phase.

You also need to add a special function at the top of the build.settings file and provide your Patreon email and an access key. The access key you get when you become a patron.

local spiralcodestudio_patreon_email = 'YOUR_EMAIL'
local spiralcodestudio_key = 'YOUR_ACCESS_KEY'

local function spiralcodestudio_plugin(name, platforms)
	local plugin = {publisherId = 'com.spiralcodestudio', supportedPlatforms = {}}
	platforms = platforms or {'android', 'appletvos', 'appletvsimulator', 'iphone', 'iphone-sim', 'mac-sim', 'win32-sim'}
	for i = 1, #platforms do
		local platform = platforms[i]
		plugin.supportedPlatforms[platform] = {url = 'https://build.spiralcodestudio.com/' .. spiralcodestudio_patreon_email .. '/' .. spiralcodestudio_key .. '/solar2d/' .. name .. '_' .. platform .. '.tgz'}
	end
	return plugin
end

settings = {
	plugins = {
		['plugin.bluetooth'] = spiralcodestudio_plugin('bluetooth', {'android'})
	}
}

Sample Project

A sample project can be found here.

https://github.com/Lerg/plugins-sample-bluetooth