From patchwork Tue Aug 30 16:22:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Storm, Christian" X-Patchwork-Id: 1671936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=googlegroups.com (client-ip=2a00:1450:4864:20::33e; helo=mail-wm1-x33e.google.com; envelope-from=swupdate+bncbdd6bwv65qpbbhpsxcmamgqecikcdpi@googlegroups.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.a=rsa-sha256 header.s=20210112 header.b=slINvJzW; dkim-atps=neutral Received: from mail-wm1-x33e.google.com (mail-wm1-x33e.google.com [IPv6:2a00:1450:4864:20::33e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4MHCHh5Vhtz1ynb for ; Wed, 31 Aug 2022 02:21:52 +1000 (AEST) Received: by mail-wm1-x33e.google.com with SMTP id r83-20020a1c4456000000b003a7b679981csf5889850wma.6 for ; Tue, 30 Aug 2022 09:21:52 -0700 (PDT) ARC-Seal: i=3; a=rsa-sha256; t=1661876509; cv=pass; d=google.com; s=arc-20160816; b=pt3ZYpbJxyjNakl0m3vDotNh/uxvHW7RhYqEYjhJKHqvbeLAfCfjSQ9pYLK+RCrl4g PB4TGqvvHTI9LvvYdgmwpJCAPiKuUe0lpUPoAk9WHTPCcp/CVn/uHgYLqI79WHf6M3DE 3Iad93oAkDT7Q2qLNw2lphBi8cd1BzKDvcLdvFdcO+8+jGlIXEfbGfuGbptLsmogtRf0 CMtIDFeKmajzXcVnFjmFad5x4/6QFfYMSb9ziHfhZQuVKnBwdetE/mzmxikHzNhhOOtl sq/Rz7qKYMdvgD9n3+gHFjaRyJC30BKaQu3i4H6l8mMogGQcZe4EWNsg/am3JIjqPkZM wCKA== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:dkim-signature; bh=TxFnIdLU8zElLDAcpsQ1IGcvp63VqDq9dQEUSRBf0tQ=; b=UCXv/8tZ0Imx8c45+23KkQemvOlS5HdECZmDc3zn8jLlItaohqKJ4N25G/8Cj5lHJX RZRCFmgJ6+tuhLR4+otz4d0hcHGYXx5x1dDHb+9xg3m8WDl5Ie6ppai0Gif0QQ5f6jjc Y/4t4gF5EWoDwaH/o2/7zlNltuKpTg5qifkIK22PUZJIe8MwOD2L5dt5hV/ehw3mfwHu jQhgssBIpZlgD/gC0qDuWR9FC/USAgMQuOW0OPyDjAvACN5DQapItQpTMIj5Yb+5Sfbu oVBptxfrceykUjM5u0mcKYJ8qt76jSgKB6aPs0lpfl76TRne5MGT5XOHHzsvWWd0a+47 aPVA== ARC-Authentication-Results: i=3; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=yHTgmYrN; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 40.107.20.77 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:sender:from:to:cc; bh=TxFnIdLU8zElLDAcpsQ1IGcvp63VqDq9dQEUSRBf0tQ=; b=slINvJzWYVxt+XS5JetB8XTIiXTtjxlFLe/LG4cA6R+Wb6EiKXjBiyr0cTatjm84ih fhjlq+XCFT45aKbu/upMa2zaOmsib6kqeZITKx/qtdjRC95gFU+f3J4G2dkk5goMxqWc 1Y9Mg+nN59su1tW0IfjWcmGrW5JvoTWoQRVB45dvVImDdafYIaMAZYLJKgB3FuPanCmw rGlFnkZEHzcmR9m5dxsza3Osyz/zEFji+f2DPFWOA1eFx7+0JzVlYTLBPgjBV9LOj3ND SSz8F9c32eSJXHN7SbGmrRyQvfUsXQ4u+k3brs1Ff16HgHYgYmSB159FYeJximSh1Vcg BnBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:sender:from:to:cc; bh=TxFnIdLU8zElLDAcpsQ1IGcvp63VqDq9dQEUSRBf0tQ=; b=hyOMtO5bj0f/+Pu+5qnUueCbsCk6TWzsnRUGL5sjSHSnFJPJ8kRjfi1GsoxtR31Zsk /nRIEvShLWXcSfYpaiNJ+5f9h4rr/kdeQah3RmcFDc1xqhCA9tBZvelUMbtrTN0RP2Aw OBXSTNvT7vgvQ5ExatBNp2qW5BIVoc9PwwijfF6OGKTnDepIafyPakAlry1CKBK/ohiB /paIeDH/vxL5Kh2pZgrasbZaIDuMup7rkGgRGP8rbrzT7HGs5mbiBxLT+5Fvi1mnwXzH u10xPJSP8irfzyymmOX4z3TmxOYqdxSLfWLQyJ9pC6jReQrnOMZ6AaECMR+zBuhYXZxl 7wUQ== Sender: swupdate@googlegroups.com X-Gm-Message-State: ACgBeo2N2ZdxnC5Uw5F38rtM2VKJ1AHBfquFrq9SjBxTaIGoLqOiV+CR 8KZf+Pf6C6hJLiyX9qKh9tI= X-Google-Smtp-Source: AA6agR5oR5qHOr9cvr+U4FD3UHSb3WKHdD/ZYtF7Dq/tZqd6QaFdC8+gAU9JRnyx240J2kcJyXsx+g== X-Received: by 2002:a05:600c:3ac4:b0:3a5:f6e5:1cbc with SMTP id d4-20020a05600c3ac400b003a5f6e51cbcmr9975521wms.92.1661876509730; Tue, 30 Aug 2022 09:21:49 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a5d:4848:0:b0:225:58db:7886 with SMTP id n8-20020a5d4848000000b0022558db7886ls7256707wrs.1.-pod-prod-gmail; Tue, 30 Aug 2022 09:21:48 -0700 (PDT) X-Received: by 2002:a05:6000:1568:b0:226:e2d0:abcb with SMTP id 8-20020a056000156800b00226e2d0abcbmr2599705wrz.456.1661876508484; Tue, 30 Aug 2022 09:21:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1661876508; cv=pass; d=google.com; s=arc-20160816; b=HKo3xsnivqUGdpBLxBy2ykU0bZJ/OmZCX+hfeobBhFuWrs898s7vudVu6hKqOJfcLX 2ZQZEGTNo8gdvf6UJQ4p0TpUNm73QfxXMF03a41BOFPRYOUK+AGnV2xN9TdS8HSyGfJa 0TGmht2FpiZWp6Pgdiuh8aC331qI4w5tWUvmWbH4MIxEAozMmSP16zd4stQMzyoyRDA1 zIrlqe5ziFsJ1RCElFXpkr9M1pyY9tdaogLkCem1ZBn7ebYisEpUkiC8qp/vAGLwT1oX /FvPgBxAtGtBAOxEDDB+zteBGSPp4X4t6nqc/dUqiCXQciaj8+dGyBlHa8Qftqi/4ko0 7OcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=9PRyG4Yew+gFMWyzh93aLPpJ7dtIaEgURjGCnIDMmOs=; b=lgSwLrbDn0Age2q+yfwyEKkWalXGtm2bH+VCTzl0oB7PeryAYNI9d3NyUOpKzgu22M Y8W8T6esE85lswG3YQV1PVsgEs5arZF2OX39aeeoP3DxxXm5S7wFcpAXUVk3B4U3vzkC raybyxF7DQ8affEgzmT31IlDWsH/cpqIE4ng+/0td3l9vAv2Ed3el++UNn4GqoV+etM0 HL3oKmta5kG64iAsFMW+wes8HvIA7yDTgAdpqZtHRuWU2qgtBaMKW0MYR6rKJM0M+iFy whR074ytTP4idescQ3yClRu39DYQYVwbPmUz6YywyyX/pICGd5CSPn2grr77Z0Gmc7da 9sDg== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=yHTgmYrN; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 40.107.20.77 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2077.outbound.protection.outlook.com. [40.107.20.77]) by gmr-mx.google.com with ESMTPS id i7-20020a5d4387000000b0021e8b3a5ffesi448589wrq.2.2022.08.30.09.21.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Aug 2022 09:21:48 -0700 (PDT) Received-SPF: pass (google.com: domain of christian.storm@siemens.com designates 40.107.20.77 as permitted sender) client-ip=40.107.20.77; ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AyTtHWgX2PuiNOc1ecUY+SGWou+Kxphx0pwfFjDLcohb+/ClaA3GXk4StPHzMaiOf7i3DjDq22+XpMdEX2ocPn4gBBCFfYJU+AfbYIuHYgMDwkKcq64CcyQbMu1uS4HGeJHH1l6pCuwdoPyuUApanPGwUBpWPFtxXkQDavmK7m1f5ZDrJwwsSNOkJJXY35n+fy/ojXrSm5C451x412VPF6aZ72+ZIply55N3AXJpHnJkX8xC5Pzp0m5vjgw0wWjm/8xnxnKawZ0huUmbheElCRJstWNZ21U3XwH5jPklLj++AjfsMGDPDUoGIM0X2vUlA2sFQ+FrUz/qP6l0GjurIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=9PRyG4Yew+gFMWyzh93aLPpJ7dtIaEgURjGCnIDMmOs=; b=A9Sy0XuLQOHBEe2mNwNIZgCmlbP8u0c3J4z3tB/k0UQhweQrnh4A0bdKNryicUb9Rt2a9gVaOCxQ2lue4RujXirY+sQnKgHNzwI8fhw8ikICOf0WJWkvS+e07zVVcc/rh59AmGoMnArZmzCWvGQR1dxK/HijKDOZbPcrJGaIsybY2xxbaixE5Dg6p9Lgbh7nvfPNcGB/PR4GY1pMX1Eu8iTkCAB1/DhSNWUM/gn9qnWI38aJysDOYfqMPw7kUT48LLvvc62P+Th/qIbyR4QTpjaCiDARuA4ieEywh/UHdHImdxl2aIHEeceD0GSYfNXPUIOhV6To7r64lTmjCSpBNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 194.138.21.76) smtp.rcpttodomain=googlegroups.com smtp.mailfrom=siemens.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=siemens.com; dkim=none (message not signed); arc=none Received: from FR0P281CA0061.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:49::16) by AM9PR10MB4072.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:1f7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5566.15; Tue, 30 Aug 2022 16:21:47 +0000 Received: from VE1EUR01FT035.eop-EUR01.prod.protection.outlook.com (2603:10a6:d10:49:cafe::2d) by FR0P281CA0061.outlook.office365.com (2603:10a6:d10:49::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Tue, 30 Aug 2022 16:21:47 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 194.138.21.76) smtp.mailfrom=siemens.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=siemens.com; Received-SPF: Pass (protection.outlook.com: domain of siemens.com designates 194.138.21.76 as permitted sender) receiver=protection.outlook.com; client-ip=194.138.21.76; helo=hybrid.siemens.com; pr=C Received: from hybrid.siemens.com (194.138.21.76) by VE1EUR01FT035.mail.protection.outlook.com (10.152.2.236) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5588.10 via Frontend Transport; Tue, 30 Aug 2022 16:21:46 +0000 Received: from DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) by DEMCHDC8VSA.ad011.siemens.net (194.138.21.76) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.12; Tue, 30 Aug 2022 18:21:45 +0200 Received: from MD1ZFJVC.ad001.siemens.net (139.25.0.117) by DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.9; Tue, 30 Aug 2022 18:21:45 +0200 From: Christian Storm To: CC: Christian Storm Subject: [swupdate] [PATCH 4/5] suricatta/lua: Update General HTTP Server example Date: Tue, 30 Aug 2022 18:22:24 +0200 Message-ID: <20220830162225.42042-4-christian.storm@siemens.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220830162225.42042-1-christian.storm@siemens.com> References: <20220830162225.42042-1-christian.storm@siemens.com> MIME-Version: 1.0 X-Originating-IP: [139.25.0.117] X-ClientProxiedBy: DEMCHDC89XA.ad011.siemens.net (139.25.226.103) To DEMCHDC8A0A.ad011.siemens.net (139.25.226.106) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ad41bc17-9d39-4605-cbee-08da8aa3bc31 X-MS-TrafficTypeDiagnostic: AM9PR10MB4072:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nArL2mqEAPs3Gt3qEZO0BNyUUjpRKFab5malv80/kG3Fti7MouX8+5BQ17k3KifeNBwLauEwjr1J6zy4Oo8GcWpDveMii/0MWnOixsYBZK3Lfb69KsmeZgTvzXtHmBSbrn24SLS7oYuivjHfTwyoe74EjSMbn+u3gQGmmMdxKoITqNW8204gL5mQoAfu6oz0Kghi6E6+vQ1gaXWTsUtYbQdrA+imu0E1zQMCbgzKJ3zeBd2/yHZoOF1vGKLkfnrK9b3a21OmxQNfACl+D2PKlnD/GqtMYjze9kCNpR90MalFYV9/UHDk7wHFtEWvi+StHO9jPboiBUlAojXRhbk2QBGPBS3i/JT+83336A+qTsrd8AUkl63qQB6roJ8fIjHAklITSXZAGPVYUleVmM544uJLGebaR5BCLQrAgCHbR+5BRtd+j2fCoN7dg1ShYgsjIuQ62K0yC/4CYnYWwSO10aj9ltIk586aIHj61COtc+FIsWt0VzywXmaJpCEme6Ksv/PXgf75+KlG3SESDd8t37pN4PuggFctfT983W5on+hUsmsXSUW23+pZ5nMIdIBdfSi1JpLog1l/GoawkP8Zq/x10+/f0u07UNd75xhODY5+GR7n3Gtofhs97eIynVLaxrFp1aUj0/MBzZO4WCDwGlAwj/Q7t80ik9bjo3oV2TFvmdEjJIfCDpGp0srfG4aWcjrigFqD+Dqp0rllFtzU+ayeg7hvHoLG5JQqTNfVpoVQ3zLWIS3KKKK4s18GB1+Ah+s8WK8PfF4pm0ARfS5s/SjsNlcdGHoW89fDzgK8/N5gExQKm7+lgnxUkOFYvIo9 X-Forefront-Antispam-Report: CIP:194.138.21.76;CTRY:DE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:hybrid.siemens.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(346002)(396003)(136003)(39860400002)(376002)(40470700004)(46966006)(36840700001)(82310400005)(40480700001)(36860700001)(356005)(82960400001)(82740400003)(70586007)(4326008)(81166007)(8676002)(41300700001)(5660300002)(478600001)(8936002)(70206006)(6916009)(316002)(40460700003)(1076003)(47076005)(2616005)(16526019)(956004)(83380400001)(2906002)(6666004)(44832011)(186003)(26005)(15650500001)(86362001)(336012)(36756003)(107886003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: siemens.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Aug 2022 16:21:46.7403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ad41bc17-9d39-4605-cbee-08da8aa3bc31 X-MS-Exchange-CrossTenant-Id: 38ae3bcd-9579-4fd4-adda-b42e1495d55a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=38ae3bcd-9579-4fd4-adda-b42e1495d55a;Ip=[194.138.21.76];Helo=[hybrid.siemens.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT035.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR10MB4072 X-Original-Sender: christian.storm@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=selector2 header.b=yHTgmYrN; arc=pass (i=1 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of christian.storm@siemens.com designates 40.107.20.77 as permitted sender) smtp.mailfrom=christian.storm@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , Use @enum for enum-like tables. Remove device.pstate as it's not really needed. Update has_pending_action() to showcase optional action_id parameter. Split ipc_message.json for proper type inference. Signed-off-by: Christian Storm --- examples/suricatta/swupdate_suricatta.lua | 51 ++++++++++++----------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/examples/suricatta/swupdate_suricatta.lua b/examples/suricatta/swupdate_suricatta.lua index 75a35a8..f1d2da6 100644 --- a/examples/suricatta/swupdate_suricatta.lua +++ b/examples/suricatta/swupdate_suricatta.lua @@ -22,7 +22,7 @@ local suricatta = require("suricatta") -- Unknown options are (silently) ignored. -- If an option's required argument is missing, (':', option) is returned. -- ---- @param argv string Integer-keyed arguments table +--- @param argv table Integer-keyed arguments table --- @param optstring string GETOPT(3)-like option string --- @return function # Iterator, returning the next (option, optarg) pair function getopt(argv, optstring) @@ -112,21 +112,21 @@ end --[[ Suricatta General Purpose HTTP Server Module ]] --[[ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ]] +--- Marker for not (yet) set valid Device ID +DEVICE_ID_INVALID = "InvalidDeviceID" + --- Device state and information. -- --- @class device ---- @field pstate suricatta.pstate Persistent state ID number ---- @field id string Device ID +--- @field id string Device ID device = { - pstate = nil, - id = nil + id = DEVICE_ID_INVALID } --- Job type "enum". -- ---- @class job.type ---- @type table +--- @enum job.type jobtype = { INSTALL = 1, DOWNLOAD = 2, @@ -166,7 +166,7 @@ gs = { -- sleeping again. -- --- @param action_id number Current Action ID [unused] ---- @return number # Action ID [optional] +--- @return number|nil # Action ID [optional] --- @return suricatta.status # Suricatta return code function has_pending_action(action_id) action_id = action_id @@ -174,7 +174,7 @@ function has_pending_action(action_id) local _, pstate = suricatta.pstate.get() if pstate == suricatta.pstate.INSTALLED then suricatta.notify.warn("An installed update is pending testing, not querying server.") - return suricatta.status.NO_UPDATE_AVAILABLE + return action_id, suricatta.status.NO_UPDATE_AVAILABLE end suricatta.notify.trace("Querying %q", gs.channel_config.url) @@ -197,10 +197,10 @@ function has_pending_action(action_id) "Server queries client data for: %s", data.received_headers["Served-Client"] or "" ) - return suricatta.status.ID_REQUESTED + return action_id, suricatta.status.ID_REQUESTED end suricatta.notify.trace("Server served request for: %s", data.received_headers["Served-Client"] or "") - return suricatta.status.NO_UPDATE_AVAILABLE + return action_id, suricatta.status.NO_UPDATE_AVAILABLE end if data.http_response_code == 503 then @@ -208,7 +208,7 @@ function has_pending_action(action_id) -- Try again after seconds announced in HTTP header or default value. gs.polldelay.current = tonumber(data.received_headers["Retry-After"]) or gs.polldelay.default suricatta.notify.debug("Server busy, waiting for %ds.", gs.polldelay.current) - return suricatta.status.NO_UPDATE_AVAILABLE + return action_id, suricatta.status.NO_UPDATE_AVAILABLE end if data.http_response_code == 302 then @@ -219,11 +219,11 @@ function has_pending_action(action_id) suricatta.notify.info("Update available, update job enqueued.") gs.job.md5 = data.received_headers["Content-Md5"] gs.job.url = data.received_headers["Location"] - return suricatta.status.UPDATE_AVAILABLE + return action_id, suricatta.status.UPDATE_AVAILABLE end suricatta.notify.trace("Unhandled HTTP status code %d.", data.http_response_code) - return suricatta.status.NO_UPDATE_AVAILABLE + return action_id, suricatta.status.NO_UPDATE_AVAILABLE end suricatta.server.register(has_pending_action, suricatta.server.HAS_PENDING_ACTION) @@ -491,7 +491,7 @@ function server_start(defaults, argv, fconfig) end gs.polldelay.current = gs.polldelay.default - if not gs.channel_config.url or not device.id then + if not gs.channel_config.url or device.id == DEVICE_ID_INVALID then suricatta.notify.error("Mandatory configuration parameter missing.") return suricatta.status.EINIT end @@ -560,28 +560,31 @@ end suricatta.server.register(send_target_data, suricatta.server.SEND_TARGET_DATA) ---- Lua-alike of `ipc_message` as in `include/network_ipc.h` +--- Lua "enum" of IPC commands as in `include/network_ipc.h` -- --- Note: Some members are deliberately not passed through to the Lua realm --- such as `ipc_message.data.len` as that's handled by the C-to-Lua bridge --- transparently. --- Also, this is not a direct equivalent as, e.g., the `json` field is not --- present in `struct ipc_message`, but rather it's a "sensible" selection. --- As another example, CMD_ENABLE is also not passed through and hence not --- in `ipc_commands` as it's handled directly in `suricatta/suricatta.c`. +-- `CMD_ENABLE` is not passed through and hence not in `ipc_commands` as +-- it's handled directly in `suricatta/suricatta.c`. -- --- @type table --- @class ipc_commands --- @field ACTIVATION number 0 --- @field CONFIG number 1 --- @field GET_STATUS number 3 + +--- Lua-alike of `ipc_message` as in `include/network_ipc.h` +-- +-- Note: Some members are deliberately not passed through to the Lua realm +-- such as `ipc_message.data.len` as that's handled by the C-to-Lua bridge +-- transparently. +-- Also, this is not a direct equivalent as, e.g., the `json` field is not +-- present in `struct ipc_message`, but rather it's a "sensible" selection. -- --- @class ipc_message --- @field magic number SWUpdate IPC magic number --- @field commands ipc_commands IPC commands --- @field cmd number Command number, one of `ipc_commands`'s values --- @field msg string String data sent via IPC ---- @field json string If `msg` is JSON, JSON as Lua Table +--- @field json table If `msg` is JSON, JSON as Lua Table --- Handle IPC messages sent to Suricatta Lua module.