Skip to content
Snippets Groups Projects
Commit c0658d63 authored by Adrien Chabod's avatar Adrien Chabod
Browse files

ajout ingredient

parent 1e2a76e2
Branches
No related tags found
1 merge request!1MAJ BDD + Data commande fonctionnel
......@@ -30,6 +30,8 @@ MACHINE_SEND_ORDER_CHARACTERISTIC_UUID = "6e4a0007-
SQL_PUT_COCKTAIL_CHARACTERISTIC_UUID = "6e4a0008-b5a3-f393-e0a9-e50e24dcca9e"
SQL_PUT_INGREDIENT_CHARACTERISTIC_UUID = "6e4a0009-b5a3-f393-e0a9-e50e24dcca9e"
SQL_MAJ_MACHINE_CHARACTERISTIC_UUID = "6e4a0010-b5a3-f393-e0a9-e50e24dcca9e"
SQL_GET_BEC_FROM_INGREDIENT_CHARACTERISTIC_UUID = "6e4a0011-b5a3-f393-e0a9-e50e24dcca9e"
SQL_ADD_INGREDIENT_CHARACTERISTIC_UUID = "6e4a0012-b5a3-f393-e0a9-e50e24dcca9e"
mainloop = None
class TxCharacteristic(Characteristic):
......@@ -93,7 +95,8 @@ class UartService(Service):
self.add_characteristic(BLE_GET_INGREDIENT_LIST(bus, 2, self))
self.add_characteristic(BLE_GET_QUANTITE_MACHINE(bus, 3, self))
self.add_characteristic(BLE_MACHINE_SEND_ORDER(bus, 4, self))
self.add_characteristic(BLE_GET_BEC_FROM_INGREDIENT(bus, 5, self))
self.add_characteristic(BLE_ADD_INGREDIENT(bus, 6, self))
class Application(dbus.service.Object):
def __init__(self, bus):
......@@ -161,6 +164,23 @@ class BLE_GET_QUANTITE_MACHINE(TxCharacteristic):
def do_something(self):
self.send_tx(formalize_data_list(mysql_get_quantite_machine))
class BLE_GET_BEC_FROM_INGREDIENT(TxCharacteristic):
def __init__(self, bus, index, service):
TxCharacteristic.__init__(self, bus, index, service, SQL_GET_BEC_FROM_INGREDIENT_CHARACTERISTIC_UUID)
def do_something(self):
self.send_tx(formalize_data_list(mysql_get_bec_from_ingredient))
class BLE_ADD_INGREDIENT(RxCharacteristic):
def __init__(self, bus, index, service):
RxCharacteristic.__init__(self, bus, index, service, SQL_ADD_INGREDIENT_CHARACTERISTIC_UUID)
def WriteValue(self, value, options):
ingredient = unformalize_data_list(format(bytearray(value).decode()))
print(format(bytearray(value).decode()))
print(ingredient)
print(ingredient[0])
class BLE_MACHINE_SEND_ORDER(RxCharacteristic):
def __init__(self, bus, index, service):
RxCharacteristic.__init__(self, bus, index, service, MACHINE_SEND_ORDER_CHARACTERISTIC_UUID)
......
......@@ -74,7 +74,7 @@ def mysql_get_bec_from_ingredient(id_ingredient):
def mysql_add_ingredient(id_bec, nom_ingredient):
connection = connect_db()
cursor = connection.cursor()
cursor.execute("INSERT INTO ingredient ""(id_bec, nom_ingredient) " "VALUES (%s, %s)", (id_bec, nom_ingredient,))
cursor.execute("INSERT INTO ingredient ""(nom_ingredient) " "VALUES (%s)", (nom_ingredient,))
connection.commit()
cursor.close()
connection.close()
......
......@@ -6,5 +6,5 @@ print(mysql_get_quantite_machine())
print(mysql_get_all_cocktail_composition_without_bec())
print(mysql_get_cocktail_composition_without_bec(1))
print(mysql_get_cocktail_composition_with_bec(1))
mysql_add_ingredient(10, "test")
print(mysql_get_bec_from_ingredient(1))
\ No newline at end of file
print(mysql_get_bec_from_ingredient(1))
mysql_add_ingredient(1, "test")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment