"use strict";(self.webpackChunkdocs_site=self.webpackChunkdocs_site||[]).push([[1268],{8453:(e,n,o)=>{o.d(n,{R:()=>l,x:()=>i});var t=o(6540);const r={},s=t.createContext(r);function l(e){const n=t.useContext(s);return t.useMemo(function(){return"function"==typeof e?e(n):{...n,...e}},[n,e])}function i(e){let n;return n=e.disableParentContext?"function"==typeof e.components?e.components(r):e.components||r:l(e.components),t.createElement(s.Provider,{value:n},e.children)}},9311:(e,n,o)=>{o.r(n),o.d(n,{assets:()=>a,contentTitle:()=>i,default:()=>u,frontMatter:()=>l,metadata:()=>t,toc:()=>c});const t=JSON.parse('{"id":"XXTLanControl.lua/README","title":"XXTLanControl Module","description":"XXTLanControl.lua provides a unified interface for device-side scripts to talk to the control center. It is organized into four main areas:","source":"@site/i18n/en/docusaurus-plugin-content-docs/current/XXTLanControl.lua/README.md","sourceDirName":"XXTLanControl.lua","slug":"/XXTLanControl.lua/","permalink":"/docs/en/XXTLanControl.lua/","draft":false,"unlisted":false,"tags":[],"version":"current","sidebarPosition":3,"frontMatter":{"sidebar_position":3},"sidebar":"tutorialSidebar","previous":{"title":"Shutdown and Uninstall","permalink":"/docs/en/usage/shutdown-and-uninstall"},"next":{"title":"Core","permalink":"/docs/en/XXTLanControl.lua/core/"}}');var r=o(4848),s=o(8453);const l={sidebar_position:3},i="XXTLanControl Module",a={},c=[{value:"Download the Module",id:"download-the-module",level:2},{value:"Import the Module",id:"import-the-module",level:2},{value:"Before You Start",id:"before-you-start",level:2},{value:"Common Usage Patterns",id:"common-usage-patterns",level:2}];function d(e){const n={code:"code",h1:"h1",h2:"h2",header:"header",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,s.R)(),...e.components};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(n.header,{children:(0,r.jsx)(n.h1,{id:"xxtlancontrol-module",children:"XXTLanControl Module"})}),"\n",(0,r.jsxs)(n.p,{children:[(0,r.jsx)(n.code,{children:"XXTLanControl.lua"})," provides a unified interface for device-side scripts to talk to the control center. It is organized into four main areas:"]}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Core control"}),": initialize the connection, configure retry behavior, set log aliases, and send logs back to the control center."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"Shared files"}),": read and write files in the ",(0,r.jsx)(n.code,{children:"Resource Directory"}),"."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"KVDB operations"}),": work with queues and dictionaries stored on the control center."]}),"\n",(0,r.jsxs)(n.li,{children:[(0,r.jsx)(n.strong,{children:"TableDB operations"}),": create, query, and edit structured table data on the control center."]}),"\n"]}),"\n",(0,r.jsx)(n.h2,{id:"download-the-module",children:"Download the Module"}),"\n",(0,r.jsx)("a",{href:"/api/down/XXTLanControl.lua",target:"_self",children:"Click here to download XXTLanControl.lua"}),"\n",(0,r.jsx)(n.h2,{id:"import-the-module",children:"Import the Module"}),"\n",(0,r.jsx)(n.pre,{children:(0,r.jsx)(n.code,{className:"language-lua",children:'local LCC = require("XXTLanControl")\n'})}),"\n",(0,r.jsx)(n.h2,{id:"before-you-start",children:"Before You Start"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsx)(n.li,{children:"Make sure the XXTouch version on the device is new enough."}),"\n",(0,r.jsxs)(n.li,{children:["If the script is not started directly by the control center, call ",(0,r.jsx)(n.code,{children:'LCC.set_api_url("http://control-center-address:46990")'})," first."]}),"\n",(0,r.jsxs)(n.li,{children:["Always call ",(0,r.jsx)(n.code,{children:"LCC.connect()"})," before using other helpers."]}),"\n"]}),"\n",(0,r.jsxs)(n.p,{children:["If the module version on the device does not match the one from the control center, ",(0,r.jsx)(n.code,{children:"LCC.connect()"})," will try to download the newer ",(0,r.jsx)(n.code,{children:"XXTLanControl.lua"})," automatically and reconnect."]}),"\n",(0,r.jsx)(n.h2,{id:"common-usage-patterns",children:"Common Usage Patterns"}),"\n",(0,r.jsxs)(n.ul,{children:["\n",(0,r.jsxs)(n.li,{children:["Use ",(0,r.jsx)(n.code,{children:"LCC.get_ui_config()"})," to read values submitted from a flat script's ",(0,r.jsx)(n.code,{children:"main.json"})," configuration UI."]}),"\n",(0,r.jsxs)(n.li,{children:["Use ",(0,r.jsx)(n.code,{children:"LCC.log()"})," to write messages back into log channels 1 to 6 in the control center."]}),"\n",(0,r.jsxs)(n.li,{children:["Use ",(0,r.jsx)(n.code,{children:"LCC.kvdb"})," and ",(0,r.jsx)(n.code,{children:"LCC.db"})," when you want scripts and the UI to share state or business data."]}),"\n"]})]})}function u(e={}){const{wrapper:n}={...(0,s.R)(),...e.components};return n?(0,r.jsx)(n,{...e,children:(0,r.jsx)(d,{...e})}):d(e)}}}]);