Class GollumJS
-
- All Implemented Interfaces:
-
com.comthings.gollum.api.gollumandroidlib.duktape.GollumJSInterface
public class GollumJS implements GollumJSInterface
GollumJS is a class to bind GollumDongle Java methods to JS methods and execute a JS script.
-
-
Method Summary
Modifier and Type Method Description static String
getVersion()
int
evaluateJS(String script)
Evaluate a Javascript script void
closeEvaluation()
JS evaluation will be stopped if 'still renning void
initFileDescAccordingTransceiver()
Init file descriptor variable of PandwaRF device. Array<String>
functionList()
Returns the list of available Gollum Engine JS functions void
rfOpen()
void
rfClose()
Close RF link void
resetRadioChip()
Order the CC1111 chip to do a power off/power on sequence of the CC1111 using RESET void
setFrequency(int frequency)
Set the RX/TX operating frequency of PandwaRF. int
rxStop()
Stop RX data reception int
rxSetup(int freq, int mod, int drate, int flen, int chanbw, int deviation)
Configure Dongle for RX int
rxListen(int rx_size)
Start listening for RX data int
rxListenAsync(Array<int> buffer)
Fill given list of int where a couple of two int represents a duration. int
txFlush()
Removes all TX messages already in queue int
txSetup(int freq, int mod, int drate, int deviation)
Configure CC1111 radio before sending Tx message over radio interface int
txSend(String buffer, boolean async, int repeat)
Send data as a byte array in the form [0x41, 0x42, 0x30, 0x46, ... int
txSendCompress(String data, boolean async, int repeat, boolean compress)
Send an hexadecimal String. int
registerRead(int address, String buffer)
Read a register from CC1111 RF int
registerWrite(int address, String buffer)
Write to a register in CC1111 RF int
startSpecan(int basefreq, int chanspc, int numchan, int pkt_delay_ms)
Starts Spectrum Analyzer int
stopSpecan()
Stop Spectrum Analyzer String
getSpecanRssi(int size)
Returns SpecAn RSSI measurements int
startDataRateMeas(int freq, int mod, int drate, int chanbw, int deviation, int threshold_occ_winner)
Measure data rate int
stopDataRateMeas()
Stop data rate measurement int
listenDataRateMeas()
Periodicaly read for data rate measurement results String
pingSyncEmpty()
Make an empty Synchronous (wait for PandwaRF ack) ping to device String
pingSync(String buffer_hex)
Make a Synchronous (wait for PandwaRF ack) ping with provided data to device Array<int>
getBruteForceStatusUpdate()
Returns Brute Force status update value void
setConfigPredefined(int config)
Set predefined configuration void
setOutputPower(int power_dbm)
Sets 'standard' output power of CC1111 void
setBitRate(int dataRate)
Set the TX/RX data rate to use for PandwaRF transmission/reception void
setModulation(int modulation)
Set the RX/TX operating modulation of PandwaRF. void
setFilterBandwidth(int filter_bandwidth)
Set filter bandwidth void
setLed(int led, boolean val)
Set the specified LED ID on or off void
setCC1111Sleep(int mode)
Put CC1111 into sleep mode String
getBuildType()
Get CC1111 FW build type Sync version (GollumRfBigRogueCCtl, GollumRfBigCCtl, ... Array<String>
getCC1111RfRegisters()
Return the list of CC1111 registers in a String[] list void
startJamming(int startFrequency, int stopFrequency, int dataRate, int modulation)
Start RF jamming Warning: calling this method causes the CC1111 to reset, in order to start Jamming with clean parameters. void
stopJamming()
Stop RF jamming void
setSpecanPktDelay(int pkt_delay_ms)
Configure the delay between 2 Spectrum Analyzer packets void
startBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int delay_btw_attempts_ms, int encSymbolZero, int encSymbolOne, int encSymbolTwo, int encSymbolThree, int syncWordSize, String syncWord)
All in one message to start a Brute Force void
stopBruteForceAttack()
Stop the Brute Force attack void
setupBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int delay_btw_attempts_ms, int encSymbolZero, int encSymbolOne, int encSymbolTwo, int encSymbolThree, int syncWordSize, String syncWord)
Setup the Brute Force. void
setupLongSymbolBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int delayBtwAttemptsMs, int symbolLength, String encSymbolZero, String encSymbolOne, String encSymbolTwo, String encSymbolThree)
Setup the Brute Force with long symbols Requires a Brute Force Start SyncCodeTail to start the BF Warning: calling this method causes the CC1111 to reset, in order to start BF with clean parameters. void
setupBruteForceAttackFunction(String functionMask, String functionValue)
Brute Force setup of the Function Mask and Value. void
startBruteForceAttackSyncCodeTail(int syncWordSize, String syncWord, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int tailWordSize, String tailWord)
Start a Brute Force using previous parameters set in Setup Brute Force message Requires a call to rfBruteForceAttackSetup() before void
setTxRxPowerAmp(int actionToPerform)
Set power Amplifiers mode int
getTxRxPowerAmp()
Get power Amplifiers mode void
print(String somethingToPrint)
Print into JS fragment console void
delay(int delayMs)
Causes the currently executing thread to sleep for the specified number of milliseconds String
getCurrentBleDeviceMacAddress()
Returns the current BLE device MAC address int
getCurrentTrxMode()
Returns the current trx mode (USB or BLE) int
setTxInfiniteMode(boolean infiniteMode, int infModeLength)
Configure RF TX infinite mode (for RF air gap-less transmission). boolean
writeResetNordic()
boolean
writeResetCC1111()
void
notifyProgress(String message, int stepNumber, int countOfSteps)
-
-
Constructor Detail
-
GollumJS
GollumJS(Context mContext)
GollumJS constructor- Parameters:
mContext
- : The context of the application
-
-
Method Detail
-
getVersion
static String getVersion()
-
evaluateJS
int evaluateJS(String script)
Evaluate a Javascript script
- Returns:
0 if success, -1 if fail
-
closeEvaluation
void closeEvaluation()
JS evaluation will be stopped if 'still renning
-
initFileDescAccordingTransceiver
void initFileDescAccordingTransceiver()
Init file descriptor variable of PandwaRF device. Only used when sending command over USB. For command sent over BLE, use 0.
-
functionList
Array<String> functionList()
Returns the list of available Gollum Engine JS functions
- Returns:
list of available Gollum Engine JS functions
-
rfOpen
void rfOpen()
-
rfClose
void rfClose()
Close RF link
-
resetRadioChip
void resetRadioChip()
Order the CC1111 chip to do a power off/power on sequence of the CC1111 using RESET
-
setFrequency
void setFrequency(int frequency)
Set the RX/TX operating frequency of PandwaRF. Warning: some API calls that require frequency as parameter can override this value.
-
rxStop
int rxStop()
Stop RX data reception
- Returns:
0 if operation successfully completed, -1 in case of error
-
rxSetup
int rxSetup(int freq, int mod, int drate, int flen, int chanbw, int deviation)
Configure Dongle for RX
- Parameters:
freq
- The frequency to use, in Hzmod
- The modulation value to use.drate
- Sampling rate, in Hzflen
- Size (in bytes) of the packet that the CC1111 transceiver needs to capture before sending it to Androidchanbw
- Receiver Channel Filter Bandwidth in Hzdeviation
- Channel deviation, in Hz.- Returns:
0 if operation successfully completed, -1 in case of error
-
rxListen
int rxListen(int rx_size)
Start listening for RX data
- Parameters:
rx_size
- Size of RX data buffer- Returns:
0 if operation successfully completed, -1 in case of error
-
rxListenAsync
int rxListenAsync(Array<int> buffer)
Fill given list of int where a couple of two int represents a duration. [lower int0, higher int0, lower int1, higher int1, ...] int range -> [0, 255] in this example, first duration is represented by lower_int0 higher_int0 in little endian.
- Returns:
count of bytes set to the buffer.
-
txFlush
int txFlush()
Removes all TX messages already in queue
- Returns:
0 if operation successfully completed, -1 in case of error
-
txSetup
int txSetup(int freq, int mod, int drate, int deviation)
Configure CC1111 radio before sending Tx message over radio interface
- Parameters:
freq
- The frequency to use, in Hzmod
- The modulation value to use.drate
- Transmission data rate, in bits/sdeviation
- Channel deviation, in Hz.- Returns:
0 if operation successfully completed, -1 in case of error
-
txSend
int txSend(String buffer, boolean async, int repeat)
Send data as a byte array in the form [0x41, 0x42, 0x30, 0x46, ...]
- Parameters:
buffer
- as a byte array in the form [0x41, 0x42, 0x30, 0x46, ...].async
- true to send in async mode (doesn't wait for ack from PandwaRF), false to send in sync mode (wait for PandwaRF ack)repeat
- number of SW or HW repeat times: 1 = single TX, 2 = 2 TX, etc.- Returns:
0 if operation successfully completed, -1 in case of error
-
txSendCompress
int txSendCompress(String data, boolean async, int repeat, boolean compress)
Send an hexadecimal String. Same as txSend, but assuming we are already in a background task Must be called from background thread. Method will block until completion, whether async is true or false. If buffer contains too much data vs what is possible for the device variant (PandwaRF or Rogue), the data will truncated before sending.
- Parameters:
data
- an hexadecimal String in the form "abcdef0123456789".async
- true to send in async mode (doesn't wait for ack from PandwaRF), false to send in sync mode (wait for PandwaRF ack)repeat
- number of SW or HW repeat times: 1 = single TX, 2 = 2 TX, etc.compress
- If false, no compression requested.- Returns:
0 if operation successfully completed, -1 in case of error.
-
registerRead
int registerRead(int address, String buffer)
Read a register from CC1111 RF
- Parameters:
address
- Address of first CC1111 register to readbuffer
- Buffer where CC1111 registers values will be stored- Returns:
0 if operation successfully completed, -1 in case of error
-
registerWrite
int registerWrite(int address, String buffer)
Write to a register in CC1111 RF
- Parameters:
address
- Address of first CC1111 register to writebuffer
- Buffer of data to write to CC1111 registers- Returns:
0 if operation successfully completed, -1 in case of error
-
startSpecan
int startSpecan(int basefreq, int chanspc, int numchan, int pkt_delay_ms)
Starts Spectrum Analyzer
- Parameters:
basefreq
- Start frequency in Hz (ex: 433920000)chanspc
- frequency increment in Hz (ex: 25000 Hz)numchan
- number of channels (ex: 51 channels)pkt_delay_ms
- delay in ms between packets- Returns:
0 if operation successfully completed, -1 in case of error
-
stopSpecan
int stopSpecan()
Stop Spectrum Analyzer
- Returns:
0 if operation successfully completed, -1 in case of error
-
getSpecanRssi
String getSpecanRssi(int size)
Returns SpecAn RSSI measurements
- Parameters:
size
- RSSI Buffer size.- Returns:
String with the RSSI values as an hexadecimal String
-
startDataRateMeas
int startDataRateMeas(int freq, int mod, int drate, int chanbw, int deviation, int threshold_occ_winner)
Measure data rate
- Parameters:
freq
- The frequency to use, in Hzmod
- The modulation value to use.drate
- Sampling rate, in Hzchanbw
- Receiver Channel Filter Bandwidth, in Hz.deviation
- Channel deviation, in Hz.threshold_occ_winner
- Number of occurence needed for a duration to be elected as the winner- Returns:
0 if operation successfully completed, -1 in case of error
-
stopDataRateMeas
int stopDataRateMeas()
Stop data rate measurement
- Returns:
0 if operation successfully completed, -1 in case of error
-
listenDataRateMeas
int listenDataRateMeas()
Periodicaly read for data rate measurement results
- Returns:
value of measured data rate if operation successfully completed, 0 if no DRM result found, -1 if DRM measurement is finished
-
pingSyncEmpty
String pingSyncEmpty()
Make an empty Synchronous (wait for PandwaRF ack) ping to device
- Returns:
null if failure, array with bytes if success
-
pingSync
String pingSync(String buffer_hex)
Make a Synchronous (wait for PandwaRF ack) ping with provided data to device
- Parameters:
buffer_hex
- an hex byte array in the form [0xAB, 0x0F, 0x00, 0xFF, ...].- Returns:
null if failure, array with bytes if success
-
getBruteForceStatusUpdate
Array<int> getBruteForceStatusUpdate()
Returns Brute Force status update value
- Returns:
int array with 2 elements.First element indicates the BF status0 -> UNKNOWN1 -> NOT_STARTED2 -> ONGOING3 -> FINISHEDSecond element is brute force index, represented by an integer 32bits.
-
setConfigPredefined
void setConfigPredefined(int config)
Set predefined configuration
- Parameters:
config
- Predefined configuration Id
-
setOutputPower
void setOutputPower(int power_dbm)
Sets 'standard' output power of CC1111
- Parameters:
power_dbm
- TX output power in dBm
-
setBitRate
void setBitRate(int dataRate)
Set the TX/RX data rate to use for PandwaRF transmission/reception
- Parameters:
dataRate
- TX/RX data rate to use for PandwaRF transmission/reception.
-
setModulation
void setModulation(int modulation)
Set the RX/TX operating modulation of PandwaRF. Warning: some API calls that require modulation as parameter can override this value
- Parameters:
modulation
- The modulation value to use.
-
setFilterBandwidth
void setFilterBandwidth(int filter_bandwidth)
Set filter bandwidth
- Parameters:
filter_bandwidth
- Receiver Channel Filter Bandwidth, in Hz.
-
setLed
void setLed(int led, boolean val)
Set the specified LED ID on or off
- Parameters:
led
- LED Id.val
- True for LED on, false for LED off
-
setCC1111Sleep
void setCC1111Sleep(int mode)
Put CC1111 into sleep mode
- Parameters:
mode
- CC1111 power sleep mode.
-
getBuildType
String getBuildType()
Get CC1111 FW build type Sync version (GollumRfBigRogueCCtl, GollumRfBigCCtl, ...)
- Returns:
build_type
-
getCC1111RfRegisters
Array<String> getCC1111RfRegisters()
Return the list of CC1111 registers in a String[] list
- Returns:
CC1111 registers list
-
startJamming
void startJamming(int startFrequency, int stopFrequency, int dataRate, int modulation)
Start RF jamming
Warning: calling this method causes the CC1111 to reset, in order to start Jamming with clean parameters. All RF parameters set prior to this method call will be lost.
- Parameters:
startFrequency
- The start Frequency to use in HzstopFrequency
- The stop Frequency to use in HzdataRate
- Target data rate, in bits/smodulation
- The modulation value to use.
-
stopJamming
void stopJamming()
Stop RF jamming
-
setSpecanPktDelay
void setSpecanPktDelay(int pkt_delay_ms)
Configure the delay between 2 Spectrum Analyzer packets
- Parameters:
pkt_delay_ms
- delay in ms between packets (max 255 ms)
-
startBruteForceAttack
void startBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int delay_btw_attempts_ms, int encSymbolZero, int encSymbolOne, int encSymbolTwo, int encSymbolThree, int syncWordSize, String syncWord)
All in one message to start a Brute Force
- Parameters:
frequency
- The frequency to use in HzdataRate
- Target data rate, in bits/smodulation
- The modulation value to use.deviation
- Channel deviation, in Hz.codeLength
- Number of Symbols in CodeWordstartValue
- The start value of Brute Force from where you want to beginstopValue
- The stop value of Brute Force at which you want to stoprepeat
- Frame Repetition.littleEndian
- Endianess.delay_btw_attempts_ms
- Delay between each frame to send.encSymbolZero
- How to encode symbol '0'encSymbolOne
- How to encode symbol '1'encSymbolTwo
- How to encode symbol '2'encSymbolThree
- How to encode symbol '3'syncWordSize
- Synchronisation word size, in bytes.syncWord
- Synchronisation word, in hexadecimal.
-
stopBruteForceAttack
void stopBruteForceAttack()
Stop the Brute Force attack
-
setupBruteForceAttack
void setupBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int delay_btw_attempts_ms, int encSymbolZero, int encSymbolOne, int encSymbolTwo, int encSymbolThree, int syncWordSize, String syncWord)
Setup the Brute Force. Requires a Brute Force Start SyncCodeTail to start the BF.
Warning: calling this method causes the CC1111 to reset, in order to start BF with clean parameters. All RF parameters set prior to this method call will be lost.
- Parameters:
frequency
- The frequency to use in HzdataRate
- Target data rate, in bits/smodulation
- The modulation value to use.deviation
- Channel deviation, in Hz.codeLength
- Number of Symbols in CodeWordstartValue
- The start value of Brute Force from where you want to beginstopValue
- The stop value of Brute Force at which you want to stoprepeat
- Frame Repetition.littleEndian
- Endianess.delay_btw_attempts_ms
- Delay between each frame to send.encSymbolZero
- How to encode symbol '0'encSymbolOne
- How to encode symbol '1'encSymbolTwo
- How to encode symbol '2'encSymbolThree
- How to encode symbol '3'syncWordSize
- Synchronisation word size, in bytes.syncWord
- Synchronisation word, in hexadecimal.
-
setupLongSymbolBruteForceAttack
void setupLongSymbolBruteForceAttack(int frequency, int dataRate, int modulation, int deviation, int delayBtwAttemptsMs, int symbolLength, String encSymbolZero, String encSymbolOne, String encSymbolTwo, String encSymbolThree)
Setup the Brute Force with long symbols Requires a Brute Force Start SyncCodeTail to start the BF
Warning: calling this method causes the CC1111 to reset, in order to start BF with clean parameters. All RF parameters set prior to this method call will be lost.
- Parameters:
frequency
- The frequency to use in HzdataRate
- Target data rate, in bits/smodulation
- The modulation value to use.deviation
- Channel deviation, in Hz.delayBtwAttemptsMs
- Delay between each frame to send.symbolLength
- Length of a symbol.encSymbolZero
- How to encode symbol '0'encSymbolOne
- How to encode symbol '1'encSymbolTwo
- How to encode symbol '2'encSymbolThree
- How to encode symbol '3'
-
setupBruteForceAttackFunction
void setupBruteForceAttackFunction(String functionMask, String functionValue)
Brute Force setup of the Function Mask and Value. Optional after a Brute Force Setup and before Brute Force Start SyncCodeTail to start the BF
- Parameters:
functionMask
- This is like a Mask IP Address.functionValue
- This is the "contrary" of functionMask.
-
startBruteForceAttackSyncCodeTail
void startBruteForceAttackSyncCodeTail(int syncWordSize, String syncWord, int codeLength, int startValue, int stopValue, int repeat, boolean littleEndian, int tailWordSize, String tailWord)
Start a Brute Force using previous parameters set in Setup Brute Force message Requires a call to rfBruteForceAttackSetup() before
-
setTxRxPowerAmp
void setTxRxPowerAmp(int actionToPerform)
Set power Amplifiers mode
- Parameters:
actionToPerform
- Power amplifier mode
-
getTxRxPowerAmp
int getTxRxPowerAmp()
Get power Amplifiers mode
- Returns:
Power amplifier mode on success, -1 in case of failure
-
print
void print(String somethingToPrint)
Print into JS fragment console
- Parameters:
somethingToPrint
- message to print into console
-
delay
void delay(int delayMs)
Causes the currently executing thread to sleep for the specified number of milliseconds
- Parameters:
delayMs
- the length of time to sleep in milliseconds
-
getCurrentBleDeviceMacAddress
String getCurrentBleDeviceMacAddress()
Returns the current BLE device MAC address
- Returns:
the device MAC address
-
getCurrentTrxMode
int getCurrentTrxMode()
Returns the current trx mode (USB or BLE)
- Returns:
current trx mode: {@value {@link com.comthings.gollum.api.gollumandroidlib.GollumDongle#GOLLUM_MODE_USB}} or {@value {@link com.comthings.gollum.api.gollumandroidlib.GollumDongle#GOLLUM_MODE_BLE}}
-
setTxInfiniteMode
int setTxInfiniteMode(boolean infiniteMode, int infModeLength)
Configure RF TX infinite mode (for RF air gap-less transmission). Aka TX FIFO enqueue mode, assuming we are already in a background task Must be called from background thread
Only available in Rogue variants
- Parameters:
infiniteMode
- TX FIFO enqueue mode (true: enabled, false: disabled)infModeLength
- Expected block size when entering Infinite mode, in bytes- Returns:
0 if operation successfully completed, -1 in case of error.
-
writeResetNordic
boolean writeResetNordic()
-
writeResetCC1111
boolean writeResetCC1111()
-
notifyProgress
void notifyProgress(String message, int stepNumber, int countOfSteps)
-
-
-
-