As I've explored ways of controlling the 2B remotely, it's become apparent that there are some things that you can do easily with a remote connection, and some that are a bit trickier - or might just be reinventing the wheel. In many of those cases, it's best to tell the Mac (or PC) software what to do, and take the potentially unreliable web connection out of the equation.
Extended commands are my way of adding extra features and information that can be sent between two bits of software that are designed to work with the E-Stim systems 2B, without confusing things if one of those bits of software knows nothing about what's going on. They provide extra functions, but if sent to the 2B itself, will be ignored, so you don't get any unpleasant surprises.
NB. This page is a bit techy; if you just want to use the software, rather than code a web page, or write other software that works with mine, you really don't need to know any of this. Head back to the main index!
The commmands detailed here can be sent as part of the data stream between two apps. After talking with eStim, we agreed that the semicolon character would be suitable for starting extended commands, as the box will never respond to these, even if they are sent to it by mistake (my software intercepts them, but it's best to be safe). So, an extended command for the 2B will always start with a semicolon. I've also made some other restrictions at the moment, mostly in the interests of making things as simple as possible to interpret, whether in RealStudio, JavaScript or anything else.
If a command has parameters, they're specified by following the command with = followed by the parameters, with a comma between each one. There are no spaces anywhere in the command. For instance, the first extended command I implemented was the GOTO command. It takes the form ;GOTO=12,15,40,63
The numbers are, in order, the settings for A channel, B channel, C setting and D setting. The software sets the C and D parameters, then gradually increases the settngs, for the current mode and power level, from 10% of the A/B settings to 100%, over a period of thirty seconds. If a fifth paramter is passed, and is greater than thirty, then that will be used as the time over which the settings are increased - and there's no upper limit.
The command details here are as implemented in Estim Control/Server version 2.4 and above (and changes will be noted). If you are using an earlier version, not all commands may be available. Please update your software.
Many commands don't actually send a specific response; you'll simply get back the current status of the unit, however you're connected. When a command does need to send a response, that too will start with a semicolon, followed by a token, which depends on the command that is sending the response, followed by a colon, and then the response text. For example, the GETSTATUS
command will return a response like this:
;STATUS:delayfirst=false
;STATUS:delayvalue=
;STATUS:delaybetween=true
;STATUS:mindelay=60<
;STATUS:maxdelay=300
;STATUS:randomtimes=true
;STATUS:minrun=45
;STATUS:maxrun=200
;STATUS:randompower=false
;STATUS:checks=true
;STATUS:timeout=600
;STATUS:random=false
;STATUS:loop=false
;STATUS:sequence=false
;STATUS:countdown=0
;STATUS:targeta=0
;STATUS:targetb=0
The GETFAVS
command returns the list of favourites, with a line like this for each one:
;FAV:Pulse-48-36-50-35,30,180,20,1,Pulse,48,36,50,35,H
All lines end with CR-LF (\r\n).
I've tried to be reasonably accepting with parameters, so you don't have to send too many commands to do what you want. Where an option can be turned on or off, you can send 'on' or 'true' and either 'off' or 'false' for instance. At the receiving end, all commands are converted into upper case, so you can use mixed case to send the commands, and it won't make any difference.
The table here is correct for version 2.4 of both Android and desktop apps. In older versions of some apps, certain commands may not be available, or certain options to those commands may not be available. You are strongly recommended to update your software. The original version of this page includes more detail about which versions suport which commands. The Android column indicates if the command is supported by estim4android when running in server (slave) mode. If no response is indicated, the standard status of the 2B will usually be returned.
GOTO
;GOTO=10,25,40,30
set output A to 10, B to 25, setting C to 40 and D to 30. It will take 30 seconds to reach levels, mode and power are unchanged;GOTO=15,37,30,30,45
the fifth parameter is the time taken to reach the required levels;GOTO=24,12,17,50,90,8,H
parameter 6 is the 2B program, and parameter 7 is the power level
SAVE
PLAYSEQ
STOPSEQ
CLEARSEQ
GETSTATUS
;STATUS:option=value
as in the example above. The following options may be reported:delayfirst
If false, then the random setting 'delay before first setting' has not been ticked, so a random sequence will start immediatelydelayvalue
If there's a number, this is the number of minutes that the software will wait before playing the first in a random sequence of settingsdelaybetween
If true, the software will wait for a random period between settings in a random sequencemindelay
, maxdelay
These are the number of seconds for the lower and upper limit of the delay between items in a random sequencerandomtimes
Whether or not run times will be varied in a random sequenceminrun
, maxrun
Shortest and longest run times (in seconds) for a program in a random sequence, when randomtimes is activated randompower
If set to true, then ECS will also vary the maximum output in random mode by plus or minus 10% checks
If true, then commands to change level will be refused if they are more than five steps from the previous leveltimeout
The number of seconds used for the Slave timeout moderandom
If true, the software is currently working through a random programloop
If true, the software is in random loop mode, and so will not stop unless told to do solooppower
If true, then the power will increase by loopboosta and loopboostb for each iteration of the random looploopboosta
, loopboostb
The amount by which the power on each channel will increase each time the random loop restarts looptimeout
If true, then the loop mode will stop after the loopruntime number of minutesloopruntime
The number of minutes after which loop mode will terminate; at the end of this time, the current program will finish, and loop mode will stopsequence
If true, the software is playing a sequence of selected favouritescoundtown
The number of seconds for the current timer to run, usually the run-time of the current setting in sequence or random modetargeta
, targetb
The levels to which outputs will be increased in the current modeversion
The current version of the server softwarebuildno
An internal version number of the server software, which is used to determine which commands are available. See the old details page for earlier buildspercent
When the server is increasing or decreasing levels, this value will be returned as a status response, to indicate how much of the change has been completed. Build 19 and above.
percent
only
GETFAVS
A line is returned for each favourite, starting with the token ;FAV:
. The next part of the line consists of comma-separated values, in the order favourite name, rise time, run time, fall time, sequence, program name, A setting, B setting, C setting, D setting, power level
Time settings are in seconds; power level is "L" or "H", and sequence is "0" it unticked or "1" if ticked.
Program names are used because this is also the format of the saved favourites file; the names can be mapped to program numbers via the defnition Array("Pulse","Bounce","Continuous","Asplit","Bsplit","Wave","Waterfall","Squeeze","Milk","Throb","Thrust","Random","Step","Training")
CHECKS
;CHECKS=TRUE
TIMEOUT
;TIMEOUT=900
DELAYFIRST
;DELAYFIRST=OFF
;DELAYFIRST=TRUE
;DELAYFIRST=5
RANDOMDELAY
;RANDOMDELAY=false
;RANDOMDELAY=60,300
RANDROMRUN
;RANDOMRUN=true
;RANDOMRUN=45,200
RANDOMPOWER
PLAYRANDOM
PLAYLOOP
LOOPBOOST
;LOOPBOOST=off
;LOOPBOST=4,2
LOOPTIMEOUT
;LOOPTIMEOUT=off
;LOOPTIMEOUT=60
UP
DOWN
APLUS
AMINUS
BPLUS
BMINUS
CPLUS
CMINUS
DPLUS
DMINUS
;UP
and ;DOWN
generate two sets of commands at the remote end, and are considered experimental.
MOVE
;MOVE=30,20,60
HALT
PLAY
;PLAY=20,30,45,70,30,120,20,8,H
SEQSET
;SEQSET=1
SEQUNSET
MSG
;MSG=Take some poppers, this is going to hurt
SYSTEM
;STATUS:type=ECS,24
;STATUS:type=E4A,1
One thing to be aware of with extended commands is that some of them can take longer than the Slave timeout option that's included on the ECS software controlling the 2B. For example, if the timeout is set to 600 seconds (ten minutes), and you send the GOTO command, also specifying 10 minutes, it's likely that instead of continuing at the level you requested, the box will get there and almost immediately set the outputs to zero, because the request for an update of the settings that the web script sends after the GOTO command will be more than 600 seconds after the GOTO was sent.
Many of these remote commands are not presently sent from one app to another, but they can easily be generated by a web interface - which will hopefully soon be part of StimBroker - to allow a remote user as much control over the 2B as if they had installed the app.
As well as accepting commands via a standard connection, ECS has an HTTP command mode. This is designed principally to make it easier to build a web page to control the 2B, without having to dick around with websockets.
An extended command sent via an HTTP connection would look something like GET http://some.place.on.line:7846/;GOTO=12,15,40,63,120 HTTP/1.1
An ordinary command might just look like GET http://some.place.on.line:7846/A12 HTTP/1.1
ECS will parse the first one as ;GOTO=12,15,40,63,120
and the second as A12
. In the manual settings panel of ECS preferences, tick the HTTP Slave box to enable support.
Back to the tech page.