Python HMKit

HMKit is the access point for the Broadcaster. It is also used to initialise the SDK with a Device Certificate and security keys.

Getting the instance

hmkit.getInstance()

Declaration

get_instance();

Returns

The HMKit object.

Managing the SDK lifecycle

Discussion

The SDK needs to be initialised with necessary properties and terminated if not used anymore.

Initialise the SDK with a DeviceCertificate and crypto keys.

Declaration

__init__(snippet, loglevel=logging.INFO):

Parameters

snippet

Device certificate snippet downloaded from developer centre

loglevel

python logging level for hmkit logs logging.DEBUG logging.INFO logging.WARNING logging.ERROR logging.CRITICAL

Example

# Initialise with HMKit class with a Device Certificate and private key. To start with
# this can accept Base64 strings straight from the Developer Center

hmkit = hmkit.HmKit(["dGVzdL4fYCCf6ejwVan0qIYsj8fSrM1xs5y/EiMDgPEcwRSNlEmd+SFAJeGxFn+GUKzK0SukJMT732PSpz6bD6vI1y5aJNJXQLLUraXIkCde85SfXws/HZqqkSO7ZThFqyfGqjicPFgf/3qDys9kaU59bu+KiDi3nrnbDKnWFLZR2LQNmAksZiD3kZP9jap9ddXzjpLGXjaZ",
"RBeM/YetpFhY6KaNnGAX5aBSGUJrslMxCFJX9NAyAiQ=",
"N2q9HV421SvfLClnNhaYK1dAcKs3LwDAIOTKhUX4dZbIoonHxfz2614r/ZuMCw9TwjQPHt4MC5LeFEi9wrf5nw=="], logging.DEBUG)

Terminate Hmkit and internal resources

Declaration

hmkit_exit():

Discussion

Call this function when the SDK is not used anymore. For instance when killing the app. This clears the Bluetooth service and unregisters all BroadcastReceivers.

Properties

The logging level of the SDK.

Declaration

set_logging_level(loglevel=logging.INFO)

Discussion

The possible logging levels are represented by python logging module logging._

logging.DEBUG, logging.INFO, logging.WARNING ,logging.ERROR,
logging.CRITICAL

Certificate Management

Discussion

Access Certificates are needed to identifiy the link between two devices, via Bluetooth

Download an access certificate.

Declaration

download_access_certificate(token):

Parameters

token

The token that is used to download the certificate.

Discussion

The access token needs to be provided by the certificate provider. raises Exception on error

Read More

Example

# Download Access Certificate with the token

try:
    hmkit.get_instance().download_access_certificate(b"03ba0ec2-a8d9-4410-9468-fe7d536ebd05")
except Exception as e:
    # Handle the error
    log.critical("Error in Access certicate download " + str(e.args[0]))