add missing payment providers and iot modules for 19.0

Add 19 payment provider modules needed by the sale module:
payment_adyen, payment_aps, payment_asiapay, payment_authorize,
payment_buckaroo, payment_demo, payment_dpo, payment_flutterwave,
payment_iyzico, payment_mercado_pago, payment_mollie, payment_nuvei,
payment_paymob, payment_paypal, payment_razorpay, payment_redsys,
payment_stripe, payment_worldline, payment_xendit

Add 3 IoT modules needed for point_of_sale:
iot_base, iot_box_image, iot_drivers

Note: Stripe test API keys replaced with placeholders.

🤖 assisted by claude
This commit is contained in:
Ernad Husremovic 2026-03-09 15:44:59 +01:00
parent 3037cab43e
commit aee3ee8bf7
1472 changed files with 194608 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.
{
'name': 'IoT Base',
'version': '1.0',
'category': 'Hidden',
'description': """
Base tools required by all IoT related modules.
===============================================
""",
'depends': ['web'],
'installable': True,
'author': 'Odoo S.A.',
'license': 'LGPL-3',
'assets': {
'web.assets_backend': [
'iot_base/static/src/network_utils/*',
'iot_base/static/src/device_controller.js',
],
},
}

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
# "Noemi Pla Garcia (nopl)" <nopl@odoo.com>, 2025.
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-24 19:23+0000\n"
"Last-Translator: \"Noemi Pla Garcia (nopl)\" <nopl@odoo.com>\n"
"Language-Team: Catalan <https://translate.odoo.com/projects/odoo-19/iot_base/"
"ca/>\n"
"Language: ca\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.12.2\n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr "Ha fallat la connexió a la IoT Box"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
# "Patricia Gutiérrez (pagc)" <pagc@odoo.com>, 2025.
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-18 19:00+0000\n"
"Last-Translator: \"Patricia Gutiérrez (pagc)\" <pagc@odoo.com>\n"
"Language-Team: Spanish (Latin America) <https://translate.odoo.com/projects/"
"odoo-19/iot_base/es_419/>\n"
"Language: es_419\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.12.2\n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr "Falló la conexión a la caja IoT"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr "No fue posible contactar a la caja IoT en %s"

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
# "Maitê Dietze (madi)" <madi@odoo.com>, 2025.
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-24 19:23+0000\n"
"Last-Translator: \"Maitê Dietze (madi)\" <madi@odoo.com>\n"
"Language-Team: Portuguese (Brazil) <https://translate.odoo.com/projects/"
"odoo-19/iot_base/pt_BR/>\n"
"Language: pt_BR\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: nplurals=2; plural=n > 1;\n"
"X-Generator: Weblate 5.12.2\n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr "Conexão ao IoT Box falhou"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr "Não foi possível contatar a IoT Box em %s"

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,28 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 19.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-09-11 13:57+0000\n"
"PO-Revision-Date: 2025-09-11 13:57+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Plural-Forms: \n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr ""
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,32 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * iot_base
#
# Translators:
# Wil Odoo, 2025
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server saas~18.3\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-05-09 20:36+0000\n"
"PO-Revision-Date: 2025-05-17 15:02+0000\n"
"Last-Translator: Wil Odoo, 2025\n"
"Language-Team: Chinese (Taiwan) (https://app.transifex.com/odoo/teams/41243/zh_TW/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: \n"
"Language: zh_TW\n"
"Plural-Forms: nplurals=1; plural=0;\n"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Connection to IoT Box failed"
msgstr "連接到IoT Box失敗"
#. module: iot_base
#. odoo-javascript
#: code:addons/iot_base/static/src/network_utils/longpolling.js:0
msgid "Failed to reach IoT Box at %s"
msgstr ""

View file

@ -0,0 +1,7 @@
declare module "services" {
import { iotLongpollingService } from "@iot_base/network_utils/longpolling";
export interface Services {
iot_longpolling: typeof iotLongpollingService
}
}

View file

@ -0,0 +1,40 @@
import { uniqueId } from "@web/core/utils/functions";
/**
* Used to communicate to the iot devices.
*/
export class DeviceController {
/**
* @param {import("@iot_base/network_utils/longpolling").IoTLongpolling} iotLongpolling
* @param {{ iot_ip: string, identifier: string, iot_id: Object, manual_measurement: string }} deviceInfo - Representation of an iot device
*/
constructor(iotLongpolling, deviceInfo) {
this.id = uniqueId('listener-');
this.iotIp = deviceInfo.iot_ip;
this.identifier = deviceInfo.identifier;
this.iotId = deviceInfo.iot_id?.id; // if class is instantiated without providing the full device record, iot_id will be undefined
this.manual_measurement = deviceInfo.manual_measurement;
this.iotLongpolling = iotLongpolling;
}
/**
* Send an action to the device.
* @param data - action to send to the device
* @param fallback - if true, no notification will be displayed on fail
*/
action(data, fallback = false) {
return this.iotLongpolling.action(this.iotIp, this.identifier, data, fallback);
}
/**
* Add a listener to the device.
* @param callback - function to call when the listener is triggered
* @param fallback - if true, no notification will be displayed on fail
*/
addListener(callback, fallback = true) {
return this.iotLongpolling.addListener(this.iotIp, [this.identifier], this.id, callback, fallback);
}
removeListener() {
return this.iotLongpolling.removeListener(this.iotIp, this.identifier, this.id);
}
}

View file

@ -0,0 +1,39 @@
import { browser } from "@web/core/browser/browser";
/**
* Format the endpoint to send the request to
* Used to ensure the request is sent with the same protocol as the current page
* (e.g. if the current page is HTTPS, the request will be sent to the IoT Box using HTTPS)
* @param ip IP Address of the IoT Box
* @param route Route to send the request to
* @returns {string} The formatted endpoint
*/
export function formatEndpoint(ip, route) {
const url = new URL(window.location.href);
url.search = "";
url.hostname = ip;
url.pathname = route;
if (url.port) url.port = "8069";
return url.toString();
}
/**
* Send a POST request to the IoT Box
* @param ip IP Address of the IoT Box
* @param route Endpoint to send the request to
* @param params Parameters to send with the request (optional)
* @param timeout Time before the request times out (default: 6000ms)
* @param headers HTTP headers to send with the request (optional)
* @returns {Promise<any>}
*/
export async function post(ip, route, params = {}, timeout = 6000, headers = {}) {
const endpoint = formatEndpoint(ip, route);
const response = await browser.fetch(endpoint, {
body: JSON.stringify({'params': params}),
method: "POST",
headers: {"Content-Type": "application/json", ...headers},
signal: AbortSignal.timeout(timeout),
});
return response.json();
}

View file

@ -0,0 +1,229 @@
import { registry } from '@web/core/registry';
import { post } from '@iot_base/network_utils/http';
import { uuid } from "@web/core/utils/strings";
import { _t } from '@web/core/l10n/translation';
export class IoTLongpolling {
static serviceDependencies = ["notification", "orm"];
actionRoute = '/iot_drivers/action';
pollRoute = '/iot_drivers/event';
rpcDelay = 1500;
maxRpcDelay = 15000;
_retries = 0;
_listeners = {};
constructor() {
this.setup(...arguments);
}
/**
* Setup in addition to constructor to allow patching
*/
setup({ notification, orm }) {
this._session_id = uuid();
this._delayedStartPolling(this.rpcDelay);
this.notification = notification;
this.orm = orm;
}
/**
* Add a device_identifier to listeners[iot_ip] and restart polling
*
* @param {string} iot_ip
* @param {Array} devices list of devices
* @param {string} listener_id
* @param {boolean} fallback if true, no notification will be displayed on fail
* @param {Callback} callback
*/
async addListener(iot_ip, devices, listener_id, callback, fallback = true) {
if (!this._listeners[iot_ip]) {
this._listeners[iot_ip] = {
last_event: 0,
devices: {},
session_id: this._session_id,
rpc: false,
};
}
for (const device of devices) {
this._listeners[iot_ip].devices[device] = {
listener_id: listener_id,
device_identifier: device,
callback: callback,
};
}
this.stopPolling(iot_ip);
this.startPolling(iot_ip, fallback);
}
/**
* Stop listening to iot device with id `device_identifier`
* @param {string} iot_ip
* @param {string} device_identifier
* @param {string} listener_id
*/
removeListener(iot_ip, device_identifier, listener_id) {
const device = this._listeners[iot_ip].devices[device_identifier];
if (device && device.listener_id === listener_id) {
delete this._listeners[iot_ip].devices[device_identifier];
}
}
/**
* Execute an action on device_identifier
* Action depends on the driver that supports the device
*
* @param {string} iot_ip
* @param {string} device_identifier
* @param {Object} data contains the information needed to perform an action on this device_identifier
* @param {boolean} fallback if true, no notification will be displayed on fail
* @param {string} route endpoint to call on the IoT Box (default: /iot_drivers/action)
*/
action(iot_ip, device_identifier, data, fallback = false, route = null) {
this.protocol = window.location.protocol;
const body = {
session_id: this._session_id,
device_identifier: device_identifier,
data,
};
return this._rpcIoT(iot_ip, route || this.actionRoute, body, undefined, fallback);
}
/**
* Start a long polling, i.e. it continually opens a long poll
* connection as long as it is not stopped (@see `stopPolling`)
* @param {string} iot_ip
* @param {boolean} fallback if true, no notification will be displayed on fail
*/
startPolling(iot_ip, fallback = true) {
if (iot_ip) {
if (!this._listeners[iot_ip].rpc) {
this._poll(iot_ip, fallback);
}
} else {
const self = this;
Object.keys(this._listeners).forEach((ip) => {
self.startPolling(ip);
});
}
}
/**
* Stops any started long polling
*
* Aborts a pending long-poll so that we immediately remove ourselves
* from listening on notifications on this channel.
*/
stopPolling(iot_ip) {
if (this._listeners[iot_ip].rpc) {
this._listeners[iot_ip].rpc.abort();
this._listeners[iot_ip].rpc = false;
}
}
_delayedStartPolling(delay) {
// ``fallback: true`` to avoid error notification on longpolling setup
setTimeout(() => this.startPolling(null, true), delay);
}
/**
* Execute an RPC to the box
* Used to do both polling or action
*
* @param {string} iot_ip IP of the IoT Box
* @param {string} route endpoint to call on the IoT Box
* @param {Object} params information needed to perform an action or the listener for the polling
* @param {number} timeout time before the request times out (undefined to use default timeout from http.js)
* @param {boolean} fallback if true, no notification will be displayed on fail
* @param {Object} headers headers to send with the request (optional, allows patching)
*/
async _rpcIoT(iot_ip, route, params, timeout = undefined, fallback = false, headers = undefined) {
try {
const result = await post(iot_ip, route, params, timeout, headers);
if (this._listeners[iot_ip] && route === this.pollRoute) {
this._listeners[iot_ip].rpc = result;
return this._listeners[iot_ip].rpc;
} else {
return result;
}
} catch {
if (!fallback) {
this._doWarnFail(iot_ip);
}
throw new Error("Longpolling action failed");
}
}
/**
* Make a poll request to an IoT Box
*
* @param {string} iot_ip
* @param {boolean} fallback if true, no notification will be displayed on fail
*/
_poll(iot_ip, fallback = true) {
const listener = this._listeners[iot_ip];
// The backend has a maximum cycle time of 50 seconds so give +10 seconds
this._rpcIoT(iot_ip, this.pollRoute, { listener: listener }, 60000, fallback).then(
(result) => {
this._retries = 0;
this._listeners[iot_ip].rpc = false;
const remainingDevices = Object.keys(this._listeners[iot_ip].devices || {});
if (result.result) {
if (this._session_id === result.result.session_id) {
this._onSuccess(iot_ip, result.result);
}
} else if (remainingDevices.length > 0) {
this._poll(iot_ip);
}
},
(e) => {
if (e.name === "TimeoutError") {
this._onError();
}
}
);
}
_onSuccess(iot_ip, result) {
this._listeners[iot_ip].last_event = result.time;
const devices = this._listeners[iot_ip].devices;
devices[result.device_identifier]?.callback(result);
if (Object.keys(devices || {}).length > 0) {
this._poll(iot_ip);
}
this._retries = 0;
}
_onError() {
this._retries++;
this._delayedStartPolling(Math.min(this.rpcDelay * this._retries, this.maxRpcDelay));
}
/**
* This method is needed in _poll.
* @param {string} url
*/
_doWarnFail(url) {
this.notification.add(
_t("Failed to reach IoT Box at %s", url),
{
title: _t("Connection to IoT Box failed"),
type: "danger",
}
);
}
}
export const iotLongpollingService = {
dependencies: IoTLongpolling.serviceDependencies,
start(_, deps) {
return new IoTLongpolling(deps);
},
};
registry.category('services').add('iot_longpolling', iotLongpollingService);