Commit Graph
49 Commits
Author SHA1 Message Date
Antoine Prieels f3b5bf6b3f [FIX] hw_drivers: Lost IoT events
Events coming from the IoT Box were lost in two cases:

1. Create a listener for device 1
2. Send an action to device 1
--> If the action arrives before the listener the event is never sent
to the DB

1. Setup up two listeners for devices 1 & 2
2. After a few seconds, send two consecutive actions to devices 1 & 2
--> Everytime a longpolling request arrives, a new threading.Event
object is created. The first action sets the event, then, before the
new longpolling request arrives, the second action sets the same event,
which is overwritten once the new longpolling request arrives.

We now maintain a list of events, and when a longpolling request
arrives on the IoT Box, we make sure that all events that occured in
the last 5 seconds were received by the DB. If no events were pending,
we wait 50 seconds to check if a new one pops up.

Taskid: 2320958
X-original-commit: e3260712ce96a8d81bf807574c334d92c37c6ae4
2020-11-16 16:01:21 +00:00
Antoine Prieels 72681dc53f [IMP] hw_*,point_of_sale: Cleaning IoT Box
- Split driver.py to multiple files
- Remove hw_proxy module as most of its routes were not used and
  move remaingin routes to a controller in hw_drivers
- Add missing coding and license lines at the beginning of files
- Reorder imports and remove unused ones
- Rename device_id to device_identifier for clarity
- Rename screen to display for consistency
- Other minors improvements

Taskid: 1973956
X-original-commit: 841c016913a87133bf7257c62ae5f6bf7d99e06d
2020-08-25 11:24:56 +00:00
Antoine Prieels c5e1af7a35 [FIX] hw_drivers: IoT Box connection
In Chrome 84, mixed content will be completely blocked for security
reasons ([see blog](https://blog.chromium.org/2019/10/no-more-mixed-messages-about-https.html))
Other browsers will probably follow in the next months.

As IoT Boxes don't have a valid certificate before connecting to a DB,
we used mixed passive content to communicate with the boxes.
This won't be possible anymore, and we have no possible way to
communicate directly from the browser to the box.

- When an IoT Box boots without registered DB, a unique code will be
 created with a validity of 5 minutes.
- This code will be shown on the customer display and printed on the
 status ticket.
- The box will call a route on odoo.com and a record will be created
 in odoo.com with the unique code.
- The user will have to enter the code manually in his DB to connect
 to the IoT Box, the DB will then contact odoo.com to search for a
 record containing the unique code. If it's found, the
 `openerp.enterprise.database` will be added to the record.
- The box will then query odoo.com at regular intervals (10 seconds)
 to check if a DB is linked to the code.

closes odoo/odoo#53623

Taskid: 2246535
X-original-commit: c55f12e32598a713105f3c049ac053e46ba15bb2
Related: odoo/enterprise#11421
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-06-25 06:08:33 +00:00
lejeune quentin 9553871312 [FIX] hw_drivers: Restart Odoo after IoT has connected
When the route '/hw_drivers/box/connect' is called to connect an IoT Box to a DB,
the checkout on the branch of the DB is not performed and incompatibility can occur.

With this fix we relaunch Odoo via a parallel thread in order to be able to respond to the request...

closes odoo/odoo#52513

X-original-commit: 9aca7c464cef492c495a0c72d870b7075187dc63
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-06-05 14:00:06 +00:00
Antoine Prieels e5d25e98b4 [IMP] hw_drivers: Give a priority order to drivers
Previously, we tested the `supported` methods of all drivers
sequentially in alphabetical order of file names. If you wanted to
extend a driver, the `supported` method of your driver could never be
tested if the one of its parent was tested first.

We've now added a priority order to drivers so that by default the
extending driver will always be tested before the extended driver.

You can still do something similar to what `is_tested_last` did by
manually setting the priority of a driver to 0.

Ex: The way barcode scanners is really similar to keyboards, but still
requires a few modifications in the driver. We couldn't extend the
keyboard driver easily because the supported method of barcode scanners
had to be more strict than the one of keyboards. If the
KeyboardUSBDriver was tested first, scanners were recognized as
keyboard and didn't have all the specific features of scanners.

TaskID: 2082282
2020-05-13 13:26:05 +00:00
Antoine Prieels e1c52c936d [IMP] hw_drivers: Easier detection of new devices
Until now, to detect new types of devices on the IoT Box, we had to
modify driver.py. If partners wanted to connect a new type of device,
they had to modify directly the files on the Box, meaning that after
each new build they had to re-apply all their modifications.

We remove the loops that detected the connected devices and replace
them by `Interfaces`. All interfaces will be loaded from the connected
Odoo instance with the corresponding drivers.

TaskID: 2082282
2020-05-13 13:26:05 +00:00
Antoine Prieels 312a6d5b03 [FIX] hw_drivers: typo in ExceptionLogger
Exceptions were not logged correctly due to a typo in ExceptionLogger.

closes odoo/odoo#51191

X-original-commit: 9ac2ad249bddc631de9a9d587058d6109918f584
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-05-13 15:12:41 +00:00
Antoine Prieels d2b172becd [FIX] hw_drivers: No devices after monitor disconnect
Steps to reproduce:
 - Start the IoT Box with a monitor plugged in
 - Unplug the monitor
 - Restart the Odoo service (i.e. connect the IoT Box to a DB)
 - No devices are detected

The problem came from the fact that `tvservice -l` and `tvservice -n`
have different behaviors when a monitor is disconnected:
 - `tvservice -l` still says that a device is attached
 - `tvservice -n` cannot detect the name of the device so it logs an
error to stderr but still has a return value of 0 so we read an empty
string from stdout.

The `get_connected_displays` function raised an exception because the
format of the returned string was not the one we excepted. The other
loops were then not started and no devices at all were detected.

closes odoo/odoo#50839

X-original-commit: ab6ec2ab6d30a86f9741da4b1986831772004d91
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-05-07 10:50:09 +00:00
Antoine Prieels 005eda5c34 [IMP] hw_drivers: Download IoT Box log file
Add a button to download the IoT Box log file from the Box form view in
the connected Odoo DB.

closes odoo/odoo#41093

Taskid: 1943418
Related: odoo/enterprise#6961
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-04-29 11:09:39 +00:00
Antoine Prieels 6413ef6955 [REV] hw_drivers, hw_posbox_homepage, pos: Remove MPD
This reverts commit 9d43308a8f6b521d3d18f7fc472303f58f56a0c3.

No one should be using MPD in production at the moment but
we'll still leave it in the buiold of the Box, just to be sure.

X-original-commit: 129101815d5846d5b53148546b19bdd791f22aac
2020-03-23 09:29:52 +00:00
Antoine Prieels a200c6ddf8 [REM] hw_drivers, hw_posbox_homepage, pos: Remove MPD
Remove the MPD server and Six configuration from the IoT Box.
MPD will be replaced by TIM, which doesn't require the IoT Box.

closes odoo/odoo#46424

Taskid: 2188566
X-original-commit: 9d43308a8f6b521d3d18f7fc472303f58f56a0c3
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2020-02-27 11:17:15 +00:00
lejeune quentin 314410458b [FIX] hw_drivers: In IoT update route list after loading driver
For update correctly the route list of IoT after loading driver
we need set 'http.addons_manifest' to a empty json

Linked to 97c09e1c77284836c7c46b4e70d4f12eb48ce91b

Reboot not needed after a update

Linked to b77486753b7ae220a531ee09c529fb5eb944b0e2
Linked to 181a62cb57e143611ca1fbf0779cfd041d2a3cf8

closes odoo/odoo#46386

X-original-commit: 87b127efed97c1f6fad18d6ee6b5924a9b2c70f2
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-02-26 17:32:05 +00:00
lejeune quentin fff277a4a7 [FIX] hw_drivers: Do not send request if the IoT is in access point
If IoT Box is in access point mode and a server is configured
the box try to reach the server.
But in access point mode all requests are redirected to the box

So now before return True in function 'get_odoo_server_url'
we verify if the service 'hostapd' is inactive

closes odoo/odoo#46141

X-original-commit: 365f0e384630bad16e0872d2307702fca5a4e295
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2020-02-24 16:03:12 +00:00
Pierre Masereel d66553cafd [FIX] hw_drivers: reload routes after loading drivers
closes odoo/odoo#44263

X-original-commit: 97c09e1c77284836c7c46b4e70d4f12eb48ce91b
Signed-off-by: pimodoo <pimodoo@users.noreply.github.com>
2020-01-30 10:02:25 +00:00
Antoine Prieels 6e07e0b4b0 [FIX] hw_drivers: Use branch of connected DB
Preivously, the code of the IoT Box was retrieved from the branch that
was used during the build but the drivers were retrieved from the
connected Odoo DB. Both could be in different versions, which forced
used to make old drivers compatible with the new Box or new drivers
compatible with old versions of the Box.

All of this made it quite hard to modify the existing code, even for
new versions of the Box in master.

When connecting the IoT Box to an Odoo DB, we now retrieve the version
of Odoo that is used and checkout the Box to this branch. This means
that we can now modify the code of the Box in master without having to
worry about users using the latest build with older DBs.

Taskid: 2120749
X-original-commit: 6af5d669593a4f431d14fce08c6151932f97da82
2019-11-26 12:31:37 +00:00
lejeune quentin 4bb7fa19f1 [FIX] hw_drivers: Fix detction method for printer
Actual IoT Box not detect correctly Epson TM-T88v.
Now we can detect printer even if name is 'Unknow'

closes odoo/odoo#41563

Taskid: 2153108
X-original-commit: 4c7a1d7a9ba2ad0fbdd92b3a73b0d6294cb6e4a3
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-12-09 09:56:47 +00:00
Antoine Prieels 6f645925a4 [IMP] hw_drivers: Clean MPD manager in driver.py
We clean the code for the MPDManager by removing useless lines and
simplifying the way we run the MPD server.

closes odoo/odoo#40892

Related: odoo/enterprise#6892
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-11-28 14:04:33 +00:00
Antoine Prieels 2e34d456e8 [FIX] hw_drivers: Redirect exceptions to log file
Exceptions were logged to stderr so we couldn't see them when Odoo was
running as a service on the IoT Box. We now redirect stderr to the logger
to see track errors in the log file too.

closes odoo/odoo#41028

Taskid: 2146835
X-original-commit: 54a1919cbc37f5832ce110605c29b222c7a5bfe9
Signed-off-by: Antoine Prieëls <aprieels@users.noreply.github.com>
2019-11-28 08:32:28 +00:00
Antoine Prieels ad846fcee5 [IMP] iot: Dual screen support for RPI4
We now support the RPI4 which has 2 micro-HDMI outputs, while the
prvious driver only supported one display. We add support for a second
display.

Taskid: 2123511
X-original-commit: 5886c3a864c990fcd7b852baafab752e7da90494
2019-11-27 14:15:18 +00:00
Antoine Prieels 37bdade9a2 [IMP] hw_drivers: Add manufacturer on IoT Devices
Add the possibility to set a manufacturer on IoT Devices.

closes odoo/odoo#36748

Taskid: 2062227
Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-09-19 06:01:08 +00:00
Antoine Prieels 79ad17a7ff [FIX] hw_drivers: No connected display
In the latest version of Raspbian, when no display is connected to the
HDMI port, "tvservice -n" finds a display named "Unk-Composite dis".
Therefore, the `distant_display` was not created.
2019-09-13 09:00:50 +00:00
Antoine Prieels f03026a3d7 [REF] hw_{drivers,screen}: Convert hw_screen into an IoT Driver
Move all the logic that was inside hw_screen into an IoT Driver
in order to have consistency between devices.

TaskID: 1933834
2019-09-04 13:08:10 +00:00
Antoine Prieels 16c32f0c25 [FIX] hw_drivers: Kill MPD server on start
The MPD server was not correctly killed when the IoTBox started without
six payment terminal configured. A warning was displayed.

closes odoo/odoo#36415

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-09-04 11:58:48 +00:00
Antoine Prieels 2a7454ea6c [IMP] hw_{drivers, posbox_homepage}: Automatic load of drivers
Automatically load the IoT Drivers when Odoo starts on the IoT Box or
when the connection to the Odoo instance is done.

Allow to deactivate the automatic load to avoid overriding
modifications made on the Box.

TaskID: 2009683
2019-09-03 13:53:19 +00:00
Antoine Prieels 8449a7c607 [FIX] hw_drivers: Kill eftdvs w/o Six terminal
If no Six Payment terminal is configured, kill eftdvs if it is running.

When removing the configuration for a Six payment terminal, we just
removed the file with the configuration but we didn't stop eftdvs. The
terminal the nstayed connected to this Box even after removing the
configuration, blocking the connection to another terminal.
2019-08-29 14:09:24 +00:00
lejeune quentin 8373168bc5 [FIX] hw_drivers: Fix IoT Socket Manager
With this commit we catch OS Error when want use a new socket

closes odoo/odoo#36019

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-08-23 11:42:00 +00:00
lejeune quentin 2af13429cf [ADD] iot: Load a true certificate on IoT Box
With this commit we add the possibility to save the db_uuid and enterprise_code on the IoT Box.
We check the current SSL certificate and if it is not authenticated or not up to date
we send a request to 'https://www.odoo.com/odoo-enterprise/iot/x509'
with the db_uuid and enterprise_code to get the certificate, key, and domain associated with the client.
The IoT Box will be accessible in HTTPS according to the following domain:

https://<ip-with-dashes>.<sub-hash>.odoo-iot.com

<ip-with-dashes> being the ip address with dashes
<sub-hash> being a subdomain assigned by Odoo to a customer

Task: 1931770
2019-08-23 12:21:03 +02:00
lejeune quentin 84de7cbcb6 [ADD] iot: Improve usage of helpers in IoT Box
With this commit we move the helpers to a separate file for
easier access from the IoT Box
2019-08-23 12:21:02 +02:00
Robot Odoo e9dbf45b3b [IMP] pos, hw_drivers, hw_posbox_homepage: Six terminals
Add support for Six payment terminals.

TaskId: 1932416

Linked to odoo/enterprise#4435

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

closes odoo/odoo#33673

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-08-14 11:27:10 +02:00
Antoine Prieels 4e649a8ca9 [REF] hw_{driver, scanner}: Barcode scanners as IoT Devices
Barcode scanners are now part of KeyboardUSBDriver. We also add
the possibility to change the keyboard/scanner layout from an
action. The list of available layout can be retrieved with a new
route.

`hw_scanner` has been removed. Backward compatibility is ensured
because the name of the route that is now used in community is the
same that was used previously.

TaskID: 1939455
2019-08-13 15:35:38 +02:00
Antoine Prieels b62d98e9a8 [IMP] hw_drivers: Config file for eftdvs
Add a config file for eftdvs. This was requested during the
certification to allow user to change the config of the
terminal.

TaskID: 1932416
2019-08-12 08:16:04 +02:00
Antoine Prieels dc449a4ae5 [IMP] hw_drivers: support Six payment terminals
Add MPDManager to driver.py to keep a list of connected terminals
up to date.

Add the files needed to communicate with the payment terminals:
eftdvs --> MPD server that needs to run on the IoTBox
eftapi.so --> Library to connect Odoo to the MPD server

TaskId: 1932416
2019-08-12 08:16:04 +02:00
Antoine Prieels 03b2f7b77d [REF] pos: Replace hw_escpos by PrinterDriver
ESCPOS printers are now supported as IoT Devices, just like any other
printer. We now transform the receipts to JPGs, transform these JPGs
into ESCPOS commands and send them via Cups, adding support for network
printers. Since we now print images, we can now print special
characters and therefore add support for other languages such as
Arabic.

The JPG is generated in the browser, with the help of html2canvas.

`hw_escpos` is left untouched to allow backward compatibility and
should be removed when v12 is no longer supported.

In the PoS, all the code for printing has been moved from ProxyDevice
to a separated JS file.

TaskID: 1939455
2019-08-08 11:53:37 +00:00
pha-odoo 28c2e642cb [FIX] iot: bluetooth work with serial
Using path such as '/dev/ttyUSB0' to connect to a serial port
makes it impossible to use the bluetooth.

We now use the locations in '/dev/serial/by-path' to connect to serial port,
which does not affect bluetooth connections

closes odoo/odoo#35302

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-07-31 10:54:46 +00:00
pha-odoo 120f890ecf [FIX] iot: remove check for abstract classes
The check for abstract driver classes results in some errors being logged on the iot box.
Since this check is not essential at this point, it was removed and will be reintroduced later
if needed.

closes odoo/odoo#35014

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-07-19 11:55:01 +00:00
pha-odoo c4aade63fd [IMP] iot: add iot serial drivers
This commit adds a base serial and a base serial scale iot drivers,
as well as drivers extending them for the two previously supported scales
(ADAM EQUIPMENT AZEXTRA and TOLEDO 8217).

Since just adding the new drivers creates a race condition
between the old drivers and the new, the old drivers need to be removed.

The IoT scale drivers need to be backward compatible and compatible with the community version,
so client using an IoT box with those versions can still connect a scale to the PoS.

Task: 1892412
2019-07-17 08:02:13 +02:00
Martin Trigaux 5d57e1862f [MERGE] Forward port of saas-12.4 to master up to beba36416f
closes odoo/odoo#34924

Signed-off-by: Martin Trigaux (mat) <mat@odoo.com>
2019-07-16 15:45:24 +00:00
Martin Trigaux beba36416f [MERGE] Forward port of saas-12.3 to saas-12.4 up to 40421be73c 2019-07-16 16:36:40 +02:00
lejeune quentin a8004118b2 [IMP] point_of_sale: Updating the date of the IoT Box
before this commit the date of the IoT Box did not update.
With this commit we restart the service timesyncd on the IoT box

Task: 2034930

closes odoo/odoo#34789

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-07-11 13:54:53 +00:00
lejeune quentin 3c66ed1405 [FIX] hw_drivers: Avoid duplicates identifiers in devices
Before this commit the identifier integrate the BUS and port to identifiate USB devices
Now we check if there are duplicates devices before increment the identifier

For other loop we add identifier in the iot_device object

task: 1963500

closes odoo/odoo#32737

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-07-09 08:08:16 +00:00
lejeune quentin f5676fabea [IMP] hw_driver: inform the odoo instance of connected and disconnected devices
Before this commit, we only sent the list of connected devices to
the odoo instance (thanks to `self.send_alldevices`) when a device
is newly connected. Now, we also send this list when a device is
disconnected. We also try to call this method once if multiple devices
are connected/disconnected during an iteration.

task-id 1939338

closes odoo/odoo#32678

Signed-off-by: Quentin Lejeune (qle) <qle@odoo.com>
2019-07-03 08:14:28 +00:00
lejeune quentin ccb2835ccc [IMP] hw_drivers: Adds the ability to listen to a port
With this commit it is now possible for the IoT Box
to listen on a specific port of the box to interact
with a device via TCP / IP.

We use the library 'socket' to listen on port 9000
and if a request comes on this port we create an IoT Device
2019-05-29 15:49:03 +02:00
lejeune quentin ae35e16093 [IMP] IoT : Automatic registration of the IoT Box in HTTPS without certificate
When we are on HTTPS and we want to connect a box with the scan
we need to accept manually the certificate of the box.
With this commit we don't need to accept manually the certificate.
We don't have problem of mixed content if we use the onload method of Image object
So we load a image and put on parameter the token of the odoo DB to make a connection.
2019-04-02 15:53:02 +02:00
lejeune quentin 61c824764c [FIX] IoT : Variable name correction
This commit replace "data" by "iot_box" which is more representative
of the values it contains
2019-04-02 15:53:02 +02:00
lejeune quentin 1f845e9110 [IMP] IoT : IoT refactoring - With longpolling
Improve the implementation of IoT.
Allow both-direction communication between iot box and devices.

Now a device can send its value / status as soon as it changes. Not only when he receives a request.

Now the box have only 3 routes:

/hw_drivers/action
parameter: session_id, device_id, data
used to ask at a device to make a action (take picture, make print, ect...)

/hw_drivers/event
parameter: listener
listener is a dict where you have the session_id and a list of device_id to listen
this route wait to answer that we call device_changed for a device_id with data or value

/hw_drivers/box/connect
parameter: token
used to register the box to a Odoo database
token contain the url of Odoo database and a unique number that allow the IoT Box
to connect box in the hour

task : 1906910
2019-04-02 15:53:01 +02:00
lejeune quentin c516cb90af [ADD] IoT : Add printer compatibility with the LPD protocol
closes odoo/odoo#29875
2019-01-15 15:23:24 +00:00
lejeune quentin e5c62987b4 [FIX] IoT : HTTPS disable certificate verification by URLLIB3 2019-01-15 15:23:24 +00:00
lejeune quentin e7993f2faa [IMP] IoT : Allow to configure CUPS server
We can modify printers or CUPS configuration
These modifications will be save on IoT Box
2019-01-15 15:23:24 +00:00
Josse Colpaert 3d9ebb11b6 [ADD] hw_drivers: drivers management module for the IoT Box
- Routes to get device/driver statuses from the browser
- Framework for managing and downloading drivers for devices
connected to the IoT Box
- Automatic detection of printers and cameras in the network
- Built-in detection for USB and Bluetooth LE devices and checking
if a driver matches the device
- Authentication of the box into Odoo
- Inform Odoo of the connected devices and giving them a unique
identifier so they can be called from the browser

Thanks to qle, specially for fswebcam and cups
2018-09-25 23:01:40 +02:00