cct package¶
cct.proximity
– Bluetooth LE proximity detection¶
-
class
cct.proximity.
Proximity
(threshold=None, callback=None)¶ Detects device proximity using Bluetooth LE
Example:
from cct.proximity import Proximity # scanning example, see example.py for advertising p = Proximity() # activate bluetooth p.activate() # get bt mac address mac = p.bluetooth_mac_address # set threshold p.threshold = -100 # set your callback function (see example.py) p.callback = your_predefined_callback p.start_scanning() # when you're done p.stop_scanning() p.deactivate()
Initializes the proximity detecter
-
activate
()¶
-
property
bluetooth_mac_address
¶ MAC address hex string
Property for the MAC address ID for bluetooth device
- Type
str
-
property
callback
¶
-
deactivate
()¶
-
is_active
()¶ Proximity bluetooth active status :returns: is active? :rtype: bool
-
start_advertising
()¶ Start advertising device signal (start signaling to other bluetooth devices)
-
start_scanning
()¶ Start proximity detection (start observing other bluetooth devices)
-
stop_advertising
()¶ Stop advertising device signal (stop signaling to other bluetooth devices)
-
stop_scanning
()¶ Stop proximity detection (stop observing other bluetooth devices)
-
property
threshold
¶ -50)
Adjust this threshold to set detect closer (higher) and farther (lower)
- Type
number
- Type
Threshold for proximity detection strength (default
-
-
cct.proximity.
memoryview_addr_to_str
(data)¶
-
cct.proximity.
memoryview_data_to_str
(data)¶
cct.wifi
module¶
-
class
cct.wifi.
Connection
(ssid, password=None)¶ Initializes a connection to a WiFi network
..code-block:
from cct.wifi import Connection wifi = Connection("ssid", "password") wifi.connect()
-
connect
()¶ Connect to the previously specified wi-fi network
-
disconnect
()¶ Disconnect
-
is_connected
()¶ Check if the connection is active :returns: True if connection active, otherwise False :rtype: bool
-
nic
¶ Connection NIC
-
password
¶ Password for connection
-
reconnect
()¶ Reconnect
-
reconnect_if_necessary
()¶ Reconnect if necessary
-
ssid
¶ SSID for connection
-
cct.google.ufirebase
– read/write to Firebase database¶
-
class
cct.google.ufirebase.
Firebase
(database, email, keyfile)¶ Reads, writes, modifies, and deletes objects to a Firebase database
Example:
from cct.ufirebase import Firebase firebase = Firebase('mydbname', 'myserviceaccount@email`, `mykeyfile`) firebase.put('name', 'Joe Q Public') firebase.get('name') # returns 'Joe Q Public'
Initializes the Firebase database
- Parameters
database (str) – String name of the Firebase database
email (str) – Email for service account used to authenticate
keyfile (str) – Full filename to service account keyfile (e.g. key.json) A relative or full path to filename can be used
-
append_to_list
(key, value)¶ Alias for post
- Parameters
key (str) – Search key value
value (any) – Value to add to existing list
-
database
¶ Firebase database name.
- Type
database (str)
-
delete
(key)¶ Delete a value from the database by key
- Parameters
key (str) – Search key value
-
email
¶ Email for authenticated service account.
- Type
email (str)
-
get
(key)¶ Fetch a value from the database by key
- Parameters
key (str) – Search key value
- Returns
Retrieved key
- Return type
any
-
get_list
(key)¶ Fetch a list from the database by key
- Parameters
key (str) – Search key value
- Returns
List retrived from database
- Return type
[any]
-
patch
(key, value)¶ Modify a value in the database by key
- Parameters
key (str) – Search key value
value (any) – Value to modify in the database
-
post
(key, value)¶ Add a value to a list of values under key
- Parameters
key (str) – Search key value
value (any) – Value to add to existing list
-
put
(key, value)¶ Write a value to the database by key
- Parameters
key (str) – Search key value
value (any) – Value to write to the database