Classes | Macros | Typedefs | Enumerations | Functions | Variables
yocto_api.h File Reference
#include "yapi/ydef.h"
#include "yapi/yjson.h"
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <stdexcept>
#include <cfloat>
#include <cmath>
Include dependency graph for yocto_api.h:

Go to the source code of this file.

Classes

class  YAPI
 
class  YAPI_Exception
 
struct  yapiDataEvent
 
struct  yapiGlobalEvent
 
class  YapiWrapper
 
class  YDataLogger
 
class  YDataSet
 
class  YDataStream
 
class  YDevice
 
class  YFirmwareUpdate
 
class  YFunction
 
class  YJSONArray
 
class  YJSONContent
 
class  YJSONNumber
 
class  YJSONObject
 
class  YJSONString
 
class  YMeasure
 
class  YModule
 
class  YOldDataStream
 
class  YSensor
 

Macros

#define _Y_ADVMODE_ENUM
 
#define _Y_AUTOSTART_ENUM
 
#define _Y_BEACON_ENUM
 
#define _Y_BEACONDRIVEN_ENUM
 
#define _Y_CLEARHISTORY_ENUM
 
#define _Y_PERSISTENTSETTINGS_ENUM
 
#define _Y_RECORDING_ENUM
 
#define Y_ADVERTISEDVALUE_INVALID   (YAPI_INVALID_STRING)
 
#define Y_CALIBRATIONPARAM_INVALID   (YAPI_INVALID_STRING)
 
#define Y_CURRENTRAWVALUE_INVALID   (YAPI_INVALID_DOUBLE)
 
#define Y_CURRENTRUNINDEX_INVALID   (YAPI_INVALID_UINT)
 
#define Y_CURRENTVALUE_INVALID   (YAPI_INVALID_DOUBLE)
 
#define Y_DATA_INVALID   (-DBL_MAX)
 
#define Y_DURATION_INVALID   (-1)
 
#define Y_FIRMWARERELEASE_INVALID   (YAPI_INVALID_STRING)
 
#define Y_FRIENDLYNAME_INVALID   (YAPI_INVALID_STRING)
 
#define Y_FUNCTIONDESCRIPTOR_INVALID   (-1)
 
#define Y_FUNCTIONID_INVALID   (YAPI_INVALID_STRING)
 
#define Y_HARDWAREID_INVALID   (YAPI_INVALID_STRING)
 
#define Y_HIGHESTVALUE_INVALID   (YAPI_INVALID_DOUBLE)
 
#define Y_LOGFREQUENCY_INVALID   (YAPI_INVALID_STRING)
 
#define Y_LOGICALNAME_INVALID   (YAPI_INVALID_STRING)
 
#define Y_LOWESTVALUE_INVALID   (YAPI_INVALID_DOUBLE)
 
#define Y_LUMINOSITY_INVALID   (YAPI_INVALID_UINT)
 
#define Y_PRODUCTID_INVALID   (YAPI_INVALID_UINT)
 
#define Y_PRODUCTNAME_INVALID   (YAPI_INVALID_STRING)
 
#define Y_PRODUCTRELEASE_INVALID   (YAPI_INVALID_UINT)
 
#define Y_REBOOTCOUNTDOWN_INVALID   (YAPI_INVALID_INT)
 
#define Y_REPORTFREQUENCY_INVALID   (YAPI_INVALID_STRING)
 
#define Y_RESOLUTION_INVALID   (YAPI_INVALID_DOUBLE)
 
#define Y_SENSORSTATE_INVALID   (YAPI_INVALID_INT)
 
#define Y_SERIALNUMBER_INVALID   (YAPI_INVALID_STRING)
 
#define Y_TIMEUTC_INVALID   (YAPI_INVALID_LONG)
 
#define Y_UNIT_INVALID   (YAPI_INVALID_STRING)
 
#define Y_UPTIME_INVALID   (YAPI_INVALID_LONG)
 
#define Y_USBCURRENT_INVALID   (YAPI_INVALID_UINT)
 
#define Y_USERVAR_INVALID   (YAPI_INVALID_INT)
 
#define YAPI_INVALID_DOUBLE   (-DBL_MAX)
 
#define YAPI_INVALID_INT   (0x7FFFFFFF)
 
#define YAPI_INVALID_LONG   (0x7FFFFFFFFFFFFFFFLL)
 
#define YAPI_INVALID_STRING   "!INVALID!"
 
#define YAPI_INVALID_UINT   (-1)
 
#define YOCTO_CLASS_EXPORT
 

Typedefs

typedef vector< double > floatArr
 prototype of the value calibration handlers More...
 
typedef void(* HTTPRequestCallback) (YDevice *device, void *context, YRETCODE returnval, const string &result, string &errmsg)
 
typedef vector< int > intArr
 
typedef double(* yCalibrationHandler) (double rawValue, int calibType, vector< int > params, vector< double > rawValues, vector< double > refValues)
 
typedef void(* YDataLoggerValueCallback) (YDataLogger *func, const string &functionValue)
 
typedef YAPI_DEVICE YDEV_DESCR
 
typedef void(* yDeviceUpdateCallback) (YModule *module)
 prototype of the device arrival/update/removal callback More...
 
typedef YAPI_FUNCTION YFUN_DESCR
 
typedef void(* YFunctionValueCallback) (YFunction *func, const string &functionValue)
 
typedef void(* YHubDiscoveryCallback) (const string &serial, const string &url)
 prototype of the Hub discoverycallback More...
 
typedef void(* yLogFunction) (const string &msg)
 prototype of the log callback More...
 
typedef void(* YModuleLogCallback) (YModule *module, const string &logline)
 
typedef void(* YModuleValueCallback) (YModule *func, const string &functionValue)
 
typedef void(* YSensorTimedReportCallback) (YSensor *func, YMeasure measure)
 
typedef void(* YSensorValueCallback) (YSensor *func, const string &functionValue)
 

Enumerations

enum  Tjstate {
  JSTART, JWAITFORNAME, JWAITFORENDOFNAME, JWAITFORCOLON,
  JWAITFORDATA, JWAITFORNEXTSTRUCTMEMBER, JWAITFORNEXTARRAYITEM, JWAITFORSTRINGVALUE,
  JWAITFORSTRINGVALUE_ESC, JWAITFORINTVALUE, JWAITFORBOOLVALUE
}
 
enum  Y_ADVMODE_enum {
  Y_ADVMODE_IMMEDIATE = 0, Y_ADVMODE_PERIOD_AVG = 1, Y_ADVMODE_PERIOD_MIN = 2, Y_ADVMODE_PERIOD_MAX = 3,
  Y_ADVMODE_INVALID = -1
}
 
enum  Y_AUTOSTART_enum { Y_AUTOSTART_OFF = 0, Y_AUTOSTART_ON = 1, Y_AUTOSTART_INVALID = -1 }
 
enum  Y_BEACON_enum { Y_BEACON_OFF = 0, Y_BEACON_ON = 1, Y_BEACON_INVALID = -1 }
 
enum  Y_BEACONDRIVEN_enum { Y_BEACONDRIVEN_OFF = 0, Y_BEACONDRIVEN_ON = 1, Y_BEACONDRIVEN_INVALID = -1 }
 
enum  Y_CLEARHISTORY_enum { Y_CLEARHISTORY_FALSE = 0, Y_CLEARHISTORY_TRUE = 1, Y_CLEARHISTORY_INVALID = -1 }
 
enum  Y_PERSISTENTSETTINGS_enum { Y_PERSISTENTSETTINGS_LOADED = 0, Y_PERSISTENTSETTINGS_SAVED = 1, Y_PERSISTENTSETTINGS_MODIFIED = 2, Y_PERSISTENTSETTINGS_INVALID = -1 }
 
enum  Y_RECORDING_enum { Y_RECORDING_OFF = 0, Y_RECORDING_ON = 1, Y_RECORDING_PENDING = 2, Y_RECORDING_INVALID = -1 }
 
enum  yapiDataEventType { YAPI_FUN_UPDATE, YAPI_FUN_VALUE, YAPI_FUN_TIMEDREPORT, YAPI_FUN_REFRESH }
 
enum  yapiGlobalEventType {
  YAPI_DEV_ARRIVAL, YAPI_DEV_REMOVAL, YAPI_DEV_CHANGE, YAPI_DEV_LOG,
  YAPI_HUB_DISCOVER
}
 
enum  YJSONType { STRING, NUMBER, ARRAY, OBJECT }
 

Functions

vector< string > _strsplit (const string &str, char delimiter)
 
int _ystrpos (const string &haystack, const string &needle)
 
s64 yatoi (const char *c)
 
bool yCheckLogicalName (const string &name)
 
void yDisableExceptions (void)
 
void yEnableExceptions (void)
 
YDataLoggeryFindDataLogger (const string &func)
 
YModuleyFindModule (const string &func)
 
YSensoryFindSensor (const string &func)
 
YDataLoggeryFirstDataLogger (void)
 
YModuleyFirstModule (void)
 
YSensoryFirstSensor (void)
 
void yFreeAPI ()
 
string yGetAPIVersion ()
 
u64 yGetTickCount (void)
 
YRETCODE yHandleEvents (string &errmsg)
 
YRETCODE yInitAPI (int mode, string &errmsg)
 
YRETCODE yPreregisterHub (const string &url, string &errmsg)
 
void yRegisterCalibrationHandler (int calibrationType, yCalibrationHandler calibrationHandler)
 
void yRegisterDeviceArrivalCallback (yDeviceUpdateCallback arrivalCallback)
 
void yRegisterDeviceChangeCallback (yDeviceUpdateCallback removalCallback)
 
void yRegisterDeviceRemovalCallback (yDeviceUpdateCallback removalCallback)
 
YRETCODE yRegisterHub (const string &url, string &errmsg)
 
void yRegisterHubDiscoveryCallback (YHubDiscoveryCallback hubDiscoveryCallback)
 
void yRegisterLogFunction (yLogFunction logfun)
 
YRETCODE ySleep (unsigned ms_duration, string &errmsg)
 
YRETCODE yTestHub (const string &url, int mstimeout, string &errmsg)
 
YRETCODE yTriggerHubDiscovery (string &errmsg)
 
void yUnregisterHub (const string &url)
 
YRETCODE yUpdateDeviceList (string &errmsg)
 

Variables

const int Y_DETECT_ALL = (Y_DETECT_USB | Y_DETECT_NET)
 
const int Y_DETECT_NET = 2
 
const int Y_DETECT_NONE = 0
 
const int Y_DETECT_USB = 1
 
const int Y_RESEND_MISSING_PKT = 4
 

Macro Definition Documentation

#define _Y_ADVMODE_ENUM

Definition at line 127 of file yocto_api.h.

#define _Y_AUTOSTART_ENUM

Definition at line 174 of file yocto_api.h.

#define _Y_BEACON_ENUM

Definition at line 100 of file yocto_api.h.

#define _Y_BEACONDRIVEN_ENUM

Definition at line 182 of file yocto_api.h.

#define _Y_CLEARHISTORY_ENUM

Definition at line 190 of file yocto_api.h.

#define _Y_PERSISTENTSETTINGS_ENUM

Definition at line 91 of file yocto_api.h.

#define _Y_RECORDING_ENUM

Definition at line 165 of file yocto_api.h.

#define Y_ADVERTISEDVALUE_INVALID   (YAPI_INVALID_STRING)

Definition at line 81 of file yocto_api.h.

#define Y_CALIBRATIONPARAM_INVALID   (YAPI_INVALID_STRING)

Definition at line 143 of file yocto_api.h.

#define Y_CURRENTRAWVALUE_INVALID   (YAPI_INVALID_DOUBLE)

Definition at line 140 of file yocto_api.h.

#define Y_CURRENTRUNINDEX_INVALID   (YAPI_INVALID_UINT)

Definition at line 197 of file yocto_api.h.

#define Y_CURRENTVALUE_INVALID   (YAPI_INVALID_DOUBLE)

Definition at line 137 of file yocto_api.h.

#define Y_DATA_INVALID   (-DBL_MAX)

Definition at line 236 of file yocto_api.h.

#define Y_DURATION_INVALID   (-1)

Definition at line 237 of file yocto_api.h.

#define Y_FIRMWARERELEASE_INVALID   (YAPI_INVALID_STRING)

Definition at line 111 of file yocto_api.h.

#define Y_FRIENDLYNAME_INVALID   (YAPI_INVALID_STRING)

Definition at line 234 of file yocto_api.h.

#define Y_FUNCTIONDESCRIPTOR_INVALID   (-1)

Definition at line 231 of file yocto_api.h.

#define Y_FUNCTIONID_INVALID   (YAPI_INVALID_STRING)

Definition at line 233 of file yocto_api.h.

#define Y_HARDWAREID_INVALID   (YAPI_INVALID_STRING)

Definition at line 232 of file yocto_api.h.

#define Y_HIGHESTVALUE_INVALID   (YAPI_INVALID_DOUBLE)

Definition at line 139 of file yocto_api.h.

#define Y_LOGFREQUENCY_INVALID   (YAPI_INVALID_STRING)

Definition at line 141 of file yocto_api.h.

#define Y_LOGICALNAME_INVALID   (YAPI_INVALID_STRING)

Definition at line 80 of file yocto_api.h.

#define Y_LOWESTVALUE_INVALID   (YAPI_INVALID_DOUBLE)

Definition at line 138 of file yocto_api.h.

#define Y_LUMINOSITY_INVALID   (YAPI_INVALID_UINT)

Definition at line 112 of file yocto_api.h.

#define Y_PRODUCTID_INVALID   (YAPI_INVALID_UINT)

Definition at line 109 of file yocto_api.h.

#define Y_PRODUCTNAME_INVALID   (YAPI_INVALID_STRING)

Definition at line 107 of file yocto_api.h.

#define Y_PRODUCTRELEASE_INVALID   (YAPI_INVALID_UINT)

Definition at line 110 of file yocto_api.h.

#define Y_REBOOTCOUNTDOWN_INVALID   (YAPI_INVALID_INT)

Definition at line 115 of file yocto_api.h.

#define Y_REPORTFREQUENCY_INVALID   (YAPI_INVALID_STRING)

Definition at line 142 of file yocto_api.h.

#define Y_RESOLUTION_INVALID   (YAPI_INVALID_DOUBLE)

Definition at line 144 of file yocto_api.h.

#define Y_SENSORSTATE_INVALID   (YAPI_INVALID_INT)

Definition at line 145 of file yocto_api.h.

#define Y_SERIALNUMBER_INVALID   (YAPI_INVALID_STRING)

Definition at line 108 of file yocto_api.h.

#define Y_TIMEUTC_INVALID   (YAPI_INVALID_LONG)

Definition at line 198 of file yocto_api.h.

#define Y_UNIT_INVALID   (YAPI_INVALID_STRING)

Definition at line 136 of file yocto_api.h.

#define Y_UPTIME_INVALID   (YAPI_INVALID_LONG)

Definition at line 113 of file yocto_api.h.

#define Y_USBCURRENT_INVALID   (YAPI_INVALID_UINT)

Definition at line 114 of file yocto_api.h.

#define Y_USERVAR_INVALID   (YAPI_INVALID_INT)

Definition at line 116 of file yocto_api.h.

#define YAPI_INVALID_DOUBLE   (-DBL_MAX)

Definition at line 73 of file yocto_api.h.

#define YAPI_INVALID_INT   (0x7FFFFFFF)

Definition at line 70 of file yocto_api.h.

#define YAPI_INVALID_LONG   (0x7FFFFFFFFFFFFFFFLL)

Definition at line 72 of file yocto_api.h.

#define YAPI_INVALID_STRING   "!INVALID!"

Definition at line 69 of file yocto_api.h.

#define YAPI_INVALID_UINT   (-1)

Definition at line 71 of file yocto_api.h.

#define YOCTO_CLASS_EXPORT

Definition at line 61 of file yocto_api.h.

Typedef Documentation

typedef vector<double> floatArr

prototype of the value calibration handlers

Definition at line 225 of file yocto_api.h.

typedef void(* HTTPRequestCallback) (YDevice *device, void *context, YRETCODE returnval, const string &result, string &errmsg)

Definition at line 1500 of file yocto_api.h.

typedef vector<int> intArr

Definition at line 226 of file yocto_api.h.

typedef double(* yCalibrationHandler) (double rawValue, int calibType, vector< int > params, vector< double > rawValues, vector< double > refValues)

Definition at line 227 of file yocto_api.h.

typedef void(* YDataLoggerValueCallback) (YDataLogger *func, const string &functionValue)

Definition at line 163 of file yocto_api.h.

Definition at line 229 of file yocto_api.h.

typedef void(* yDeviceUpdateCallback) (YModule *module)

prototype of the device arrival/update/removal callback

Definition at line 217 of file yocto_api.h.

Definition at line 230 of file yocto_api.h.

typedef void(* YFunctionValueCallback) (YFunction *func, const string &functionValue)

Definition at line 79 of file yocto_api.h.

typedef void(* YHubDiscoveryCallback) (const string &serial, const string &url)

prototype of the Hub discoverycallback

Definition at line 220 of file yocto_api.h.

typedef void(* yLogFunction) (const string &msg)

prototype of the log callback

Definition at line 214 of file yocto_api.h.

typedef void(* YModuleLogCallback)(YModule *module, const string &log)

Definition at line 88 of file yocto_api.h.

typedef void(* YModuleValueCallback) (YModule *func, const string &functionValue)

Definition at line 89 of file yocto_api.h.

typedef void(* YSensorTimedReportCallback) (YSensor *func, YMeasure measure)

Definition at line 125 of file yocto_api.h.

typedef void(* YSensorValueCallback) (YSensor *func, const string &functionValue)

Definition at line 123 of file yocto_api.h.

Enumeration Type Documentation

enum Tjstate
Enumerator
JSTART 
JWAITFORNAME 
JWAITFORENDOFNAME 
JWAITFORCOLON 
JWAITFORDATA 
JWAITFORNEXTSTRUCTMEMBER 
JWAITFORNEXTARRAYITEM 
JWAITFORSTRINGVALUE 
JWAITFORSTRINGVALUE_ESC 
JWAITFORINTVALUE 
JWAITFORBOOLVALUE 

Definition at line 306 of file yocto_api.h.

Enumerator
Y_ADVMODE_IMMEDIATE 
Y_ADVMODE_PERIOD_AVG 
Y_ADVMODE_PERIOD_MIN 
Y_ADVMODE_PERIOD_MAX 
Y_ADVMODE_INVALID 

Definition at line 128 of file yocto_api.h.

Enumerator
Y_AUTOSTART_OFF 
Y_AUTOSTART_ON 
Y_AUTOSTART_INVALID 

Definition at line 175 of file yocto_api.h.

Enumerator
Y_BEACON_OFF 
Y_BEACON_ON 
Y_BEACON_INVALID 

Definition at line 101 of file yocto_api.h.

Enumerator
Y_BEACONDRIVEN_OFF 
Y_BEACONDRIVEN_ON 
Y_BEACONDRIVEN_INVALID 

Definition at line 183 of file yocto_api.h.

Enumerator
Y_CLEARHISTORY_FALSE 
Y_CLEARHISTORY_TRUE 
Y_CLEARHISTORY_INVALID 

Definition at line 191 of file yocto_api.h.

Enumerator
Y_PERSISTENTSETTINGS_LOADED 
Y_PERSISTENTSETTINGS_SAVED 
Y_PERSISTENTSETTINGS_MODIFIED 
Y_PERSISTENTSETTINGS_INVALID 

Definition at line 92 of file yocto_api.h.

Enumerator
Y_RECORDING_OFF 
Y_RECORDING_ON 
Y_RECORDING_PENDING 
Y_RECORDING_INVALID 

Definition at line 166 of file yocto_api.h.

Enumerator
YAPI_FUN_UPDATE 
YAPI_FUN_VALUE 
YAPI_FUN_TIMEDREPORT 
YAPI_FUN_REFRESH 

Definition at line 270 of file yocto_api.h.

Enumerator
YAPI_DEV_ARRIVAL 
YAPI_DEV_REMOVAL 
YAPI_DEV_CHANGE 
YAPI_DEV_LOG 
YAPI_HUB_DISCOVER 

Definition at line 249 of file yocto_api.h.

enum YJSONType
Enumerator
STRING 
NUMBER 
ARRAY 
OBJECT 

Definition at line 299 of file yocto_api.h.

Function Documentation

vector<string> _strsplit ( const string &  str,
char  delimiter 
)

Definition at line 85 of file yocto_api.cpp.

int _ystrpos ( const string &  haystack,
const string &  needle 
)

Definition at line 75 of file yocto_api.cpp.

s64 yatoi ( const char *  c)

Definition at line 4156 of file yocto_api.cpp.

bool yCheckLogicalName ( const string &  name)
inline

Checks if a given string is valid as logical name for a module or a function. A valid logical name has a maximum of 19 characters, all among A..Z, a..z, 0..9, _, and -. If you try to configure a logical name with an incorrect string, the invalid characters are ignored.

Parameters
name: a string containing the name to check.
Returns
true if the name is valid, false otherwise.

Definition at line 3522 of file yocto_api.h.

void yDisableExceptions ( void  )
inline

Disables the use of exceptions to report runtime errors. When exceptions are disabled, every function returns a specific error value which depends on its type and which is documented in this reference manual.

Definition at line 3264 of file yocto_api.h.

void yEnableExceptions ( void  )
inline

Re-enables the use of exceptions for runtime error handling. Be aware than when exceptions are enabled, every function that fails triggers an exception. If the exception is not caught by the user code, it either fires the debugger or aborts (i.e. crash) the program. On failure, throws an exception or returns a negative error code.

Definition at line 3274 of file yocto_api.h.

YDataLogger* yFindDataLogger ( const string &  func)
inline

Retrieves a data logger for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the data logger is online at the time it is invoked. The returned object is nevertheless valid. Use the method YDataLogger.isOnline() to test if the data logger is indeed online at a given time. In case of ambiguity when looking for a data logger 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 matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the data logger
Returns
a YDataLogger object allowing you to drive the data logger.

Definition at line 3979 of file yocto_api.h.

YModule* yFindModule ( const string &  func)
inline

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.

YSensor* yFindSensor ( const string &  func)
inline

Retrieves a sensor for a given identifier. The identifier can be specified using several formats:

  • FunctionLogicalName
  • ModuleSerialNumber.FunctionIdentifier
  • ModuleSerialNumber.FunctionLogicalName
  • ModuleLogicalName.FunctionIdentifier
  • ModuleLogicalName.FunctionLogicalName

This function does not require that the sensor is online at the time it is invoked. The returned object is nevertheless valid. Use the method YSensor.isOnline() to test if the sensor is indeed online at a given time. In case of ambiguity when looking for a sensor 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 matching device is plugged, make sure that you did call registerHub() at application initialization time.

Parameters
func: a string that uniquely characterizes the sensor
Returns
a YSensor object allowing you to drive the sensor.

Definition at line 3202 of file yocto_api.h.

YDataLogger* yFirstDataLogger ( void  )
inline

Starts the enumeration of data loggers currently accessible. Use the method YDataLogger.nextDataLogger() to iterate on next data loggers.

Returns
a pointer to a YDataLogger object, corresponding to the first data logger currently online, or a NULL pointer if there are none.

Definition at line 3990 of file yocto_api.h.

YModule* yFirstModule ( void  )
inline

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.

YSensor* yFirstSensor ( void  )
inline

Starts the enumeration of sensors currently accessible. Use the method YSensor.nextSensor() to iterate on next sensors.

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

Definition at line 3213 of file yocto_api.h.

void yFreeAPI ( )
inline

Frees dynamically allocated memory blocks used by the Yoctopuce library. It is generally not required to call this function, unless you want to free all dynamically allocated memory blocks in order to track a memory leak for instance. You should not call any other library function after calling yFreeAPI(), or your program will crash.

Definition at line 3255 of file yocto_api.h.

string yGetAPIVersion ( )
inline

Definition at line 3219 of file yocto_api.h.

u64 yGetTickCount ( void  )
inline

Returns the current value of a monotone millisecond-based time counter. This counter can be used to compute delays in relation with Yoctopuce devices, which also uses the millisecond as timebase.

Returns
a long integer corresponding to the millisecond counter.

Definition at line 3508 of file yocto_api.h.

YRETCODE yHandleEvents ( string &  errmsg)
inline

Maintains the device-to-library communication channel. If your program includes significant loops, you may want to include a call to this function to make sure that the library takes care of the information pushed by the modules on the communication channels. This is not strictly necessary, but it may improve the reactivity of the library for the following commands.

This function may signal an error in case there is a communication problem while contacting a module.

Parameters
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3476 of file yocto_api.h.

YRETCODE yInitAPI ( int  mode,
string &  errmsg 
)
inline

Initializes the Yoctopuce programming library explicitly. It is not strictly needed to call yInitAPI(), as the library is automatically initialized when calling yRegisterHub() for the first time.

When Y_DETECT_NONE is used as detection mode, you must explicitly use yRegisterHub() to point the API to the VirtualHub on which your devices are connected before trying to access them.

Parameters
mode: an integer corresponding to the type of automatic device detection to use. Possible values are Y_DETECT_NONE, Y_DETECT_USB, Y_DETECT_NET, and Y_DETECT_ALL.
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3244 of file yocto_api.h.

YRETCODE yPreregisterHub ( const string &  url,
string &  errmsg 
)
inline

Fault-tolerant alternative to RegisterHub(). This function has the same purpose and same arguments as RegisterHub(), but does not trigger an error when the selected hub is not available at the time of the function call. This makes it possible to register a network hub independently of the current connectivity, and to try to contact it only when a device is actively needed.

Parameters
url: a string containing either "usb","callback" or the root URL of the hub to monitor
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3410 of file yocto_api.h.

void yRegisterCalibrationHandler ( int  calibrationType,
yCalibrationHandler  calibrationHandler 
)
inline

Definition at line 3345 of file yocto_api.h.

void yRegisterDeviceArrivalCallback ( yDeviceUpdateCallback  arrivalCallback)
inline

Register a callback function, to be called each time a device is plugged. This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.

Parameters
arrivalCallback: a procedure taking a YModule parameter, or NULL to unregister a previously registered callback.

Definition at line 3295 of file yocto_api.h.

void yRegisterDeviceChangeCallback ( yDeviceUpdateCallback  removalCallback)
inline

Definition at line 3309 of file yocto_api.h.

void yRegisterDeviceRemovalCallback ( yDeviceUpdateCallback  removalCallback)
inline

Register a callback function, to be called each time a device is unplugged. This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.

Parameters
removalCallback: a procedure taking a YModule parameter, or NULL to unregister a previously registered callback.

Definition at line 3306 of file yocto_api.h.

YRETCODE yRegisterHub ( const string &  url,
string &  errmsg 
)
inline

Setup the Yoctopuce library to use modules connected on a given machine. The parameter will determine how the API will work. Use the following values:

usb: When the usb keyword is used, the API will work with devices connected directly to the USB bus. Some programming languages such a Javascript, PHP, and Java don't provide direct access to USB hardware, so usb will not work with these. In this case, use a VirtualHub or a networked YoctoHub (see below).

x.x.x.x or hostname: The API will use the devices connected to the host with the given IP address or hostname. That host can be a regular computer running a VirtualHub, or a networked YoctoHub such as YoctoHub-Ethernet or YoctoHub-Wireless. If you want to use the VirtualHub running on you local computer, use the IP address 127.0.0.1.

callback: that keyword make the API run in "<i>HTTP Callback</i>" mode. This a special mode allowing to take control of Yoctopuce devices through a NAT filter when using a VirtualHub or a networked YoctoHub. You only need to configure your hub to call your server script on a regular basis. This mode is currently available for PHP and Node.JS only.

Be aware that only one application can use direct USB access at a given time on a machine. Multiple access would cause conflicts while trying to access the USB modules. In particular, this means that you must stop the VirtualHub software before starting an application that uses direct USB access. The workaround for this limitation is to setup the library to use the VirtualHub rather than direct USB access.

If access control has been activated on the hub, virtual or not, you want to reach, the URL parameter should look like:

http://username:password@address:port

You can call RegisterHub several times to connect to several machines.

Parameters
url: a string containing either "usb","callback" or the root URL of the hub to monitor
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3392 of file yocto_api.h.

void yRegisterHubDiscoveryCallback ( YHubDiscoveryCallback  hubDiscoveryCallback)
inline

Register a callback function, to be called each time an Network Hub send an SSDP message. The callback has two string parameter, the first one contain the serial number of the hub and the second contain the URL of the network hub (this URL can be passed to RegisterHub). This callback will be invoked while yUpdateDeviceList is running. You will have to call this function on a regular basis.

Parameters
hubDiscoveryCallback: a procedure taking two string parameter, the serial number and the hub URL. Use NULL to unregister a previously registered callback.

Definition at line 3323 of file yocto_api.h.

void yRegisterLogFunction ( yLogFunction  logfun)
inline

Registers a log callback function. This callback will be called each time the API have something to say. Quite useful to debug the API.

Parameters
logfun: a procedure taking a string parameter, or NULL to unregister a previously registered callback.

Definition at line 3284 of file yocto_api.h.

YRETCODE ySleep ( unsigned  ms_duration,
string &  errmsg 
)
inline

Pauses the execution flow for a specified duration. This function implements a passive waiting loop, meaning that it does not consume CPU cycles significantly. The processor is left available for other threads and processes. During the pause, the library nevertheless reads from time to time information from the Yoctopuce modules by calling yHandleEvents(), in order to stay up-to-date.

This function may signal an error in case there is a communication problem while contacting a module.

Parameters
ms_duration: an integer corresponding to the duration of the pause, in milliseconds.
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3498 of file yocto_api.h.

YRETCODE yTestHub ( const string &  url,
int  mstimeout,
string &  errmsg 
)
inline

Test if the hub is reachable. This method do not register the hub, it only test if the hub is usable. The url parameter follow the same convention as the RegisterHub method. This method is useful to verify the authentication parameters for a hub. It is possible to force this method to return after mstimeout milliseconds.

Parameters
url: a string containing either "usb","callback" or the root URL of the hub to monitor
mstimeout: the number of millisecond available to test the connection.
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

On failure returns a negative error code.

Definition at line 3438 of file yocto_api.h.

YRETCODE yTriggerHubDiscovery ( string &  errmsg)
inline

Force a hub discovery, if a callback as been registered with yRegisterHubDiscoveryCallback it will be called for each net work hub that will respond to the discovery.

Parameters
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds. On failure, throws an exception or returns a negative error code.

Definition at line 3337 of file yocto_api.h.

void yUnregisterHub ( const string &  url)
inline

Setup the Yoctopuce library to no more use modules connected on a previously registered machine with RegisterHub.

Parameters
url: a string containing either "usb" or the root URL of the hub to monitor

Definition at line 3420 of file yocto_api.h.

YRETCODE yUpdateDeviceList ( string &  errmsg)
inline

Triggers a (re)detection of connected Yoctopuce modules. The library searches the machines or USB ports previously registered using yRegisterHub(), and invokes any user-defined callback function in case a change in the list of connected devices is detected.

This function can be called as frequently as desired to refresh the device list and to make the application aware of hot-plug events.

Parameters
errmsg: a string passed by reference to receive any error message.
Returns
YAPI_SUCCESS when the call succeeds.

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

Definition at line 3456 of file yocto_api.h.

Variable Documentation

const int Y_DETECT_ALL = (Y_DETECT_USB | Y_DETECT_NET)

Definition at line 207 of file yocto_api.h.

const int Y_DETECT_NET = 2

Definition at line 205 of file yocto_api.h.

const int Y_DETECT_NONE = 0

Definition at line 203 of file yocto_api.h.

const int Y_DETECT_USB = 1

Definition at line 204 of file yocto_api.h.

const int Y_RESEND_MISSING_PKT = 4

Definition at line 206 of file yocto_api.h.



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