v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Static Public Member Functions | List of all members
Sifteo::Bluetooth Class Reference

Global Bluetooth operations. More...

#include <sifteo/bluetooth.h>

Static Public Member Functions

static void advertiseState (const uint8_t *bytes, unsigned length)
 Set the current advertised game state. More...
 
template<typename T >
static void advertiseState (const T &object)
 Template wrapper around advertiseState() More...
 
static bool isAvailable ()
 Is Bluetooth support available on this hardware? More...
 
static bool isConnected ()
 Is a device currently connected via the Sifteo Bluetooth API? More...
 

Detailed Description

Global Bluetooth operations.

The system provides a basic level of Bluetooth functionality without any game-specific code. This includes filesystem access, pairing the base with a Sifteo user account, getting information about the running game, and launching a game.

Member Function Documentation

static void Sifteo::Bluetooth::advertiseState ( const uint8_t *  bytes,
unsigned  length 
)
inlinestatic

Set the current advertised game state.

When a device has connected to the Sifteo Base's system software but hasn't necessarily connected to a game's BluetoothPipe, it can still retrieve basic information about the running game.

This basic information is "advertised" to the mobile device, which can use it to determine game state and possibly to determine whether it wants to connect.

This basic information that we advertise includes a game's package name and version. Games may optionally specify an additional game-specific binary blob to include in the advertisement data.

The provided advertisement data is atomically copied to a system buffer. The application can reuse the buffer memory immediately.

To disable this additional advertisement data, call advertiseState() with an empty or NULL buffer.

template<typename T >
static void Sifteo::Bluetooth::advertiseState ( const T &  object)
inlinestatic

Template wrapper around advertiseState()

This is a convenience wrapper around advertiseState(), for passing arbitrary C++ objects. The object is copied, and it does not need to be retained in memory by the caller.

static bool Sifteo::Bluetooth::isAvailable ( )
inlinestatic

Is Bluetooth support available on this hardware?

Returns 'true' if the Base we're running on has firmware and hardware that support Bluetooth. If not, returns 'false'.

Warning
Other Bluetooth functions must only be called if isAvailable() returns 'true'! Do not call any other methods on the Bluetooth object if this returns 'false', and do not install any Bluetooth event handlers.
static bool Sifteo::Bluetooth::isConnected ( )
inlinestatic

Is a device currently connected via the Sifteo Bluetooth API?

Returns 'true' if a device is connected right now, 'false' if not.

To get notified when a connection is created or destroyed, you can attach handlers to Events::bluetoothConnect and Events::bluetoothDisconnect.

Note
If a new connection is created immediately after an old connection is destroyed, you're still guaranteed to receive one Disconnect and one Connect event, in that order.

The documentation for this class was generated from the following file: