How to Communication of Lua and ThingWorx platform
Hello
I'm a beginner for ThingWorx, and I'm not a native speaker of english. I've had a lot of problems, and it's great if anyone can help me. anyway Thank you for your answer.
I have created an Instances in ThingWorx Dashboard, and setting up the EMS on my device. the config.json file is as below:
{
"http_server": {
"host": "127.0.0.1",
"port": 8000
},
"ws_servers": [{
"host": "52.199.8.0",
"port": 80
}],
"appKey": "44ddf820-e22f-4348-8517-f6bffd8eadse",
"logger": {
"level": "INFO"
},
"ws_connection": {
"encryption": "none",
"verbose": true
},
"certificates": {
"validate": false,
"allow_self_signed": true
},
"auto_bind": [{
"name": "myEMSGateway",
"gateway": true
}],
"file": {
"virtual_dirs": [{
"BaseFolder": "/mnt/baseFolder"
}],
"staging_dir": "/mnt/staging_dir"
},
"tunnel": {
"buffer_size": 8192,
"read_timeout": 10,
"idle_timeout": 300000,
"max_concurrent": 4
}
}
I can connected with the ThingWorx plateform when I run ./wsems , the thing myEMSGatewayThing's property "isConnected" will be true while it's false default.
But i don't konw how to use the Lua script.
my etc/config.lua file :
scripts.log_level = "INFO"
-- under template = specify name of your *.lua resource file specified in path etc/custom/template/, example in EMS is called example.lua
-- under sw_update_dir = specify local path of our SW Update directory for SCM module
scripts.myEMSGatewayThing = {
file = "myEMSGatewayThing.lua",
template = "myEMSGateway",
sw_update_dir = "/mnt/update"
}
my etc/custom/template/myEMSGateway file is same as etc/custom/template/example.lua but line 23 :
module ("templates.myEMSGateway", thingworx.template.extend)
my etc/custom/scripts/myEMSGatewayThing.lua file is same as etc/custom/scripts/sample.lua.
1. how can i send a property of myEMSGateThing to the plateform and plateform can refresh it.
2. I create an myEMSGateThing in ThingWorx Composer, Should i create another thing(e.g. myEMSThing01)
3. My LSR is runing on the device where EMS runing, is that right? if not what should i do?
Thank you!

