Skip to content

Commit 6b524ed

Browse files
TC pushbot 5TC pushbot 5
authored andcommitted
Updates v1.112
- Fixed file operation progress bug - Fixed MacOS cache file bug on Video module - Removed unsorted video list from Video Module - Optimized AirMusic searching cache - Updated AirMusic Media Session implementation and PWA mode - Added background / theme color support for desktop and mobile interface - Moved homepage to www folder - Migrated utilities from core to modules (PDF, Timer etc) - Added experimental support for AGI controlling iot devices - Fixed SMART data is null bug
1 parent f31c173 commit 6b524ed

File tree

475 files changed

+146700
-53764
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

475 files changed

+146700
-53764
lines changed

src/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ system/aecron/*.log
3131
#Webapp related
3232
web/teleprompter/*
3333

34+
#Document related
35+
src/documents/*
36+
37+
#Testing Modules
38+
src/web/Dummy/*
39+
src/web/Label Maker/*
40+
3441
#Subservice related
3542
subservice/*
3643

src/AGI Documentation.md

Lines changed: 150 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,14 @@ console.log("text");
269269
It has the same effect as using fmt.Println in golang.
270270

271271
#### Delayed operations
272-
For delayed / timer ticking operations like setTimeout or setInterval is currently not supported.
272+
273+
Synchronized delay (or blocking delay) can be used with the delay function (ms)
274+
275+
```
276+
delay(5000);
277+
```
278+
279+
For async delayed / timer ticking operations like setTimeout or setInterval is currently not supported.
273280

274281
### System Functions
275282
System Functions are AGI functions that can be called anytime (system startup / scheduled task and user request tasks)
@@ -340,7 +347,7 @@ USER_VROOTS
340347
USER_MODULES //Might return ["*"] for admin permission
341348
```
342349

343-
#### Filepath Virutalization
350+
#### Filepath Virtualization
344351
```
345352
decodeVirtualPath("user:/Desktop"); //Convert virtual path (e.g. user:/Desktop) to real path (e.g. ./files/user/username/Desktop)
346353
decodeAbsoluteVirtualPath("user:/Desktop"); //Same as decodeVirtualPath but return in absolute path instead of relative path from the arozos binary root
@@ -368,7 +375,46 @@ You can request other library to be loaded and have extra functions to work with
368375
requirelib("filelib");
369376
```
370377

378+
379+
380+
#### Include other script files
381+
382+
You can also include another js file to load shared code between scripts
383+
384+
```
385+
includes("hello world.js")
386+
```
387+
388+
389+
390+
### Execute tasks in another routine
391+
392+
You can use the execd function to execute something that is long pulling after the main thread returned the results of the current calculation.
393+
394+
```
395+
execd("execd.js", "Payload to child")
396+
```
397+
398+
To check if the current script is being executed as routine process, check for the following variable.
399+
400+
```
401+
if (typeof PARENT_DETACHED == 'undefined'){
402+
//This is parent
403+
}else if (PARENT_DETACHED == true){
404+
//This is child
405+
}
406+
```
407+
408+
To get the payload in child routine, get the following variable (Default: empty string)
409+
410+
```
411+
PARENT_PAYLOAD
412+
```
413+
414+
415+
371416
### filelib
417+
372418
filelib is the core library for users to interact with the local filesystem.
373419

374420
To use any of the library, the agi script must call the requirelib before calling any filelib functions. Example as follows.
@@ -554,3 +600,105 @@ if (setup()){
554600
555601
```
556602

603+
### iot
604+
605+
The iot library provide access to the iot hardware control endpoints (or endpoints for short) in a much easier to use abstraction.
606+
607+
```
608+
//Include the library
609+
requirelib("iot");
610+
```
611+
612+
613+
614+
#### iot functions
615+
616+
```
617+
iot.ready() //Return the iot manager status. Return true if ready, false otherwise.
618+
iot.scan() //Force the iot manager to scan nearby iot devices
619+
iot.list() //List nearby iot device, might be cached.
620+
iot.connect(devid) //Connect to a given device using device id
621+
iot.disconnect(devid) //Disconnect a given device using device id
622+
iot.status(devid) //Get the status of an iot device given its device ID, ID can be accessed using DeviceUUID key form an iot device object.
623+
iot.exec(devid, epname, payload); //Execute iot command using device id, endpoint name and payload (object).
624+
iot.iconTag(devid) //Get the device icon name from the device id
625+
626+
```
627+
628+
#### Example Return from iot.list() or iot.scan()
629+
630+
```
631+
[
632+
{
633+
"ControlEndpoints":[
634+
{
635+
"Desc":"Toggle the power of the smart switch",
636+
"Max":0,
637+
"Min":0,
638+
"Name":"Toggle Power",
639+
"Regex":"",
640+
"RelPath":"ay?o=1",
641+
"Steps":0,
642+
"Type":"none"
643+
}
644+
],
645+
"DeviceUUID":"84:F3:EB:3C:C7:F9",
646+
"Handler":{
647+
//hidden fields
648+
},
649+
"IPAddr":"192.168.0.177",
650+
"Manufacturer":"Sonoff",
651+
"Model":"Sonoff S2X Smart Switch",
652+
"Name":"Lights",
653+
"Port":80,
654+
"RequireAuth":false,
655+
"RequireConnect":false,
656+
"Status":{
657+
"Power":"ON"
658+
},
659+
"Version":""
660+
}
661+
]
662+
663+
```
664+
665+
666+
667+
668+
669+
#### Usage Example
670+
671+
The following code do not handle errors. Please see iot.exec.js for a full example.
672+
673+
```
674+
if (iot.ready() == true){
675+
//Get device list from the iot manager
676+
var deviceList = iot.list();
677+
678+
//Assume the first device is the one we want to control
679+
var thisDevice = deviceList[0];
680+
681+
//Assume the first endpoint is the one we want to execute
682+
var targetEndpoint = thisDevice.ControlEndpoints[0];
683+
684+
//Connect to the iot device
685+
iot.connect(thisDevice.DeviceUUID);
686+
687+
//Execute the endpoint and get response from iot device
688+
var results = iot.exec(thisDevice.DeviceUUID, targetEndpoint.Name, {});
689+
690+
//Disconnect the iot device after use
691+
iot.disconnect(thisDevice.DeviceUUID);
692+
693+
if (results == false){
694+
console.log("Something went wrong");
695+
}else{
696+
console.log("It works!" + JSON.stringify(results))
697+
}
698+
}
699+
700+
701+
702+
```
703+
704+
For detailed example for other functions, see the js file located at ```UnitTest/backend/iot.*.js```

src/build.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,11 @@ mv ../aroz_online_autorelease/system/storage.json ../aroz_online_autorelease/sys
4444
rm -rf ../aroz_online_autorelease/system/aecron/
4545
rm ../aroz_online_autorelease/system/cron.json
4646

47+
echo "Creating tarball for all required files"
48+
cd ../aroz_online_autorelease/
49+
rm web.tar
50+
tar -cf web.tar system/ web/
51+
52+
cd ../arozos/
4753
go build
4854
echo "Completed"
16 MB
Binary file not shown.
542 KB
Loading
4.91 MB
Binary file not shown.
-338 KB
Binary file not shown.
-18.1 MB
Binary file not shown.
-32.1 KB
Binary file not shown.

src/documents/dev.io/diagram 1.drawio

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)