Example #1
0
    def createRequester(self):
        """Create a GATTRequester for the BLEConnectionManager

        :return: Returns the newly created requester
        :rtype: GATTRequester

        """
        if self.adapter == "":
            self.requester = GATTRequester(self.address, False)
        else:
            self.requester = GATTRequester(self.address, False, self.adapter)
        return self.requester
Example #2
0
    def connect(self,
                device: str,
                interface: str = None,
                wait: bool = True,
                channel_type: str = 'public',
                security_level: str = 'low',
                psm: int = 0,
                mtu: int = 0,
                timeout: float = 10.0):
        """
        Connect to a bluetooth LE device

        :param device: Device address to connect to
        :param interface: Bluetooth adapter name to use (default configured if None)
        :param wait: If True then wait for the connection to be established before returning (no timeout)
        :param channel_type: Channel type, usually 'public' or 'random'
        :param security_level: Security level - possible values: ['low', 'medium', 'high']
        :param psm: PSM value (default: 0)
        :param mtu: MTU value (default: 0)
        :param timeout: Connection timeout if wait is not set (default: 10 seconds)
        """
        from gattlib import GATTRequester

        req = self._req_by_addr.get(device)
        if req:
            if req.is_connected():
                self.logger.info(
                    'Device {} is already connected'.format(device))
                return

            self._req_by_addr[device] = None

        if not interface:
            interface = self.interface
        if interface:
            req = GATTRequester(device, False, interface)
        else:
            req = GATTRequester(device, False)

        self.logger.info('Connecting to {}'.format(device))
        connect_start_time = time.time()
        req.connect(wait, channel_type, security_level, psm, mtu)

        if not wait:
            while not req.is_connected():
                if time.time() - connect_start_time > timeout:
                    raise TimeoutError(
                        'Connection to {} timed out'.format(device))
                time.sleep(0.1)

        self.logger.info('Connected to {}'.format(device))
        self._req_by_addr[device] = req
    def __init__(self, address):
        self.requester = GATTRequester(address, False)

        self.connect()
        self.check_status()
        self.disconnect()
        self.check_status()
Example #4
0
def ReadFlowerCare(address):
    try:
        requester = GATTRequester(address)
    except:
        return 'error', 0, 0, 0, 0, 0
    try:
        # Read battery and firmware version attribute
        data = requester.read_by_handle(0x0038)[0]
        battery, version = unpack('<B6s', data)
        version = filter(lambda x: x in string.printable, version)
    except:
        return 'error', 0, 0, 0, 0, 0
    try:
        # Enable real-time data reading
        requester.write_by_handle(0x0033, str(bytearray([0xa0, 0x1f])))
    except:
        return 'error', 0, 0, 0, 0, 0
    try:
        # Read plant data
        data = requester.read_by_handle(0x0035)[0]
    except:
        return 'error', 0, 0, 0, 0, 0
    try:
        temperature, sunlight, moisture, fertility = unpack(
            '<hxIBHxxxxxx', data)
        return version, battery, temperature, sunlight, moisture, fertility
    except:
        return 'error', 0, 0, 0, 0, 0
Example #5
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)
        self.response = NotifyMeYourValue()

        self.connect()
        self.request_data()
        self.loop()
Example #6
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)
        self.response = GATTResponse()

        self.connect()
        self.request_data()
        self.wait_response()
Example #7
0
def write_data(self, DEVICE, service, data):
    req = GATTRequester(DEVICE)
    try:
        req.write_by_handle(service, str(data))
        print("Data was written")
    except:
        print("Write error")
Example #8
0
    def __init__(self, address):
        self.requester = GATTRequester("40:06:A0:97:74:A9", False)
        self.response = GATTResponse()

        self.connect()
        self.request_data()
        self.wait_response()
Example #9
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)

        times = 3
        print("I will connect & disconnect {} times...".format(times))

        for i in range(times):
            self.connect()
            self.disconnect()
Example #10
0
 def __init__(self, address):
     writeResponse = False
     try:
         self.requester = GATTRequester(address, False)
         self.connect()
         self.send_data()
     except:
         print("Connection failed")
         self.requester.connect(False)
Example #11
0
 def __init__(self, address):
     self.requester = GATTRequester(address, False)
     self.humidity = float(0.0)
     self.temperature = float(0.0)
     self.object_temperature = float(0.0)
     self.barometer = float(0.0)
     self.gyrometer = {"x": float(0.0), "y": float(0.0), "z": float(0.0)}
     self.acceleration = {"x": float(0.0), "y": float(0.0), "z": float(0.0)}
     self.geomagnetism = {"x": float(0.0), "y": float(0.0), "z": float(0.0)}
     self.lux = float(0.0)
Example #12
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)
        self.connect()
        self.request_name()

        characteristics = self.requester.discover_characteristics()
        for ch in characteristics:
            print(ch)

        data = self.requester.read_by_handle(0x000e)
        print(data)
    def OnGSRButtonClick(self):
	
	    req = GATTRequester("98:4F:EE:0F:59:D6")
	    temp = []
	    f = open("gsr.csv", 'a')
	    writer = csv.writer(f)
	    writer.writerow( ('timestamp', 'gsr') )
	    flagTemp = 0;
	    flagBP = 1;
	    flagGSR = 0;
	    req.write_by_handle(0x000e,str(bytearray([01])))
	    tt = req.read_by_handle(0x0010)[0]
Example #14
0
    def __init__(self):
        service = DiscoveryService("hci0")
        devices = service.discover(2)

        for address, name in devices.items():
            if name != '' and 'nemo-wedo2' in name:
                print(name)
                req = GATTRequester(address, True, "hci0")
                break

        if 'req' not in dir():
            print('Connecting to wedo2.0 hub is failed!')
            os._exit(0)

        self.req = req
Example #15
0
def smart_hub_connect():
    service = DiscoveryService("hci0")
    devices = service.discover(2)

    for address, name in devices.items():
        if name != '' and 'Smart Hub' in name:
            label['text'] = address

            global button_run, button_stop, button_disconnect, req
            button_connect['state'] = 'disabled'
            button_run['state'] = 'normal'
            button_stop['state'] = 'normal'
            button_disconnect['state'] = 'normal'
            button_up['state'] = 'normal'
            button_down['state'] = 'normal'

            req = GATTRequester(address, True, "hci0")
            break
    def OnBPButtonClick(self):
	
	   f = open("bp.csv", 'wt')
	   writer = csv.writer(f)
	   writer.writerow( ('sys', 'dia','pulse') )
	   req = GATTRequester("98:4F:EE:0F:59:D6")
	   req.write_by_handle(0x000e,str(bytearray([02])))
	   tt = req.read_by_handle(0x0010)[0]
	   pp = []
	   for c in tt:
		  pp.append(ord(c))
	   print pp
	   if(pp[1] == 2):
		
		while(1):
			try:
				tt = req.read_by_handle(0x0010)[0]
				pp = []
				for c in tt:
					pp.append(ord(c))
				if(pp[0] == 3):
					break
			except Exception,e:
				print e
		
		try:
			name = req.read_by_uuid("2A40")[0]
			#steps = (req.read_by_handle(0x0009)[0])
			print type(name)
		
			value = []
			for c in name:
				value.append((c))
			print value
			print "sys :"+value[1]+value[2]+value[3]+"\n"
			print "dia :"+value[6]+value[7]+value[8]+"\n"
			print "sys :"+value[11]+value[12]+value[13]+"\n"
			writer.writerow((value[1]+value[2]+value[3],value[6]+value[7]+value[8],value[11]+value[12]+value[13]))
		
				
		except Exception,e:
			#name = False
			print e
Example #17
0
#Read data from Xiaomi flower monitor, tested on firmware version 2.6.6

import sys
from gattlib import GATTRequester, GATTResponse
from struct import *
import paho.mqtt.client as mqtt
from farmware_tools import device

address = "c4:7c:8d:66:35:49"
#sys.argv[1]
requester = GATTRequester(address)
#Read battery and firmware version attribute
data = requester.read_by_handle(0x0038)[0]
battery, version = unpack('<B6s', data)
device.log("Battery level:", battery, "%")
device.log("Firmware version:", version)
#Enable real-time data reading
requester.write_by_handle(0x0033, str(bytearray([0xa0, 0x1f])))
#Read plant data
data = requester.read_by_handle(0x0035)[0]
temperature, sunlight, moisture, fertility = unpack('<hxIBHxxxxxx', data)
device.log("Light intensity:", sunlight, "lux")
print "Temperature:", temperature / 10., "C"
print "Soil moisture:", moisture, "%"
print "Soil fertility:", fertility, "uS/cm"

#Sometimes the version contains some funny charcters which throws off the JSON processing. Cleaning string
temp = version
version = " "
for x in temp:
    if x == ".":
Example #18
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)

        i = self.requester.is_connected()
        print(i)
        self.connect()
Example #19
0
 def __init__(self, address):
     self.requester = GATTRequester(address, False)
     self.connect()
     self.send_data()
Example #20
0
    def __init__(self, address):
        self.requester = GATTRequester(address, False)

        self.connect()
        self.wait_disconnection()
Example #21
0
scanner = Scanner()

devices = scanner.scan(5.0)
bAddr = ""
for dev in devices:
    if "6c:72:20" in dev.addr and dev.getValueText(1) and dev.getValueText(
            7) and dev.getValueText(9):
        bAddr = dev.addr
        print "[+] Komfy switch found: %s (%s), RSSI=%d dB" % (
            dev.addr, dev.addrType, dev.rssi)
if not bAddr:
    print "No Komfy switches found"
    sys.exit(1)

req = GATTRequester(bAddr.encode('ascii', 'ignore'), False, 'hci0')
req.connect(True, 'public', 'none', 0, 78)

#request SSID
wifiSsid = req.read_by_uuid("0xb006")[0]
reg = re.search(r"(:\s\"(.*)\")", wifiSsid)
wifiSsid = reg.groups()[1].replace("\\", "")

#request komfy encoded wifi password
wifiPassKomfy64 = req.read_by_uuid("0xb007")[0]
reg = re.search(r"(:\s\"(.*)\")", wifiPassKomfy64)
wifiPassKomfy64 = reg.groups()[1].replace("\\", "")

#convert password to real base64
wifiPassBase64 = ""
for char in wifiPassKomfy64:
Example #22
0
def read_data_job():
	address = mac_address
	global g_sun
	global g_moi
	global g_tem
	global g_fer
	now = datetime.datetime.now()
        test_min = int(now.strftime("%M"))
        time = now.strftime("%Y-%m-%d %H:%M:%S")
	try:
		requester = GATTRequester(address)
                #Read battery and firmware version attribute
                data=requester.read_by_handle(0x0038)[0]
                battery, version = unpack('<B6s',data)
                #Enable real-time data reading
                requester.write_by_handle(0x0033, str(bytearray([0xa0, 0x1f])))
                #Read plant data
                data=requester.read_by_handle(0x0035)[0]
                temperature, sunlight, moisture, fertility = unpack('<hxIBHxxxxxx',data)
                temperature=float(temperature/10)
		min = int(test_min/10)
		#g_sun[min] = sunlight
		#g_moi[min] = moisture
		#g_fer[min] = fertility
		#g_tem[min] = temperature
		#conn = mysql.connect()
               	#cursor = conn.cursor()
               	#sql = "INSERT INTO sensor_data_test (sunlight,moisture,temperature,fertility,time) VALUES ('%d','%d','%f','%d','%s')" % (sunlight,moisture,temperature,fertility,time)
             	#cursor.execute(sql)
              	#conn.commit()
               	#cursor.close()
                #conn.close()
		print "get data at %s" % time
	except:
		print "can not get data at %s" % time
	finally:
                if int(test_min/10) == 5:
                        sum_sun = 0
                        sum_tem = 0
                        sum_fer = 0
                        sum_moi = 0
                        check_sun = 0
                        check_tem = 0
                        check_fer = 0
                        check_moi = 0
                        for i in range(0,6):
                                if g_sun[i] != -1:
                                        sum_sun += g_sun[i]
                                        check_sun += 1
                                if g_moi[i] != -1:
                                        sum_moi += g_moi[i]
                                        check_moi += 1
                                if g_tem[i] != -1.0:
                                        sum_tem += g_tem[i]
                                        check_tem += 1
                                if g_fer[i] != -1:
                                        sum_fer += g_fer[i]
                                        check_fer += 1
			if check_sun != 0:
                        	sum_sun = int(sum_sun/check_sun)
			if check_moi != 0:
                       	 	sum_moi = int(sum_moi/check_moi)
                        if check_tem != 0:
				sum_tem = float(sum_tem/check_tem)
                        if check_fer != 0:
				sum_fer = int(sum_fer/check_fer)
			conn = mysql.connect()
                	cursor = conn.cursor()
			print "STORE DATA AFTER 1 HOUR at %s" % time
                	sql = "INSERT INTO sensor_data (sunlight,moisture,temperature,fertility,time) VALUES ('%d','%d','%f','%d','%s')" % (sum_sun,sum_moi,sum_tem,sum_fer,time)
                	cursor.execute(sql)
                	conn.commit()
                	cursor.close()
                	conn.close()
			for i in range(0,6):
				g_sun[i] = -1
				g_moi[i] = -1
				g_tem[i] = -1.0
				g_fer[i] = -1	
Example #23
0
#!/usr/bin/python
# -*- mode: python; coding: utf-8 -*-

# Copyright (C) 2014, Oscar Acena <*****@*****.**>
# This software is under the terms of Apache License v2 or later.

from __future__ import print_function

import sys
from gattlib import GATTRequester

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: {} <addr>".format(sys.argv[0]))
        sys.exit(1)

    requester = GATTRequester(sys.argv[1], False)

    print("Connecting...")
    sys.stdout.flush()
    requester.connect(True)

    primary = requester.discover_primary()
    for prim in primary:
        print(prim)

    print("Done.")
Example #24
0
#PONG pygame
from Tkinter import *
import tkMessageBox
import random
import pygame, sys
from pygame.locals import *
from time import sleep
from gattlib import GATTRequester, GATTResponse
import time

req = GATTRequester("EA:02:7F:9E:5F:7C", False)
req1 = GATTRequester("EC:C7:D5:05:67:BF", False)

#globals
WIDTH = 1600
HEIGHT = 840
BALL_RADIUS = 20
PAD_WIDTH = 50
PAD_HEIGHT = HEIGHT
HALF_PAD_WIDTH = PAD_WIDTH / 2
HALF_PAD_HEIGHT = PAD_HEIGHT / 2
ball_pos = [0, 0]
ball_vel = [0, 0]
paddle1_vel = 0
paddle2_vel = 0
l_score = 100
r_score = 100
area = 0  #Left is 0 and right is 1. Useful since we are communicating with 2 devices at once, so request only the one which is in the area
finish_flag = 0
r_score_extra = 0
l_score_extra = 0
Example #25
0
from gattlib import GATTRequester

req = GATTRequester("C9:E8:56:3B:4D:B1", False)
req.connect(True, "random")
req.is_connected()

print(req.discover_primary())
req.disconnect()
Example #26
0
from gattlib import GATTRequester
import paho.mqtt.client as mqtt
from time import sleep

try:
    req = GATTRequester("3C:71:BF:FD:08:96")

    client = mqtt.Client()
    client.connect("mqtt.thingspeak.com", 1883, 60)

    channelId = "1046955"
    apiKey = "R2GFC1Q7A5Y999I0"  #Write
    #apiKey = "3CIKRBES3MDG9W7J" #Read

    while True:
        data = req.read_by_uuid("00002A37-0000-1000-8000-00805F9B34FB")[0]
        #data = req.read_by_handle(0x180F)[0]

        value_byte = int(data[1])

        print("bytes received:", end=' ')
        print(value_byte, end=' ')
        if (value_byte < 100):
            send_to_thingspeak = 0
            print("0. Darah rendah")
        elif (value_byte < 120):
            send_to_thingspeak = 1
            print("1. Normal")
        else:
            send_to_thingspeak = 2
            print("2. Darah tinggi")
Example #27
0
import paho.mqtt.publish as publish
from gattlib import DiscoveryService, GATTRequester, GATTResponse

verbose = True

service = DiscoveryService("hci0")
devices = service.discover(15)

baseTopic = "/miflower/"
msgs = []

for address, name in list(devices.items()):
    try:
        if (name == "Flower mate" or name == "Flower care"):
            topic = baseTopic + address.replace(':', '') + '/'
            requester = GATTRequester(address, True)
            #Read battery and firmware version attribute
            data = requester.read_by_handle(0x0038)[0]
            battery, firmware = unpack('<xB5s', data)
            msgs.append({'topic': topic + 'battery', 'payload': battery})
            msgs.append({'topic': topic + 'firmware', 'payload': firmware})
            #Enable real-time data reading
            requester.write_by_handle(0x0033, str(bytearray([0xa0, 0x1f])))
            #Read plant data
            data = requester.read_by_handle(0x0035)[0]
            temperature, sunlight, moisture, fertility = unpack(
                '<hxIBHxxxxxx', data)
            msgs.append({
                'topic': topic + 'temperature',
                'payload': temperature / 10.
            })
# Publish to the same topic in a loop forever
loopCount = 0
publishDelay = 0.015 # seconds
afterSpeechDelay = 0.100 # second
dataPointsPerMovement = 4
dataPointsPerMovementIteration = 4

bufferSize = 1 # 4 packets x 20 bytes per packet MAX (5 x int32)
class ImuPacket(): pass # Stores imu packet: timestamp and payload
class ImuPayload(): pass # Stores imu data

trainingLive = True # While true, loop
while trainingLive == True:
	try:

		req = GATTRequester("98:4f:ee:10:d4:90") # BLE genuino 101 address
		
		for classIndex in range(len(longswordMovements)):
			
			if verbose == True:
				print("Playing ssml: ", longswordMovements[classIndex]);
			if speech == True:
				playTextToSpeech(longswordMovements[classIndex]) # Play movement text-to-speech

			time.sleep(afterSpeechDelay)
	
			for dataPoints in range(dataPointsPerMovement): # get  data points

				if (dataPoints % dataPointsPerMovementIteration == 0 or dataPoints == 0) and classIndex > 3:
					if speech == True and countDown == True:
Example #29
0
import sys, time
import threading
import keyboard
import numpy as np

from gattlib import GATTRequester, GATTResponse
#Device1 = GATTRequester("40:06:A0:97:74:A9", False) # right wheel
#Device2 = GATTRequester("40:06:A0:94:FE:F7", False) # left wheel
Device1 = GATTRequester("DD:43:89:16:43:81", False)  # right wheel
Device2 = GATTRequester("F4:82:B3:50:ED:55", False)  # left wheel'
time.sleep(0.5)
sum_time = 0
mean_time = 0
count = 0

STOP = 0
MOVE_FWD = 1
MOVE_BWD = 2
MOVE_FWR_R = 10
MOVE_FWR_L = 11

MOVE_R = 3
MOVE_L = 4
IDLE = 9
F = 5
S = 6
Mon = 7
Moff = 8
keycode = ""

Example #30
0
def main():
	conn = mysql.connect()
      	cursor = conn.cursor()
     	sql = "SELECT * FROM plants_info WHERE id = 1"
     	cursor.execute(sql)
     	results = cursor.fetchall()
     	for row in results:
		plants_name = row[1]
             	sun_b = row[2]
		sun_t = row[3]
		moi_b = row[4]
		moi_t = row[5]
		tem_b = row[6]
		tem_t = row[7]
		fer_b = row[8]
		fer_t = row[9]
	sql = "SELECT * FROM sensor_data_hour WHERE id = 2"
	cursor.execute(sql)
        results = cursor.fetchall()
        for row in results:
		status_led = row[7]
		status_water = row[8]
		status_fan = row[9]
	cursor.close()
        conn.close()
	sun_b = int(sun_b*10.76/(0.71*24))
	sun_t = int(sun_t*10.76/(0.71*2))
	status_sun = 1
	status_moi = 1
	status_tem = 1
	status_fer = 1
	if request.method == 'POST':
		if not session.get('mac'):
			conn = mysql.connect()
                	cursor = conn.cursor()
                	sql = "SELECT * FROM plants_info WHERE id = 1"
                	cursor.execute(sql)
                	results = cursor.fetchall()
                	for row in results:
                        	address_x = row[0]
                	cursor.close()
                	conn.close()
			address = str(address_x)
			session['mac'] = address_x
		else:
			address = str(session['mac'])
		try:
			requester = GATTRequester(address)
			#Read battery and firmware version attribute
			data=requester.read_by_handle(0x0038)[0]
			battery, version = unpack('<B6s',data)
			#Enable real-time data reading
			requester.write_by_handle(0x0033, str(bytearray([0xa0, 0x1f])))
			#Read plant data
			data=requester.read_by_handle(0x0035)[0]
			temperature, sunlight, moisture, fertility = unpack('<hxIBHxxxxxx',data)
			temperature=float(temperature/10)
			data_time=datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
			conn = mysql.connect()
                	cursor = conn.cursor()
                	sql = "UPDATE plants_info SET baterry = %d, firmware = '%s' WHERE id = 1" % (battery,version)
                	cursor.execute(sql)
			conn.commit()
			sql = "UPDATE sensor_data_hour SET sunlight = %d, moisture = %d,temperature=%0.1f,fertility=%d,time='%s' WHERE id = 2" % (sunlight,moisture,temperature,fertility,data_time)
                        cursor.execute(sql)
                        conn.commit()
			cursor.close()
			conn.close()
			flash('Data updated successfully','success')
		except:
			flash('Could not update sensor value, please try again','danger')
			conn = mysql.connect()
	                cursor = conn.cursor()
        	        sql = "SELECT * FROM sensor_data_hour WHERE id = 2"
                	cursor.execute(sql)
                	results = cursor.fetchall()
                	for row in results:
                        	sunlight = row[1]
                        	moisture = row[2]
                        	fertility = row[4]
                        	temperature = row[3]
                        	data_time = row[5]
                	cursor.close()
                	conn.close()
		if sunlight < sun_b:
			status_sun = 0
		elif sunlight > sun_t:
			status_sun = 2
                if moisture < moi_b:
                        status_moi = 0
                elif moisture > moi_t:
                        status_moi = 2
                if temperature < tem_b:
                        status_tem = 0
                elif temperature > tem_t:
                        status_tem = 2
                if fertility < fer_b:
                        status_fer = 0
                elif fertility > fer_t:
                        status_fer = 2
		string_time = str(data_time)
		string_time = string_time[11:-6]
		check_hour = int(string_time)
		if check_hour >= 18 or check_hour <=5:
			status_sun = 3
		return render_template('index.html',status_fan=status_fan,status_led=status_led,status_water=status_water,status_sun=status_sun,status_moi=status_moi,status_tem=status_tem,status_fer=status_fer,sun=sunlight,moi=moisture,tem=temperature,fer=fertility,time=data_time,plants_name=plants_name,sun_b=sun_b,sun_t=sun_t,moi_b=moi_b,moi_t=moi_t,tem_b=tem_b,tem_t=tem_t,fer_b=fer_b,fer_t=fer_t)
	else:
		conn = mysql.connect()
               	cursor = conn.cursor()
                sql = "SELECT * FROM sensor_data_hour WHERE id = 2"
                cursor.execute(sql)
                results = cursor.fetchall()
                for row in results:
                    	data_sun = row[1]
                       	data_moi = row[2]
                      	data_fer = row[4]
                     	data_tem = row[3]
                      	data_time = row[5]
		cursor.close()
		conn.close()
		if data_sun < sun_b:
                        status_sun = 0
                elif data_sun > sun_t:
                        status_sun = 2
                if data_moi < moi_b:
                        status_moi = 0
                elif data_moi > moi_t:
                        status_moi = 2
                if data_tem < tem_b:
                        status_tem = 0
                elif data_tem > tem_t:
                        status_tem = 2
                if data_fer < fer_b:
                        status_fer = 0
                elif data_fer > fer_t:
                        status_fer = 2
                string_time = str(data_time)
                string_time = string_time[11:-6]
                check_hour = int(string_time)
                if check_hour >= 18 or check_hour <=5:
                        status_sun = 3
		return render_template('index.html',status_fan=status_fan,status_led=status_led,status_water=status_water,status_sun=status_sun,status_moi=status_moi,status_tem=status_tem,status_fer=status_fer,plants_name=plants_name,sun=data_sun,moi=data_moi,tem=data_tem,fer=data_fer,time=data_time,sun_b=sun_b,sun_t=sun_t,moi_b=moi_b,moi_t=moi_t,tem_b=tem_b,tem_t=tem_t,fer_b=fer_b,fer_t=fer_t)