Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | Friends | List of all members
YModule Class Reference

#include <yocto_api.h>

Inheritance diagram for YModule:
Inheritance graph
[legend]

Public Member Functions

virtual string _flattenJsonStruct (string jsoncomplex)
 
virtual int _invokeValueCallback (string value)
 
Y_BEACON_enum beacon (void)
 
virtual string calibConvert (string param, string currentFuncValue, string unit_name, string sensorType)
 
virtual int calibOffset (string unit_name)
 
virtual int calibScale (string unit_name, string sensorType)
 
virtual int calibVersion (string cparams)
 
virtual string checkFirmware (string path, bool onlynew)
 
virtual string download (string pathname)
 
string firmwareRelease (void)
 
string functionBaseType (int functionIndex)
 
int functionCount ()
 
string functionId (int functionIndex)
 
string functionName (int functionIndex)
 
string functionType (int functionIndex)
 
string functionValue (int functionIndex)
 
virtual string get_allSettings (void)
 
Y_BEACON_enum get_beacon (void)
 
string get_firmwareRelease (void)
 
virtual string get_friendlyName (void)
 
virtual vector< string > get_functionIds (string funType)
 
virtual string get_icon2d (void)
 
virtual string get_lastLogs (void)
 
YModuleLogCallback get_logCallback ()
 
int get_luminosity (void)
 
virtual string get_parentHub (void)
 
Y_PERSISTENTSETTINGS_enum get_persistentSettings (void)
 
int get_productId (void)
 
string get_productName (void)
 
int get_productRelease (void)
 
int get_rebootCountdown (void)
 
string get_serialNumber (void)
 
virtual vector< string > get_subDevices (void)
 
s64 get_upTime (void)
 
virtual string get_url (void)
 
int get_usbCurrent (void)
 
int get_userVar (void)
 
virtual bool hasFunction (string funcId)
 
virtual int loadThermistorExtra (string funcId, string jsonExtra)
 
virtual int log (string text)
 
int luminosity (void)
 
YModulenext (void)
 
YModulenextModule (void)
 
Y_PERSISTENTSETTINGS_enum persistentSettings (void)
 
int productId (void)
 
string productName (void)
 
int productRelease (void)
 
virtual int reboot (int secBeforeReboot)
 
int rebootCountdown (void)
 
void registerLogCallback (YModuleLogCallback callback)
 
virtual int registerValueCallback (YModuleValueCallback callback)
 
virtual int revertFromFlash (void)
 
virtual int saveToFlash (void)
 
string serialNumber (void)
 
virtual int set_allSettings (string settings)
 
virtual int set_allSettingsAndFiles (string settings)
 
int set_beacon (Y_BEACON_enum newval)
 
virtual int set_extraSettings (string jsonExtra)
 
int set_luminosity (int newval)
 
int set_persistentSettings (Y_PERSISTENTSETTINGS_enum newval)
 
int set_rebootCountdown (int newval)
 
int set_userVar (int newval)
 
int setBeacon (Y_BEACON_enum newval)
 
void setImmutableAttributes (yDeviceSt *infos)
 
int setLuminosity (int newval)
 
int setPersistentSettings (Y_PERSISTENTSETTINGS_enum newval)
 
int setRebootCountdown (int newval)
 
int setUserVar (int newval)
 
virtual int triggerFirmwareUpdate (int secBeforeReboot)
 
virtual YFirmwareUpdate updateFirmware (string path)
 
virtual YFirmwareUpdate updateFirmwareEx (string path, bool force)
 
s64 upTime (void)
 
int usbCurrent (void)
 
int userVar (void)
 
 ~YModule ()
 
- Public Member Functions inherited from YFunction
void _clearDataStreamCache ()
 
string _decode_json_string (const string &json)
 
string _download (const string &url)
 
YDataStream_findDataStream (YDataSet &dataset, const string &def)
 
string _get_json_path (const string &json, const string &path)
 
vector< string > _json_get_array (const string &json)
 
string _json_get_key (const string &json, const string &data)
 
string _json_get_string (const string &json)
 
int _parseEx (yJsonStateMachine &j)
 
virtual int _parserHelper (void)
 
string _parseString (yJsonStateMachine &j)
 
string _request (const string &request)
 
string _requestEx (int tcpchan, const string &request, yapiRequestProgressCallback callback, void *context)
 
void _throw (YRETCODE errType, string errMsg)
 
YRETCODE _upload (const string &path, const string &content)
 
YRETCODE _uploadWithProgress (const string &path, const string &content, yapiRequestProgressCallback callback, void *context)
 
string advertisedValue (void)
 
void clearCache ()
 
string describe (void)
 
string errMessage (void)
 
string errorMessage (void)
 
YRETCODE errorType (void)
 
YRETCODE errType (void)
 
YFUN_DESCR functionDescriptor (void)
 
string get_advertisedValue (void)
 
string get_errorMessage (void)
 
YRETCODE get_errorType (void)
 
YFUN_DESCR get_functionDescriptor (void)
 
string get_functionId (void)
 
string get_hardwareId (void)
 
string get_hubSerial ()
 
string get_logicalName (void)
 
YModuleget_module (void)
 
void * get_userData (void)
 
bool isOnline (void)
 
YRETCODE load (int msValidity)
 
virtual string loadAttribute (string attrName)
 
string logicalName (void)
 
YModulemodule (void)
 
virtual int muteValueCallbacks (void)
 
YFunctionnext (void)
 
YFunctionnextFunction (void)
 
virtual int registerValueCallback (YFunctionValueCallback callback)
 
int set_advertisedValue (const string &newval)
 
int set_logicalName (const string &newval)
 
void set_userData (void *data)
 
int setAdvertisedValue (const string &newval)
 
int setLogicalName (const string &newval)
 
void setUserData (void *data)
 
virtual int unmuteValueCallbacks (void)
 
void * userData (void)
 
virtual ~YFunction ()
 

Static Public Member Functions

static YModuleFind (string func)
 
static YModuleFindModule (string func)
 
static YModuleFirst (void)
 
static YModuleFirstModule (void)
 
- Static Public Member Functions inherited from YFunction
static void _ClearCache (void)
 
static YFunctionFind (string func)
 
static YFunctionFindFunction (string func)
 
static YFunctionFirst (void)
 
static YFunctionFirstFunction (void)
 

Static Public Attributes

static const Y_BEACON_enum BEACON_INVALID = Y_BEACON_INVALID
 
static const Y_BEACON_enum BEACON_OFF = Y_BEACON_OFF
 
static const Y_BEACON_enum BEACON_ON = Y_BEACON_ON
 
static const string FIRMWARERELEASE_INVALID = YAPI_INVALID_STRING
 
static const int LUMINOSITY_INVALID = YAPI_INVALID_UINT
 
static const Y_PERSISTENTSETTINGS_enum PERSISTENTSETTINGS_INVALID = Y_PERSISTENTSETTINGS_INVALID
 
static const Y_PERSISTENTSETTINGS_enum PERSISTENTSETTINGS_LOADED = Y_PERSISTENTSETTINGS_LOADED
 
static const Y_PERSISTENTSETTINGS_enum PERSISTENTSETTINGS_MODIFIED = Y_PERSISTENTSETTINGS_MODIFIED
 
static const Y_PERSISTENTSETTINGS_enum PERSISTENTSETTINGS_SAVED = Y_PERSISTENTSETTINGS_SAVED
 
static const int PRODUCTID_INVALID = YAPI_INVALID_UINT
 
static const string PRODUCTNAME_INVALID = YAPI_INVALID_STRING
 
static const int PRODUCTRELEASE_INVALID = YAPI_INVALID_UINT
 
static const int REBOOTCOUNTDOWN_INVALID = YAPI_INVALID_INT
 
static const string SERIALNUMBER_INVALID = YAPI_INVALID_STRING
 
static const s64 UPTIME_INVALID = YAPI_INVALID_LONG
 
static const int USBCURRENT_INVALID = YAPI_INVALID_UINT
 
static const int USERVAR_INVALID = YAPI_INVALID_INT
 
- Static Public Attributes inherited from YFunction
static const string ADVERTISEDVALUE_INVALID = YAPI_INVALID_STRING
 
static const string FRIENDLYNAME_INVALID = YAPI_INVALID_STRING
 
static const YFUN_DESCR FUNCTIONDESCRIPTOR_INVALID = Y_FUNCTIONDESCRIPTOR_INVALID
 
static const string FUNCTIONID_INVALID = YAPI_INVALID_STRING
 
static const string HARDWAREID_INVALID = YAPI_INVALID_STRING
 
static const string LOGICALNAME_INVALID = YAPI_INVALID_STRING
 

Protected Member Functions

YRETCODE _getFunction (int idx, string &serial, string &funcId, string &baseType, string &funcName, string &funcVal, string &errMsg)
 
virtual int _parseAttr (YJSONObject *json_val)
 
 YModule (const string &func)
 
- Protected Member Functions inherited from YFunction
YRETCODE _buildSetRequest (const string &changeattr, const string *changeval, string &request, string &errmsg)
 
string _escapeAttr (const string &changeval)
 
YRETCODE _getDescriptor (YFUN_DESCR &fundescr, string &errMsg)
 
YRETCODE _getDevice (YDevice *&dev, string &errMsg)
 
YRETCODE _load_unsafe (int msValidity)
 
YRETCODE _nextFunction (string &hwId)
 
int _parse (YJSONObject *j)
 
YRETCODE _setAttr (string attrname, string newvalue)
 
 YFunction (const string &func)
 

Protected Attributes

Y_BEACON_enum _beacon
 
string _firmwareRelease
 
YModuleLogCallback _logCallback
 
int _luminosity
 
Y_PERSISTENTSETTINGS_enum _persistentSettings
 
int _productId
 
string _productName
 
int _productRelease
 
int _rebootCountdown
 
string _serialNumber
 
s64 _upTime
 
int _usbCurrent
 
int _userVar
 
YModuleValueCallback _valueCallbackModule
 
- Protected Attributes inherited from YFunction
string _advertisedValue
 
u64 _cacheExpiration
 
string _className
 
std::map< string, YDataStream * > _dataStreams
 
string _func
 
YFUN_DESCR _fundescr
 
string _funId
 
string _hwId
 
string _lastErrorMsg
 
YRETCODE _lastErrorType
 
string _logicalName
 
string _serial
 
yCRITICAL_SECTION _this_cs
 
void * _userData
 
YFunctionValueCallback _valueCallbackFunction
 

Friends

YModuleyFindModule (const string &func)
 
YModuleyFirstModule (void)
 

Additional Inherited Members

- Static Protected Member Functions inherited from YFunction
static void _AddToCache (const string &classname, const string &func, YFunction *obj)
 
static YFunction_FindFromCache (const string &classname, const string &func)
 
static void _UpdateTimedReportCallbackList (YFunction *func, bool add)
 
static void _UpdateValueCallbackList (YFunction *func, bool add)
 
- Static Protected Attributes inherited from YFunction
static std::map< string, YFunction * > _cache
 

Detailed Description

YModule Class: Module control interface

This interface is identical for all Yoctopuce USB modules. It can be used to control the module global parameters, and to enumerate the functions provided by each module.

Definition at line 1991 of file yocto_api.h.

Constructor & Destructor Documentation

YModule::YModule ( const string &  func)
protected

Definition at line 5036 of file yocto_api.cpp.

YModule::~YModule ( )

Definition at line 5058 of file yocto_api.cpp.

Member Function Documentation

string YModule::_flattenJsonStruct ( string  jsoncomplex)
virtual

Definition at line 6012 of file yocto_api.cpp.

YRETCODE YModule::_getFunction ( int  idx,
string &  serial,
string &  funcId,
string &  baseType,
string &  funcName,
string &  funcVal,
string &  errMsg 
)
protected

Definition at line 6770 of file yocto_api.cpp.

int YModule::_invokeValueCallback ( string  value)
virtual

Reimplemented from YFunction.

Definition at line 5651 of file yocto_api.cpp.

int YModule::_parseAttr ( YJSONObject json_val)
protectedvirtual

Reimplemented from YFunction.

Definition at line 5073 of file yocto_api.cpp.

Y_BEACON_enum YModule::beacon ( void  )
inline

Definition at line 2270 of file yocto_api.h.

string YModule::calibConvert ( string  param,
string  currentFuncValue,
string  unit_name,
string  sensorType 
)
virtual

Definition at line 6099 of file yocto_api.cpp.

int YModule::calibOffset ( string  unit_name)
virtual

Definition at line 6091 of file yocto_api.cpp.

int YModule::calibScale ( string  unit_name,
string  sensorType 
)
virtual

Definition at line 6070 of file yocto_api.cpp.

int YModule::calibVersion ( string  cparams)
virtual

Definition at line 6048 of file yocto_api.cpp.

string YModule::checkFirmware ( string  path,
bool  onlynew 
)
virtual

Tests whether the byn file is valid for this module. This method is useful to test if the module needs to be updated. It is possible to pass a directory as argument instead of a file. In this case, this method returns the path of the most recent appropriate .byn file. If the parameter onlynew is true, the function discards firmwares that are older or equal to the installed firmware.

Parameters
path: the path of a byn file or a directory that contains byn files
onlynew: returns only files that are strictly newer
Returns
the path of the byn file to use or a empty string if no byn files matches the requirement

On failure, throws an exception or returns a string that start with "error:".

Definition at line 5731 of file yocto_api.cpp.

string YModule::download ( string  pathname)
virtual

Downloads the specified built-in file and returns a binary buffer with its content.

Parameters
pathname: name of the new file to load
Returns
a binary buffer with the file content

On failure, throws an exception or returns YAPI_INVALID_STRING.

Definition at line 6563 of file yocto_api.cpp.

static YModule* YModule::Find ( string  func)
inlinestatic

Definition at line 2616 of file yocto_api.h.

YModule * YModule::FindModule ( string  func)
static

Allows you to find a module from its serial number or from its logical name.

This function does not require that the module is online at the time it is invoked. The returned object is nevertheless valid. Use the method YModule.isOnline() to test if the module is indeed online at a given time. In case of ambiguity when looking for a module by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string containing either the serial number or the logical name of the desired module
Returns
a YModule object allowing you to drive the module or get additional information on the module.

Definition at line 5600 of file yocto_api.cpp.

string YModule::firmwareRelease ( void  )
inline

Definition at line 2213 of file yocto_api.h.

static YModule* YModule::First ( void  )
inlinestatic

Definition at line 2640 of file yocto_api.h.

YModule * YModule::FirstModule ( void  )
static

Starts the enumeration of modules currently accessible. Use the method YModule.nextModule() to iterate on the next modules.

Returns
a pointer to a YModule object, corresponding to the first module currently online, or a NULL pointer if there are none.

Definition at line 6715 of file yocto_api.cpp.

string YModule::functionBaseType ( int  functionIndex)

Retrieves the base type of the nth function on the module. For instance, the base type of all measuring functions is "Sensor".

Parameters
functionIndex: the index of the function for which the information is desired, starting at 0 for the first function.
Returns
a string corresponding to the base type of the function

On failure, throws an exception or returns an empty string.

Definition at line 6915 of file yocto_api.cpp.

int YModule::functionCount ( )

Returns the number of functions (beside the "module" interface) available on the module.

Returns
the number of functions on the module

On failure, throws an exception or returns a negative error code.

Definition at line 6798 of file yocto_api.cpp.

string YModule::functionId ( int  functionIndex)

Retrieves the hardware identifier of the nth function on the module.

Parameters
functionIndex: the index of the function for which the information is desired, starting at 0 for the first function.
Returns
a string corresponding to the unambiguous hardware identifier of the requested module function

On failure, throws an exception or returns an empty string.

Definition at line 6823 of file yocto_api.cpp.

string YModule::functionName ( int  functionIndex)

Retrieves the logical name of the nth function on the module.

Parameters
functionIndex: the index of the function for which the information is desired, starting at 0 for the first function.
Returns
a string corresponding to the logical name of the requested module function

On failure, throws an exception or returns an empty string.

Definition at line 6844 of file yocto_api.cpp.

string YModule::functionType ( int  functionIndex)

Retrieves the type of the nth function on the module.

Parameters
functionIndex: the index of the function for which the information is desired, starting at 0 for the first function.
Returns
a string corresponding to the type of the function

On failure, throws an exception or returns an empty string.

Definition at line 6887 of file yocto_api.cpp.

string YModule::functionValue ( int  functionIndex)

Retrieves the advertised value of the nth function on the module.

Parameters
functionIndex: the index of the function for which the information is desired, starting at 0 for the first function.
Returns
a short string (up to 6 characters) corresponding to the advertised value of the requested module function

On failure, throws an exception or returns an empty string.

Definition at line 6865 of file yocto_api.cpp.

string YModule::get_allSettings ( void  )
virtual

Returns all the settings and uploaded files of the module. Useful to backup all the logical names, calibrations parameters, and uploaded files of a device.

Returns
a binary buffer with all the settings.

On failure, throws an exception or returns an binary object of size 0.

Definition at line 5794 of file yocto_api.cpp.

Y_BEACON_enum YModule::get_beacon ( void  )

Returns the state of the localization beacon.

Returns
either Y_BEACON_OFF or Y_BEACON_ON, according to the state of the localization beacon

On failure, throws an exception or returns Y_BEACON_INVALID.

Definition at line 5370 of file yocto_api.cpp.

string YModule::get_firmwareRelease ( void  )

Returns the version of the firmware embedded in the module.

Returns
a string corresponding to the version of the firmware embedded in the module

On failure, throws an exception or returns Y_FIRMWARERELEASE_INVALID.

Definition at line 5238 of file yocto_api.cpp.

string YModule::get_friendlyName ( void  )
virtual

Returns a global identifier of the function in the format MODULE_NAME&#46;FUNCTION_NAME. The returned string uses the logical names of the module and of the function if they are defined, otherwise the serial number of the module and the hardware identifier of the function (for example: MyCustomName.relay1)

Returns
a string that uniquely identifies the function using logical names (ex: MyCustomName.relay1)

On failure, throws an exception or returns Y_FRIENDLYNAME_INVALID.

Reimplemented from YFunction.

Definition at line 6732 of file yocto_api.cpp.

vector< string > YModule::get_functionIds ( string  funType)
virtual

Retrieve all hardware identifier that match the type passed in argument.

Parameters
funType: The type of function (Relay, LightSensor, Voltage,...)
Returns
an array of strings.

Definition at line 5988 of file yocto_api.cpp.

string YModule::get_icon2d ( void  )
virtual

Returns the icon of the module. The icon is a PNG image and does not exceeds 1536 bytes.

Returns
a binary buffer with module icon, in png format. On failure, throws an exception or returns YAPI_INVALID_STRING.

Definition at line 6575 of file yocto_api.cpp.

string YModule::get_lastLogs ( void  )
virtual

Returns a string with last logs of the module. This method return only logs that are still in the module.

Returns
a string with last logs of the module. On failure, throws an exception or returns YAPI_INVALID_STRING.

Definition at line 6587 of file yocto_api.cpp.

YModuleLogCallback YModule::get_logCallback ( )

Definition at line 6952 of file yocto_api.cpp.

int YModule::get_luminosity ( void  )

Returns the luminosity of the module informative leds (from 0 to 100).

Returns
an integer corresponding to the luminosity of the module informative leds (from 0 to 100)

On failure, throws an exception or returns Y_LUMINOSITY_INVALID.

Definition at line 5313 of file yocto_api.cpp.

string YModule::get_parentHub ( void  )
virtual

Returns the serial number of the YoctoHub on which this module is connected. If the module is connected by USB, or if the module is the root YoctoHub, an empty string is returned.

Returns
a string with the serial number of the YoctoHub or an empty string

Definition at line 6663 of file yocto_api.cpp.

Y_PERSISTENTSETTINGS_enum YModule::get_persistentSettings ( void  )

Returns the current state of persistent module settings.

Returns
a value among Y_PERSISTENTSETTINGS_LOADED, Y_PERSISTENTSETTINGS_SAVED and Y_PERSISTENTSETTINGS_MODIFIED corresponding to the current state of persistent module settings

On failure, throws an exception or returns Y_PERSISTENTSETTINGS_INVALID.

Definition at line 5268 of file yocto_api.cpp.

int YModule::get_productId ( void  )

Returns the USB device identifier of the module.

Returns
an integer corresponding to the USB device identifier of the module

On failure, throws an exception or returns Y_PRODUCTID_INVALID.

Definition at line 5180 of file yocto_api.cpp.

string YModule::get_productName ( void  )

Returns the commercial name of the module, as set by the factory.

Returns
a string corresponding to the commercial name of the module, as set by the factory

On failure, throws an exception or returns Y_PRODUCTNAME_INVALID.

Definition at line 5122 of file yocto_api.cpp.

int YModule::get_productRelease ( void  )

Returns the hardware release version of the module.

Returns
an integer corresponding to the hardware release version of the module

On failure, throws an exception or returns Y_PRODUCTRELEASE_INVALID.

Definition at line 5209 of file yocto_api.cpp.

int YModule::get_rebootCountdown ( void  )

Returns the remaining number of seconds before the module restarts, or zero when no reboot has been scheduled.

Returns
an integer corresponding to the remaining number of seconds before the module restarts, or zero when no reboot has been scheduled

On failure, throws an exception or returns Y_REBOOTCOUNTDOWN_INVALID.

Definition at line 5484 of file yocto_api.cpp.

string YModule::get_serialNumber ( void  )

Returns the serial number of the module, as set by the factory.

Returns
a string corresponding to the serial number of the module, as set by the factory

On failure, throws an exception or returns Y_SERIALNUMBER_INVALID.

Definition at line 5151 of file yocto_api.cpp.

vector< string > YModule::get_subDevices ( void  )
virtual

Returns a list of all the modules that are plugged into the current module. This method only makes sense when called for a YoctoHub/VirtualHub. Otherwise, an empty array will be returned.

Returns
an array of strings containing the sub modules.

Definition at line 6618 of file yocto_api.cpp.

s64 YModule::get_upTime ( void  )

Returns the number of milliseconds spent since the module was powered on.

Returns
an integer corresponding to the number of milliseconds spent since the module was powered on

On failure, throws an exception or returns Y_UPTIME_INVALID.

Definition at line 5424 of file yocto_api.cpp.

string YModule::get_url ( void  )
virtual

Returns the URL used to access the module. If the module is connected by USB, the string 'usb' is returned.

Returns
a string with the URL of the module.

Definition at line 6687 of file yocto_api.cpp.

int YModule::get_usbCurrent ( void  )

Returns the current consumed by the module on the USB bus, in milli-amps.

Returns
an integer corresponding to the current consumed by the module on the USB bus, in milli-amps

On failure, throws an exception or returns Y_USBCURRENT_INVALID.

Definition at line 5453 of file yocto_api.cpp.

int YModule::get_userVar ( void  )

Returns the value previously stored in this attribute. On startup and after a device reboot, the value is always reset to zero.

Returns
an integer corresponding to the value previously stored in this attribute

On failure, throws an exception or returns Y_USERVAR_INVALID.

Definition at line 5530 of file yocto_api.cpp.

bool YModule::hasFunction ( string  funcId)
virtual

Tests if the device includes a specific function. This method takes a function identifier and returns a boolean.

Parameters
funcId: the requested function identifier
Returns
true if the device has the function identifier

Definition at line 5963 of file yocto_api.cpp.

int YModule::loadThermistorExtra ( string  funcId,
string  jsonExtra 
)
virtual

Definition at line 5858 of file yocto_api.cpp.

int YModule::log ( string  text)
virtual

Adds a text message to the device logs. This function is useful in particular to trace the execution of HTTP callbacks. If a newline is desired after the message, it must be included in the string.

Parameters
text: the string to append to the logs.
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 6606 of file yocto_api.cpp.

int YModule::luminosity ( void  )
inline

Definition at line 2242 of file yocto_api.h.

YModule* YModule::next ( void  )
inline

Definition at line 2627 of file yocto_api.h.

YModule * YModule::nextModule ( void  )

Continues the module enumeration started using yFirstModule().

Returns
a pointer to a YModule object, corresponding to the next module found, or a NULL pointer if there are no more modules to enumerate.

Definition at line 6705 of file yocto_api.cpp.

Y_PERSISTENTSETTINGS_enum YModule::persistentSettings ( void  )
inline

Definition at line 2226 of file yocto_api.h.

int YModule::productId ( void  )
inline

Definition at line 2189 of file yocto_api.h.

string YModule::productName ( void  )
inline

Definition at line 2165 of file yocto_api.h.

int YModule::productRelease ( void  )
inline

Definition at line 2201 of file yocto_api.h.

int YModule::reboot ( int  secBeforeReboot)
virtual

Schedules a simple module reboot after the given number of seconds.

Parameters
secBeforeReboot: number of seconds before rebooting
Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5697 of file yocto_api.cpp.

int YModule::rebootCountdown ( void  )
inline

Definition at line 2321 of file yocto_api.h.

void YModule::registerLogCallback ( YModuleLogCallback  callback)

Registers a device log callback function. This callback will be called each time that a module sends a new log message. Mostly useful to debug a Yoctopuce module.

Parameters
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.

Definition at line 6944 of file yocto_api.cpp.

int YModule::registerValueCallback ( YModuleValueCallback  callback)
virtual

Registers the callback function that is invoked on every change of advertised value. The callback is invoked only during the execution of ySleep or yHandleEvents. This provides control over the time when the callback is triggered. For good responsiveness, remember to call one of these two functions periodically. To unregister a callback, pass a NULL pointer as argument.

Parameters
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.

Definition at line 5632 of file yocto_api.cpp.

int YModule::revertFromFlash ( void  )
virtual

Reloads the settings stored in the nonvolatile memory, as when the module is powered on.

Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5683 of file yocto_api.cpp.

int YModule::saveToFlash ( void  )
virtual

Saves current settings in the nonvolatile memory of the module. Warning: the number of allowed save operations during a module life is limited (about 100000 cycles). Do not call this function within a loop.

Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5670 of file yocto_api.cpp.

string YModule::serialNumber ( void  )
inline

Definition at line 2177 of file yocto_api.h.

int YModule::set_allSettings ( string  settings)
virtual

Restores all the settings of the device. Useful to restore all the logical names and calibrations parameters of a module from a backup.Remember to call the saveToFlash() method of the module if the modifications must be kept.

Parameters
settings: a binary buffer with all the settings.
Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 6279 of file yocto_api.cpp.

int YModule::set_allSettingsAndFiles ( string  settings)
virtual

Restores all the settings and uploaded files to the module. This method is useful to restore all the logical names and calibrations parameters, uploaded files etc. of a device from a backup. Remember to call the saveToFlash() method of the module if the modifications must be kept.

Parameters
settings: a binary buffer with all the settings.
Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5913 of file yocto_api.cpp.

int YModule::set_beacon ( Y_BEACON_enum  newval)

Turns on or off the module localization beacon.

Parameters
newval: either Y_BEACON_OFF or Y_BEACON_ON
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5401 of file yocto_api.cpp.

int YModule::set_extraSettings ( string  jsonExtra)
virtual

Definition at line 5883 of file yocto_api.cpp.

int YModule::set_luminosity ( int  newval)

Changes the luminosity of the module informative leds. The parameter is a value between 0 and 100. Remember to call the saveToFlash() method of the module if the modification must be kept.

Parameters
newval: an integer corresponding to the luminosity of the module informative leds
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5347 of file yocto_api.cpp.

int YModule::set_persistentSettings ( Y_PERSISTENTSETTINGS_enum  newval)

Definition at line 5290 of file yocto_api.cpp.

int YModule::set_rebootCountdown ( int  newval)

Definition at line 5506 of file yocto_api.cpp.

int YModule::set_userVar ( int  newval)

Stores a 32 bit value in the device RAM. This attribute is at programmer disposal, should he need to store a state variable. On startup and after a device reboot, the value is always reset to zero.

Parameters
newval: an integer
Returns
YAPI_SUCCESS if the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5563 of file yocto_api.cpp.

int YModule::setBeacon ( Y_BEACON_enum  newval)
inline

Definition at line 2283 of file yocto_api.h.

void YModule::setImmutableAttributes ( yDeviceSt infos)

Definition at line 6759 of file yocto_api.cpp.

int YModule::setLuminosity ( int  newval)
inline

Definition at line 2258 of file yocto_api.h.

int YModule::setPersistentSettings ( Y_PERSISTENTSETTINGS_enum  newval)
inline

Definition at line 2230 of file yocto_api.h.

int YModule::setRebootCountdown ( int  newval)
inline

Definition at line 2325 of file yocto_api.h.

int YModule::setUserVar ( int  newval)
inline

Definition at line 2353 of file yocto_api.h.

int YModule::triggerFirmwareUpdate ( int  secBeforeReboot)
virtual

Schedules a module reboot into special firmware update mode.

Parameters
secBeforeReboot: number of seconds before rebooting
Returns
YAPI_SUCCESS when the call succeeds.

On failure, throws an exception or returns a negative error code.

Definition at line 5711 of file yocto_api.cpp.

YFirmwareUpdate YModule::updateFirmware ( string  path)
virtual

Prepares a firmware update of the module. This method returns a YFirmwareUpdate object which handles the firmware update process.

Parameters
path: the path of the .byn file to use.
Returns
a YFirmwareUpdate object or NULL on error.

Definition at line 5781 of file yocto_api.cpp.

YFirmwareUpdate YModule::updateFirmwareEx ( string  path,
bool  force 
)
virtual

Prepares a firmware update of the module. This method returns a YFirmwareUpdate object which handles the firmware update process.

Parameters
path: the path of the .byn file to use.
force: true to force the firmware update even if some prerequisites appear not to be met
Returns
a YFirmwareUpdate object or NULL on error.

Definition at line 5759 of file yocto_api.cpp.

s64 YModule::upTime ( void  )
inline

Definition at line 2295 of file yocto_api.h.

int YModule::usbCurrent ( void  )
inline

Definition at line 2307 of file yocto_api.h.

int YModule::userVar ( void  )
inline

Definition at line 2338 of file yocto_api.h.

Friends And Related Function Documentation

YModule* yFindModule ( const string &  func)
friend

Allows you to find a module from its serial number or from its logical name.

This function does not require that the module is online at the time it is invoked. The returned object is nevertheless valid. Use the method YModule.isOnline() to test if the module is indeed online at a given time. In case of ambiguity when looking for a module by logical name, no error is notified: the first instance found is returned. The search is performed first by hardware name, then by logical name.

If a call to this object's is_online() method returns FALSE although you are certain that the device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string containing either the serial number or the logical name of the desired module
Returns
a YModule object allowing you to drive the module or get additional information on the module.

Definition at line 3548 of file yocto_api.h.

YModule* yFirstModule ( void  )
friend

Starts the enumeration of modules currently accessible. Use the method YModule.nextModule() to iterate on the next modules.

Returns
a pointer to a YModule object, corresponding to the first module currently online, or a NULL pointer if there are none.

Definition at line 3559 of file yocto_api.h.

Member Data Documentation

Y_BEACON_enum YModule::_beacon
protected

Definition at line 2006 of file yocto_api.h.

string YModule::_firmwareRelease
protected

Definition at line 2003 of file yocto_api.h.

YModuleLogCallback YModule::_logCallback
protected

Definition at line 2012 of file yocto_api.h.

int YModule::_luminosity
protected

Definition at line 2005 of file yocto_api.h.

Y_PERSISTENTSETTINGS_enum YModule::_persistentSettings
protected

Definition at line 2004 of file yocto_api.h.

int YModule::_productId
protected

Definition at line 2001 of file yocto_api.h.

string YModule::_productName
protected

Definition at line 1999 of file yocto_api.h.

int YModule::_productRelease
protected

Definition at line 2002 of file yocto_api.h.

int YModule::_rebootCountdown
protected

Definition at line 2009 of file yocto_api.h.

string YModule::_serialNumber
protected

Definition at line 2000 of file yocto_api.h.

s64 YModule::_upTime
protected

Definition at line 2007 of file yocto_api.h.

int YModule::_usbCurrent
protected

Definition at line 2008 of file yocto_api.h.

int YModule::_userVar
protected

Definition at line 2010 of file yocto_api.h.

YModuleValueCallback YModule::_valueCallbackModule
protected

Definition at line 2011 of file yocto_api.h.

const Y_BEACON_enum YModule::BEACON_INVALID = Y_BEACON_INVALID
static

Definition at line 2150 of file yocto_api.h.

const Y_BEACON_enum YModule::BEACON_OFF = Y_BEACON_OFF
static

Definition at line 2148 of file yocto_api.h.

const Y_BEACON_enum YModule::BEACON_ON = Y_BEACON_ON
static

Definition at line 2149 of file yocto_api.h.

const string YModule::FIRMWARERELEASE_INVALID = YAPI_INVALID_STRING
static

Definition at line 2142 of file yocto_api.h.

const int YModule::LUMINOSITY_INVALID = YAPI_INVALID_UINT
static

Definition at line 2147 of file yocto_api.h.

const Y_PERSISTENTSETTINGS_enum YModule::PERSISTENTSETTINGS_INVALID = Y_PERSISTENTSETTINGS_INVALID
static

Definition at line 2146 of file yocto_api.h.

const Y_PERSISTENTSETTINGS_enum YModule::PERSISTENTSETTINGS_LOADED = Y_PERSISTENTSETTINGS_LOADED
static

Definition at line 2143 of file yocto_api.h.

const Y_PERSISTENTSETTINGS_enum YModule::PERSISTENTSETTINGS_MODIFIED = Y_PERSISTENTSETTINGS_MODIFIED
static

Definition at line 2145 of file yocto_api.h.

const Y_PERSISTENTSETTINGS_enum YModule::PERSISTENTSETTINGS_SAVED = Y_PERSISTENTSETTINGS_SAVED
static

Definition at line 2144 of file yocto_api.h.

const int YModule::PRODUCTID_INVALID = YAPI_INVALID_UINT
static

Definition at line 2140 of file yocto_api.h.

const string YModule::PRODUCTNAME_INVALID = YAPI_INVALID_STRING
static

Definition at line 2138 of file yocto_api.h.

const int YModule::PRODUCTRELEASE_INVALID = YAPI_INVALID_UINT
static

Definition at line 2141 of file yocto_api.h.

const int YModule::REBOOTCOUNTDOWN_INVALID = YAPI_INVALID_INT
static

Definition at line 2153 of file yocto_api.h.

const string YModule::SERIALNUMBER_INVALID = YAPI_INVALID_STRING
static

Definition at line 2139 of file yocto_api.h.

const s64 YModule::UPTIME_INVALID = YAPI_INVALID_LONG
static

Definition at line 2151 of file yocto_api.h.

const int YModule::USBCURRENT_INVALID = YAPI_INVALID_UINT
static

Definition at line 2152 of file yocto_api.h.

const int YModule::USERVAR_INVALID = YAPI_INVALID_INT
static

Definition at line 2154 of file yocto_api.h.


The documentation for this class was generated from the following files:


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:13