def __init__(self):
     try:
         print('Attempting to connect to ', self.MAC_ADDR)
         self.band = MiBand3(self.MAC_ADDR, debug=True)
     except:
         print("Can't Connect Bluetooth")
         redFlag = True
Exemple #2
0
def inicializar_mi_band():
    MAC_ADDR = "D1:51:75:37:49:B4"
    print('Attempting to connect to ', MAC_ADDR)

    band = MiBand3(MAC_ADDR, debug=True)
    band.setSecurityLevel(level = "medium")
    band.authenticate()
    return band
Exemple #3
0
    payload = build_payload(x)
    #band.stop_realtime()
    if x < 30:
        BTsocket = BluetoothSocket(RFCOMM)
        BTsocket.connect(("CC:50:E3:A1:42:D6", 1))
        BTsocket.send("1")
        BTsocket.close()
    print("[INFO] Attemping to send data")
    post_request(payload)
    print("[INFO] finished")
    time.sleep(2)
    band.start_raw_data_realtime(heart_measure_callback=l)


band = MiBand3(MAC_ADDR, debug=True)
band.setSecurityLevel(level="medium")

band.authenticate()
TOKEN = "BBFF-9f0ooUnFzfnJ6R8aGsJzdL7Wtrg6MG"  # Put your TOKEN here
DEVICE_LABEL = "machine"  # Put your device label here


def build_payload(value_1):
    variable_1 = 'heartrate'
    variable_2 = 'time'
    now = datetime.now()
    value_2 = now.strftime("%H:%M:%S")
    payload = {variable_1: value_1, variable_2: value_2}

    return payload
Exemple #4
0
parser.add_argument('cmd',
                    help='Operation required',
                    choices=commands,
                    nargs=1)
parser.add_argument(
    '--silent',
    help='Avoid additional informations regarding BLE communication',
    action='store_false')
args = parser.parse_args()

mac = args.mac
cmd = args.cmd[0]
dbg = args.silent

# Instance of MiBand3
band = MiBand3(mac, debug=dbg)
band.setSecurityLevel(level="medium")

# Initialize or authenticate
if cmd == 'init':
    if band.initialize():
        perr("Initialized...")
    band.disconnect()
    sys.exit(0)
else:
    band.authenticate()

if cmd == 'battery':
    print('Battery:', band.get_battery_info())
elif cmd == 'steps':
    print('Steps:', band.get_steps())
import sys
from auth import MiBand3
from constants import ALERT_TYPES
import time
import os

# Set MAC address of your band here
MAC_ADDR = "00:00:00:00:00"
# need to initialize or not
INIT = False

# create object
band = MiBand3(MAC_ADDR, debug=False)
band.setSecurityLevel(level = "medium")
# Authenticate the MiBand
if(INIT):
    if band.initialize():
        print("Initialized...")
    band.disconnect()
    sys.exit(0)
else:
    band.authenticate()

def get_band_details():
    # put everything into pretty dictionary
    band_data = {
        "Soft revision":band.get_revision(),
        "Hardware revision":band.get_hrdw_revision(),
        "Serial":band.get_serial(),
        "Battery":band.get_battery_info(),
        "Time":band.get_current_time(),