Each command has an internal state (data memory) denoted with $ with default value '' (empty string).
With com = val the internal status of the command is updated, even if it is disabled, and then executed.
A command can be disabled by the user or in case of a run-time error.
This behavior has also been applied to the primitive commands: rf, sound, sonar, press, matrix.
A command can refer, in its definition com = [... $ ...], to its status by indicating it with the $ symbol.
With com=expression the expression is evaluated and stored in $ state, then the command is executed by replacing the parameter, if any, with its value.
With com the command returns the value of the internal state if com is parametric, else it is executed.
Using com as operand in an expression returns always the value of the internal state.
If you want to read the status of a non-parametric commanda use +com or (com).
Example 1 :
--- parametric command
blink=[led=!led #$ ^6] define blink with parameter $=''
blink=1 set $=1 and execute led=!led #1 ^6
blink read the $ status of the command (returns 1) <== ### difference ###
x=2*blink+5 read the $ status of the command (x=2*1+5)
+blink read the $ status of the command (returns 1)
(blink) read the $ status of the command (returns 1)
For a traditional, non-parametric command, the behavior is slightly different.
Examples 2:
--- non-parametric command
flash=[led=!led *] define flash without parameter ($='')
flash=1 set $=1 and execute led=!led *
flash execute led=!led * <== ### difference ###
x=2*flash+5 read the $ status of the command (x=2*1+5)
+flash read the $ status of the command (returns 1)
(flash) read the $ status of the command (returns 1)
5. Wi-Fi manager
Removed web server for Wi-Fi Manager and the related commands web, disweb, webclear. Removed in conf --- Web management section.
6. Boot management
At boot Wi-Fi and services (MQTT and VOX) are disabled. The user can enable them, if used, in the start command:
start = [wifi=1, mqtt=1, vox=1]
When the Wi-Fi radio is turned off (wifi=0) Smick absorbs 20mA with a power of 143mW, while when it is switched on (wifi=1) it absorbs 70mA with a power of 358mW.
At boot time, if the SOS condition is not verified, the following instructions are automatically executed:
- load to load the configuration by resetting the timers for NTP and OTA
- if host is not set it is initialized with 'smick'
- if ssid is not set it is initialized with 'Smick- <code>'
- set NTP update after 15 seconds from boot
- set OTA update after 10 minutes from boot
- start to initialize the system.
Improved procedures for connecting to Wi-Fi, MQTT broker and voice assistants (VOX). The boot with Wi-Fi, MQTT and VOX connection is made in less than 10s. To measure it use this sketch:
start = [wifi=1]
Wificon -> [mqtt=1, vox=1]
Mqttcon & Voxcon -> Secs
7. NTP and OTA management
When Wi-Fi is enabled, the NTP and OTA services, if enabled (ntpupd>0 and otaupd>0) are activated automatically after the first Wi-Fi connection: NTP after 15s from boot and OTA after 10m from boot.
8. MQTT management
Activating MQTT the Conn event is automatically sent to MQTT.
If MQTT is active, disconnecting MQTT (mqtt=0) or WIFI (wifi=0) or switching to sleep mode (sleep=n) or performing a reset, the Disc event is sent to MQTT.
The language instruction
mqtto=0
disables the automatic sending of events and commands activated by rules. Also Conn and Disc are not sent.
The language instruction
mqttio=0
disable interactive MQTT. When Smick receives instructions from MQTT, he executes them without sending the result.
9. Management of the status LED
The status LED flashes every 3s to indicate that it is ready for use, otherwise it will flash:
- fast (4 times per second) to indicate that it is trying to connect to the Wi-Fi network
- slowly (1 time per second) if it is connected to the Wi-Fi network, but can not connect to some activated service (MQTT or VOX).
To disable the status LED use the status=0 instruction.
Modified status instruction: added new value 2. Summarizing:
Added new Status event that shows the value of the status LED: 1 if it is on, 0 if it is off. (See the example "Simple clock with status report").
10. Variable names
The words start and stop can not be names of variables.
11. Matrix module
Changed the scroll instruction that previously set only the scroll mode (0|1) while now setting the scroll frequency (0..100 Hz).
12. Removed instructions: HHMM and MMSS
13. MQTT send
< command
First command is executed and then the result is published on MQTT.
Alcuni esempi:
] < 45+2*4
< 53
ok
] < 'x='+x
< x=26
ok
] < json,x+4,csv##
< {"x+4":30}
ok
] < "json,x+4,csv##"
< json,x+4,csv##
ok
]
14. Modified scroll instruction that has values of 0..100 (scroll speed).
15. Modified status statement that has values of 0..2 (0 = disabled, 1 = enabled, 2 = enabled only to report connectivity problems).
16. Added event Status.
17. Removed HHMM and MMSS instructions.
18. The following instructions have been added:
19. Added configuration parameters: mac1, ..., mac8 (MAC friends) in the format 'HH: HH: HH: HH: HH: HH'.
The behavior of the scroll command has been changed and the direct command has been added.
Summary of the commands used to manage Matrix:
matrix :: d6
defines the Smick PIN connected to the Matrix CS (Chip Select) PIN
matrix = <value>
show <value> which can be a logical value (true, false), a number (integer or decimal) or a string.
If <value> consists of more than 5 characters, it is scrolled to the left until the last character.
scroll = 1/0
scroll = 1 scrolls <value> to the left indefinitely,
scroll = 0 suspend scrolling (default)
direct = 1/0
direct = 1 sets scrolling to the right
direct = 0 sets scrolling to the left (default)
inverse = 1/0
inverse = 1 sets the bright background
inverse = 0 sets non-luminous background (default)
2. Modified tracing. With trace = 2 we get detailed trace:
# 5186905: Wificon -> [json,led=0,vox=1##10]
# 5186993: ------ end cycle: 1208539 (329ms), Ips: 147
]
# 5196564: vox=1
# 5196870: ------ end cycle: 1208574 (307ms), Ips: 159
# 5197089: Voxcom -> msg
# 5197110: msg = [Voxdev,Voxcom,Voxval]
]
# 5197223: ------ end cycle: 1208575 (353ms), Ips: 159
With trace = 1 we get simplified trace:
# Wificon -> [json,led=0,vox=1##10]
]
# vox=1
# Voxcom -> msg
# msg = [Voxdev,Voxcom,Voxval]
]
3. Added new operators on instructions:
Examples:
] x=0,[x=x+1,x]^3
ok
]
1
]
2
]
3
] x=0,[x=x+1,x]*
ok
]
1
]
2
]
3
]
4
]
5
...
Summarizing the periodic operators are:
Note: in your sketches replace #@ with ^ and @ with ^
The difference between the messages sent by Alexa and Google Home concerns only the parameters:
Examples:
Saying to Alexa: "Alexa, turn on the lamp", Smick receives:
Voxcon='5c1aaa461390c02d93f1239',Voxcom='setPowerState',Voxval='ON'
Saying to Google Home: "Ok google, turn on the lamp", Smick receives:
Voxcon='5c1aaa461390c02d93f1239',Voxcom='action.devices.commands.OnOff',Voxval='{"on":true}'
2. Type casting
For casting to number use: +x or -x (unary + or -).
Examples:
+true=1, +'45.3bt'=45.30, +23.6=23.60
-true=-1, -'45.3bt'=-45.30, -23.6=-23.60
For casting to string use: ''+x.
Examples:
''+12.56='12.56', ''+true='true', ''+'home'='home'
For casting to logic use: !!x.
Examples:
!!'home'=true, !!12.56=true, !!true=true
!!''=false, !!0=false, !!false=false
3. Added print command '?'
Example: ?'result is '+val
4. New error messages for commands:
vox = 1, if not configured voxkey generates "nok: VUI voxkey is not configured" error
wifi = 1, if not configured wifissid generates "nok: Wi-Fi SSID is not configured" error
mqtt = 1, if not configured mqttserver generates "nok: MQTT server is not configured" error
5. The 'new' command disconnects the virtual pins (rf, matrix, ...)
6. Added new 'Ips' parameter (Instructions per second). Count the number of:
- operations performed: +, -, *, /,%,!, &, |
- verified relationships: ==,! =, <=, <,>,> =, <<, == *, * ==
- assigned assignments: =
- calculated operands.
7. Added New 'Cycle' parameter that provides the duration in ms of a loop cycle.
8. Improved tracing. With trace = 1 we get:
# 5186905: Wificon -> [json,led=0,vox=1##10]
# 5186993: ------ end cycle: 1208539 (329ms), Ips: 147
WIFI connected with IP: 192.168.1.148 (smick.local)
VOX connected to VUI bridge
]
# 5196564: vox=1
# 5196870: ------ end cycle: 1208574 (307ms), Ips: 159
# 5197089: Voxcom -> msg
# 5197110: msg = [Voxdev,Voxcom,Voxval]
{"Voxdev":"5c1aaa461390c02d93f1239","Voxcom":"'setPowerState'","Voxval":"'ON'"}
]
# 5197223: ------ end cycle: 1208575 (353ms), Ips: 159
For every cycle of the interpreter K all the instructions executed are traced (lines starting with #). Obviously the tracking slows down the system, but it is useful for understanding the functioning of a sketch and discovering unwanted effects.
The end of each cycle is traced with:
# 5197223: ------ end cycle: 1208575 (353ms), Ips: 159
where:
9. New values for the rf command:
10. Command '?' show the definitions in the following order:
--- Pin connections
--- Variables
--- Commands
--- Events
--- Rules
11. Integer from fractional
] x=4.56, i=x/'.', f=x%'.', i, f
i=4,f=56
Added configuration parameter:
Added command:
Added events:
Normally Voxdev, Voxcom and Voxval are always empty. When Alexa receives a command for your device, she understands it and sends a message to Smick containing:
To set your VUI key, enable VUI and set JSON data format use this command:
start = [voxkey = "f83702bb-f9ee-43db-b25d-968a874a2c14", vox = 1, json]
Note: "f83702bb-f9ee-43db-b25d-968a874a2c14" is an example key.
To trace the messages sent by Alexa use the following rule:
Voxcom -> [Voxdev, Voxcom, Voxval]
Here's how a command received from Alexa is traced:
{"Voxdev":"5bd1cfacdc99c35cc7b871f","Voxcom":"setPowerState","Voxval":"ON"}
7. Added new Comparison Operators:
*==
(prefix of)==*
(has suffix)<<
(contained in)!<
(not contained in)8. Removed logical operator:
^
(xor)9. Extended validity of arithmetic operators (+, -, *, /, %) to all data types (logic, number and string).
3. Added commands:
4. String management
5. Structured display of the configuration (conf):
...
--- NTP management
ntpserver=0.it.pool.ntp.org
timezone=10
ntpupd=60
--- OTA management
otaupd=1440
--- SERIAL management
bitrate=115200
--- TELNET management
distel=60
disweb=10
...
6. ls | dir also summarizes the number of config files and the sketch number
/Smick.k 660 bytes
2% used space 24598 bytes
98% free space 932716 bytes
6 config files
34 sketch files
7. Added two new commands for the engines operating on both motor1 and motor2 engines. They are used to control a robotic base:
8. Modified command load and run: does not run new if it refers to configuration file (starting with a capital letter) .
9. Connection with NB-IoT (Narrow Band IoT) u-blox transceiver on serial interface. Added new configuration parameters:
Setting nbiot=0 the dynamic parameters Nbrtt, Nbttl, Nbip, Nbrxudpsid, Nbrxudplen, Nbrxudpmsg are initialized.
10. Added new commands to manage the MAX7219 4x 8x8 LED Dot Matrix module:
11. MQTT connection executable with and without credentials (mqttuser, mqttpass)
12. The mqttserver parameter can contain an IP address or a domain name.
The telnet parameter can take the following values:
With the distel parameter set the idle time (in minutes) for automatic deactivation of the Telnet interface. If distel is zero no automatic deactivation is set.
The Telnetcon event indicates whether Telnet is active. It can be used to know, for example, when someone connects or disconnects via Telnet.
Telnetcon -> led = 1
!Telnetcon -> led = 0
5. Added bell dynamic configuration parameter that enables or disables sending the BELL code to the Serial and Telnet interfaces:
Sending BELL is performed at the same time as reading the bell parameter (when it is 1). To hear the bell on the Serial or Telnet client, you must configure it on the client.
6. Added new reboot command to reinitialize the system without resetting.
7. Added new fota command to force the OTA update with the latest available version. This command replaces the forced OTA update procedure described in release notes Smick v.10.29.80, step 1.
sonar :: <trigger PIN>
Sonar :: <Echo PIN>
To set the maximum visibility distance use
sonar = <maximum distance> (3, .., 250) expressed in cm
Instead
Sonar
returns the distance of the obstacle. The value 0 indicates no obstacle.
6. Added Wemos motor shield to handle two engines: motor1 and motor2. The shield uses the I2C serial interface via the D1 and D2 PINs and it is not necessary to define the connection. The motor1 and motor2 parameters can take between -100 and +100.
7. Added pressure and temperature sensor BMP180. It uses the I2C serial interface (addr. 0x77) via the D1 and D2 PINs and it is not necessary to define the connection. The press parameter must be set with the pressure, expressed in hPa (default=1013.25), at the current sea level and its area available from any weather forecast site. You can consult, for example http://www.weatheronline.co.uk, search for your city, view the 'SL pressure' map and read the isobara from the map. If, for example, you read 1026, you have to set
press = 1026
The sensor provides the following parameters:
8. Removing sub-commands limitation up to three levels. Subcommands can be leveled as long as the system's memory resources allow it.
To force the firmware update through OTA:
] otaupd=1440, trace=1, ota
OTA Check firmware update
ets Jan 8 2013,rst cause:4, boot mode:(3,0)
wdt reset
...
2. Added new read-only variables to manage calendar-based events:
3. It is possible to display from MQTT the definition of a link, a variable, an event, a command, or a rule. Send from MQTT:
and you get on MQTT:
Note: max length of a definition is 80 chars
1. External event is generated even if disabled!
2. Introduction of two new parameters:
If the command is an expression to be evaluated (i.e. Sec + 3), the result is stored in the val register and set Eval=true.
Example of use.
These two registers are used to define such rules:
Eval -> led = val
to set led with a value received from mqttin or serial channel.
] 0
0
The LED goes off.
] 1
1
The LED lights up
3. Added new registry 'mqttio' to set up MQTT channel interaction.
If mqttio = 0 (default), when evaluating an expression via mqttin channel
> Sec+2
46
]
the result is not returned on mqttout, but only on serial.
If mqttio = 1, when evaluating an expression via mqttin channel
> Sec+2
< 79
]
the result is returned to mqttout.
4. For commands '?', '\', '+', '-' the pattern may contain as a suffix:
5. Modified the result of the 'help' command:
] help
For any information see the web page http://smick.tk
ok