Skip to content
Snippets Groups Projects
Unverified Commit 1d6bc728 authored by Robot Odoo's avatar Robot Odoo Committed by GitHub
Browse files

[IMP] hw_drivers, pos : Listen port in the IoT Box


We use a new method to connect the box to a device in the network.

We use the socket to listen a specific port in the box to connect device through the TCP/IP

Task: 1891152

--
I confirm I have signed the CLA and read the PR guidelines at www.odoo.com/submit-pr

closes odoo/odoo#33398

Signed-off-by: default avatarQuentin Lejeune (qle) <qle@odoo.com>
parents 4cae62ba 7c31e0d2
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ from cups import Connection as cups_connection
from glob import glob
from base64 import b64decode
from pathlib import Path
import socket
from odoo import http, _
from odoo.modules.module import get_resource_path
......@@ -117,6 +118,7 @@ class StatusController(http.Controller):
drivers = []
bt_devices = {}
socket_devices = {}
iot_devices = {}
class DriverMetaClass(type):
......@@ -348,6 +350,7 @@ class Manager(Thread):
updated_devices = self.usb_loop()
updated_devices.update(self.video_loop())
updated_devices.update(bt_devices)
updated_devices.update(socket_devices)
if cpt % 40 == 0:
printer_devices = self.printer_loop()
cpt = 0
......@@ -388,6 +391,19 @@ class BtManager(Thread):
dm.start_discovery()
dm.run()
class SocketManager(Thread):
def run(self):
while True:
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
sock.bind(('', 9000))
sock.listen(1)
dev, addr = sock.accept()
if addr and addr[0] not in socket_devices:
iot_device = IoTDevice(type('', (), {'dev': dev}), 'socket')
socket_devices[addr[0]] = iot_device
conn = cups_connection()
PPDs = conn.getPPDs()
printers = conn.getPrinters()
......@@ -399,3 +415,7 @@ m.start()
bm = BtManager()
bm.daemon = True
bm.start()
sm = SocketManager()
sm.daemon = True
sm.start()
......@@ -46,8 +46,8 @@ html {
}
table {
border-spacing: 0px;
border-collapse: collapse;
border-spacing: 0px 10px;
border-collapse: inherit;
}
td {
padding: 0px;
......
......@@ -9,7 +9,7 @@
<field name="journal_user" attrs="{'invisible': [('type', 'not in', ['bank', 'cash'])]}"/>
</xpath>
<xpath expr="//notebook[last()]" position="inside">
<page string="Point of Sale" attrs="{'invisible': [('journal_user', '=', False)]}">
<page string="Point of Sale" name="point_of_sale" attrs="{'invisible': [('journal_user', '=', False)]}">
<group>
<group name="amount_authorized" attrs="{'invisible': [('type', '!=', 'cash')]}">
<field name="amount_authorized_diff"/>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment