public class YModule extends YFunction
Modifier and Type | Class and Description |
---|---|
static interface |
YModule.ConfigChangeCallback |
static interface |
YModule.LogCallback |
static interface |
YModule.TimedReportCallback
TimedReportCallback for Module
|
static interface |
YModule.UpdateCallback
Deprecated UpdateCallback for Module
|
Modifier and Type | Field and Description |
---|---|
protected int |
_beacon |
protected YModule.ConfigChangeCallback |
_confChangeCallback |
protected String |
_firmwareRelease |
protected YModule.LogCallback |
_logCallback |
protected int |
_luminosity |
protected int |
_persistentSettings |
protected int |
_productId |
protected String |
_productName |
protected int |
_productRelease |
protected int |
_rebootCountdown |
protected String |
_serialNumber |
protected long |
_upTime |
protected int |
_usbCurrent |
protected int |
_userVar |
protected YModule.UpdateCallback |
_valueCallbackModule |
static int |
BEACON_INVALID |
static int |
BEACON_OFF
invalid beacon value
|
static int |
BEACON_ON |
static String |
FIRMWARERELEASE_INVALID
invalid firmwareRelease value
|
static int |
LUMINOSITY_INVALID
invalid luminosity value
|
static int |
PERSISTENTSETTINGS_INVALID |
static int |
PERSISTENTSETTINGS_LOADED
invalid persistentSettings value
|
static int |
PERSISTENTSETTINGS_MODIFIED |
static int |
PERSISTENTSETTINGS_SAVED |
static int |
PRODUCTID_INVALID
invalid productId value
|
static String |
PRODUCTNAME_INVALID
invalid productName value
|
static int |
PRODUCTRELEASE_INVALID
invalid productRelease value
|
static int |
REBOOTCOUNTDOWN_INVALID
invalid rebootCountdown value
|
static String |
SERIALNUMBER_INVALID
invalid serialNumber value
|
static long |
UPTIME_INVALID
invalid upTime value
|
static int |
USBCURRENT_INVALID
invalid usbCurrent value
|
static int |
USERVAR_INVALID
invalid userVar value
|
_advertisedValue, _cacheExpiration, _className, _dataStreams, _func, _funId, _hwId, _lastErrorMsg, _lastErrorType, _logicalName, _serial, _userData, _valueCallbackFunction, _yapi, ADVERTISEDVALUE_INVALID, FUNCTIONDESCRIPTOR_INVALID, LOGICALNAME_INVALID
Modifier | Constructor and Description |
---|---|
protected |
YModule(String func) |
protected |
YModule(YAPIContext yctx,
String func) |
Modifier and Type | Method and Description |
---|---|
byte[] |
_flattenJsonStruct(byte[] jsoncomplex) |
protected com.yoctopuce.YoctoAPI.YDevice |
_getDev() |
int |
_invokeConfigChangeCallback() |
int |
_invokeValueCallback(String value) |
protected void |
_parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) |
String |
calibConvert(String param,
String currentFuncValue,
String unit_name,
String sensorType) |
int |
calibOffset(String unit_name) |
int |
calibScale(String unit_name,
String sensorType) |
int |
calibVersion(String cparams) |
String |
checkFirmware(String path,
boolean onlynew)
Tests whether the byn file is valid for this module.
|
byte[] |
download(String pathname)
Downloads the specified built-in file and returns a binary buffer with its content.
|
static YModule |
FindModule(String func)
Allows you to find a module from its serial number or from its logical name.
|
static YModule |
FindModuleInContext(YAPIContext yctx,
String func)
Retrieves a module for a given identifier in a YAPI context.
|
static YModule |
FirstModule()
Starts the enumeration of modules currently accessible.
|
static YModule |
FirstModuleInContext(YAPIContext yctx)
comment from .yc definition
|
String |
functionBaseType(int functionIndex)
Retrieves the base type of the nth function on the module.
|
int |
functionCount()
Returns the number of functions (beside the "module" interface) available on the module.
|
String |
functionId(int functionIndex)
Retrieves the hardware identifier of the nth function on the module.
|
String |
functionName(int functionIndex)
Retrieves the logical name of the nth function on the module.
|
String |
functionType(int functionIndex)
Retrieves the type of the nth function on the module.
|
String |
functionValue(int functionIndex)
Retrieves the advertised value of the nth function on the module.
|
byte[] |
get_allSettings()
Returns all the settings and uploaded files of the module.
|
int |
get_beacon()
Returns the state of the localization beacon.
|
String |
get_firmwareRelease()
Returns the version of the firmware embedded in the module.
|
ArrayList<String> |
get_functionIds(String funType)
Retrieve all hardware identifier that match the type passed in argument.
|
byte[] |
get_icon2d()
Returns the icon of the module.
|
String |
get_lastLogs()
Returns a string with last logs of the module.
|
int |
get_luminosity()
Returns the luminosity of the module informative leds (from 0 to 100).
|
String |
get_parentHub()
Returns the serial number of the YoctoHub on which this module is connected.
|
int |
get_persistentSettings()
Returns the current state of persistent module settings.
|
int |
get_productId()
Returns the USB device identifier of the module.
|
String |
get_productName()
Returns the commercial name of the module, as set by the factory.
|
int |
get_productRelease()
Returns the hardware release version of the module.
|
int |
get_rebootCountdown()
Returns the remaining number of seconds before the module restarts, or zero when no
reboot has been scheduled.
|
String |
get_serialNumber()
Returns the serial number of the module, as set by the factory.
|
ArrayList<String> |
get_subDevices()
Returns a list of all the modules that are plugged into the current module.
|
long |
get_upTime()
Returns the number of milliseconds spent since the module was powered on.
|
String |
get_url()
Returns the URL used to access the module.
|
int |
get_usbCurrent()
Returns the current consumed by the module on the USB bus, in milli-amps.
|
int |
get_userVar()
Returns the value previously stored in this attribute.
|
int |
getBeacon()
Returns the state of the localization beacon.
|
String |
getFirmwareRelease()
Returns the version of the firmware embedded in the module.
|
int |
getLuminosity()
Returns the luminosity of the module informative leds (from 0 to 100).
|
int |
getPersistentSettings()
Returns the current state of persistent module settings.
|
int |
getProductId()
Returns the USB device identifier of the module.
|
String |
getProductName()
Returns the commercial name of the module, as set by the factory.
|
int |
getProductRelease()
Returns the hardware release version of the module.
|
int |
getRebootCountdown()
Returns the remaining number of seconds before the module restarts, or zero when no
reboot has been scheduled.
|
String |
getSerialNumber()
Returns the serial number of the module, as set by the factory.
|
long |
getUpTime()
Returns the number of milliseconds spent since the module was powered on.
|
int |
getUsbCurrent()
Returns the current consumed by the module on the USB bus, in milli-amps.
|
int |
getUserVar()
Returns the value previously stored in this attribute.
|
boolean |
hasFunction(String funcId)
Tests if the device includes a specific function.
|
int |
loadThermistorExtra(String funcId,
String jsonExtra) |
int |
log(String text)
Adds a text message to the device logs.
|
YModule |
nextModule()
Continues the module enumeration started using yFirstModule().
|
int |
reboot(int secBeforeReboot)
Schedules a simple module reboot after the given number of seconds.
|
int |
registerConfigChangeCallback(YModule.ConfigChangeCallback callback)
Register a callback function, to be called when a persistent settings in
a device configuration has been changed (e.g.
|
void |
registerLogCallback(YModule.LogCallback callback)
Registers a device log callback function.
|
int |
registerValueCallback(YModule.UpdateCallback callback)
Registers the callback function that is invoked on every change of advertised value.
|
int |
revertFromFlash()
Reloads the settings stored in the nonvolatile memory, as
when the module is powered on.
|
int |
saveToFlash()
Saves current settings in the nonvolatile memory of the module.
|
int |
set_allSettings(byte[] settings)
Restores all the settings of the device.
|
int |
set_allSettingsAndFiles(byte[] settings)
Restores all the settings and uploaded files to the module.
|
int |
set_beacon(int newval)
Turns on or off the module localization beacon.
|
int |
set_extraSettings(String jsonExtra) |
int |
set_luminosity(int newval)
Changes the luminosity of the module informative leds.
|
int |
set_persistentSettings(int newval) |
int |
set_rebootCountdown(int newval) |
int |
set_userVar(int newval)
Stores a 32 bit value in the device RAM.
|
int |
setBeacon(int newval)
Turns on or off the module localization beacon.
|
int |
setLuminosity(int newval)
Changes the luminosity of the module informative leds.
|
int |
setUserVar(int newval)
Stores a 32 bit value in the device RAM.
|
int |
triggerConfigChangeCallback()
Triggers a configuration change callback, to check if they are supported or not.
|
int |
triggerFirmwareUpdate(int secBeforeReboot)
Schedules a module reboot into special firmware update mode.
|
YFirmwareUpdate |
updateFirmware(String path)
Prepares a firmware update of the module.
|
YFirmwareUpdate |
updateFirmwareEx(String path,
boolean force)
Prepares a firmware update of the module.
|
_AddToCache, _clearDataStreamCache, _devRequest, _download, _escapeAttr, _FindFromCache, _FindFromCacheInContext, _get_json_path_struct, _get_json_path, _json_get_array, _json_get_key, _json_get_string, _parse, _parserHelper, _setAttr, _throw, _UpdateTimedReportCallbackList, _UpdateValueCallbackList, _upload, _upload, clearCache, describe, errMessage, errorMessage, errorType, errType, FindFunction, FindFunctionInContext, FirstFunction, FirstFunctionInContext, functionDescriptor, get_advertisedValue, get_errorMessage, get_errorType, get_friendlyName, get_functionDescriptor, get_functionId, get_hardwareId, get_logicalName, get_module, get_userData, getAdvertisedValue, getErrorMessage, getErrorType, getFriendlyName, getFunctionDescriptor, getFunctionId, getHardwareId, getLogicalName, getModule, getUserData, isOnline, load, loadAttribute, module, muteValueCallbacks, nextFunction, registerValueCallback, set_advertisedValue, set_logicalName, set_userData, setLogicalName, setUserData, toString, unmuteValueCallbacks, userData
public static final String PRODUCTNAME_INVALID
public static final String SERIALNUMBER_INVALID
public static final int PRODUCTID_INVALID
public static final int PRODUCTRELEASE_INVALID
public static final String FIRMWARERELEASE_INVALID
public static final int PERSISTENTSETTINGS_LOADED
public static final int PERSISTENTSETTINGS_SAVED
public static final int PERSISTENTSETTINGS_MODIFIED
public static final int PERSISTENTSETTINGS_INVALID
public static final int LUMINOSITY_INVALID
public static final int BEACON_OFF
public static final int BEACON_ON
public static final int BEACON_INVALID
public static final long UPTIME_INVALID
public static final int USBCURRENT_INVALID
public static final int REBOOTCOUNTDOWN_INVALID
public static final int USERVAR_INVALID
protected String _productName
protected String _serialNumber
protected int _productId
protected int _productRelease
protected String _firmwareRelease
protected int _persistentSettings
protected int _luminosity
protected int _beacon
protected long _upTime
protected int _usbCurrent
protected int _rebootCountdown
protected int _userVar
protected YModule.UpdateCallback _valueCallbackModule
protected YModule.LogCallback _logCallback
protected YModule.ConfigChangeCallback _confChangeCallback
protected YModule(YAPIContext yctx, String func)
func
- : functionidprotected YModule(String func)
protected com.yoctopuce.YoctoAPI.YDevice _getDev() throws YAPI_Exception
YAPI_Exception
public int functionCount() throws YAPI_Exception
YAPI_Exception
- on errorpublic String functionId(int functionIndex) throws YAPI_Exception
functionIndex
- : the index of the function for which the information is desired, starting at
0 for the first function.YAPI_Exception
- on errorpublic String functionType(int functionIndex) throws YAPI_Exception
functionIndex
- : the index of the function for which the information is desired, starting at
0 for the first function.YAPI_Exception
- on errorpublic String functionBaseType(int functionIndex) throws YAPI_Exception
functionIndex
- : the index of the function for which the information is desired, starting at
0 for the first function.YAPI_Exception
- on errorpublic String functionName(int functionIndex) throws YAPI_Exception
functionIndex
- : the index of the function for which the information is desired, starting at
0 for the first function.YAPI_Exception
- on errorpublic String functionValue(int functionIndex) throws YAPI_Exception
functionIndex
- : the index of the function for which the information is desired, starting at
0 for the first function.YAPI_Exception
- on errorpublic void registerLogCallback(YModule.LogCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the module object that emitted the log message, and the character string containing the log.protected void _parseAttr(com.yoctopuce.YoctoAPI.YJSONObject json_val) throws Exception
_parseAttr
in class YFunction
Exception
public String get_productName() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getProductName() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_serialNumber() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getSerialNumber() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_productId() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getProductId() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_productRelease() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getProductRelease() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_firmwareRelease() throws YAPI_Exception
YAPI_Exception
- on errorpublic String getFirmwareRelease() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_persistentSettings() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getPersistentSettings() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_persistentSettings(int newval) throws YAPI_Exception
YAPI_Exception
public int get_luminosity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getLuminosity() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_luminosity(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the luminosity of the module informative ledsYAPI_Exception
- on errorpublic int setLuminosity(int newval) throws YAPI_Exception
newval
- : an integer corresponding to the luminosity of the module informative ledsYAPI_Exception
- on errorpublic int get_beacon() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getBeacon() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_beacon(int newval) throws YAPI_Exception
newval
- : either YModule.BEACON_OFF or YModule.BEACON_ONYAPI_Exception
- on errorpublic int setBeacon(int newval) throws YAPI_Exception
newval
- : either Y_BEACON_OFF or Y_BEACON_ONYAPI_Exception
- on errorpublic long get_upTime() throws YAPI_Exception
YAPI_Exception
- on errorpublic long getUpTime() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_usbCurrent() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getUsbCurrent() throws YAPI_Exception
YAPI_Exception
- on errorpublic int get_rebootCountdown() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getRebootCountdown() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_rebootCountdown(int newval) throws YAPI_Exception
YAPI_Exception
public int get_userVar() throws YAPI_Exception
YAPI_Exception
- on errorpublic int getUserVar() throws YAPI_Exception
YAPI_Exception
- on errorpublic int set_userVar(int newval) throws YAPI_Exception
newval
- : an integerYAPI_Exception
- on errorpublic int setUserVar(int newval) throws YAPI_Exception
newval
- : an integerYAPI_Exception
- on errorpublic static YModule FindModule(String func)
func
- : a string containing either the serial number or
the logical name of the desired modulepublic static YModule FindModuleInContext(YAPIContext yctx, String func)
yctx
- : a YAPI contextfunc
- : a string that uniquely characterizes the modulepublic int registerValueCallback(YModule.UpdateCallback callback)
callback
- : the callback function to call, or a null pointer. The callback function should take two
arguments: the function object of which the value has changed, and the character string describing
the new advertised value.public int _invokeValueCallback(String value)
_invokeValueCallback
in class YFunction
public int saveToFlash() throws YAPI_Exception
YAPI_Exception
- on errorpublic int revertFromFlash() throws YAPI_Exception
YAPI_Exception
- on errorpublic int reboot(int secBeforeReboot) throws YAPI_Exception
secBeforeReboot
- : number of seconds before rebootingYAPI_Exception
- on errorpublic int triggerFirmwareUpdate(int secBeforeReboot) throws YAPI_Exception
secBeforeReboot
- : number of seconds before rebootingYAPI_Exception
- on errorpublic int registerConfigChangeCallback(YModule.ConfigChangeCallback callback)
callback
- : a procedure taking a YModule parameter, or null
to unregister a previously registered callback.public int _invokeConfigChangeCallback()
public int triggerConfigChangeCallback() throws YAPI_Exception
YAPI_Exception
public String checkFirmware(String path, boolean onlynew) throws YAPI_Exception
path
- : the path of a byn file or a directory that contains byn filesonlynew
- : returns only files that are strictly newerYAPI_Exception
- on errorpublic YFirmwareUpdate updateFirmwareEx(String path, boolean force) throws YAPI_Exception
path
- : the path of the .byn file to use.force
- : true to force the firmware update even if some prerequisites appear not to be metYAPI_Exception
public YFirmwareUpdate updateFirmware(String path) throws YAPI_Exception
path
- : the path of the .byn file to use.YAPI_Exception
public byte[] get_allSettings() throws YAPI_Exception
YAPI_Exception
- on errorpublic int loadThermistorExtra(String funcId, String jsonExtra) throws YAPI_Exception
YAPI_Exception
public int set_extraSettings(String jsonExtra) throws YAPI_Exception
YAPI_Exception
public int set_allSettingsAndFiles(byte[] settings) throws YAPI_Exception
settings
- : a binary buffer with all the settings.YAPI_Exception
- on errorpublic boolean hasFunction(String funcId) throws YAPI_Exception
funcId
- : the requested function identifierYAPI_Exception
public ArrayList<String> get_functionIds(String funType) throws YAPI_Exception
funType
- : The type of function (Relay, LightSensor, Voltage,...)YAPI_Exception
public byte[] _flattenJsonStruct(byte[] jsoncomplex) throws YAPI_Exception
YAPI_Exception
public int calibVersion(String cparams)
public int calibOffset(String unit_name)
public String calibConvert(String param, String currentFuncValue, String unit_name, String sensorType)
public int set_allSettings(byte[] settings) throws YAPI_Exception
settings
- : a binary buffer with all the settings.YAPI_Exception
- on errorpublic byte[] download(String pathname) throws YAPI_Exception
pathname
- : name of the new file to loadYAPI_Exception
- on errorpublic byte[] get_icon2d() throws YAPI_Exception
YAPI_Exception
- on errorpublic String get_lastLogs() throws YAPI_Exception
YAPI_Exception
- on errorpublic int log(String text) throws YAPI_Exception
text
- : the string to append to the logs.YAPI_Exception
- on errorpublic ArrayList<String> get_subDevices() throws YAPI_Exception
YAPI_Exception
public String get_parentHub() throws YAPI_Exception
YAPI_Exception
public String get_url() throws YAPI_Exception
YAPI_Exception
public YModule nextModule()
public static YModule FirstModule()
public static YModule FirstModuleInContext(YAPIContext yctx)
Copyright © 2018. All rights reserved.