def get_temp_units_handler(msg_type, data): temp = pb.IntegerValue() temp.ParseFromString(data) if temp.value == 0: print "Celcius" else: print "Farenheight"
def cmd_get_ble_params(self, msg_num): iv = pb.IntegerValue() iv.value = 0 self.send(msg_type=msg_num, data=iv.SerializeToString(), handler=get_ble_params_handler)
def cmd_set_temp_units(self, msg_num, degree): iv = pb.IntegerValue() iv.value = degree self.send(msg_type=msg_num, data=iv.SerializeToString(), handler=set_temp_units_handler)
def cmd_get_cur_temp(self, msg_num): iv = pb.IntegerValue() iv.value = 0 self.send(msg_type=msg_num, data=iv.SerializeToString(), handler=get_curr_temp_handler)
def cmd_setpoint(self, msg_num, value): iv = pb.IntegerValue() iv.value = value self.send(msg_type=msg_num, data=iv.SerializeToString(), handler=set_temp_setpoint_handler)
def get_temp_setpoint_handler(msg_type, data): temp = pb.IntegerValue() temp.ParseFromString(data) print "Setpoint: %d" % temp.value