public class YAPI extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
YAPI.CalibrationHandlerCallback |
static interface |
YAPI.DeviceArrivalCallback |
static interface |
YAPI.DeviceChangeCallback |
static interface |
YAPI.DeviceRemovalCallback |
static interface |
YAPI.HubDiscoveryCallback |
static interface |
YAPI.LogCallback |
| Constructor and Description |
|---|
YAPI() |
| Modifier and Type | Method and Description |
|---|---|
static int |
_bincrc(byte[] content,
int ofs,
int len) |
static String |
AddTrustedCertificates(String certificate)
Adds a TLS/SSL certificate to the list of trusted certificates.
|
static String |
AddUdevRule(boolean force)
Adds a UDEV rule which authorizes all users to access Yoctopuce modules
connected to the USB ports.
|
static boolean |
CheckLogicalName(String name)
Checks if a given string is valid as logical name for a module or a function.
|
void |
ClearHTTPCallbackCacheDir(boolean removeFiles)
Disables the HTTP callback cache.
|
static String |
DownloadHostCertificate(String url,
long mstimeout)
Download the TLS/SSL certificate from the hub.
|
static void |
EnableUSBHost(Object osContext)
This function is used only on Android.
|
static YHub |
findYHubFromID(String id) |
static void |
FreeAPI()
Waits for all pending communications with Yoctopuce devices to be
completed then frees dynamically allocated resources used by
the Yoctopuce library.
|
static String |
GetAPIVersion()
Returns the version identifier for the Yoctopuce library in use.
|
static long |
GetCacheValidity()
Returns the validity period of the data loaded by the library.
|
static int |
GetDeviceListValidity()
Returns the delay between each forced enumeration of the used YoctoHubs.
|
static int |
GetNetworkTimeout()
Returns the network connection delay for yRegisterHub() and yUpdateDeviceList().
|
static long |
GetTickCount()
Returns the current value of a monotone millisecond-based time counter.
|
static String |
GetYAPISharedLibraryPath()
Returns the path to the dynamic YAPI library.
|
static YHub |
getYHubObj(int hubref) |
static int |
HandleEvents()
Maintains the device-to-library communication channel.
|
static int |
InitAPI(int mode)
Initializes the Yoctopuce programming library explicitly.
|
static YHub |
nextHubInUseInternal(int hubref) |
static int |
PreregisterHub(String url)
Fault-tolerant alternative to yRegisterHub().
|
static int |
PreregisterHubWebSocketCallback(Object session) |
static int |
PreregisterHubWebSocketCallback(Object session,
String user,
String pass) |
static void |
RegisterDeviceArrivalCallback(YAPI.DeviceArrivalCallback arrivalCallback)
Register a callback function, to be called each time
a device is plugged.
|
static void |
RegisterDeviceChangeCallback(YAPI.DeviceChangeCallback changeCallback) |
static void |
RegisterDeviceRemovalCallback(YAPI.DeviceRemovalCallback removalCallback)
Register a callback function, to be called each time
a device is unplugged.
|
static int |
RegisterHub(String url)
Set up the Yoctopuce library to use modules connected on a given machine.
|
static int |
RegisterHub(String url,
InputStream request,
OutputStream response) |
static void |
RegisterHubDiscoveryCallback(YAPI.HubDiscoveryCallback hubDiscoveryCallback)
Register a callback function, to be called each time an Network Hub send
an SSDP message.
|
static void |
RegisterLogFunction(YAPI.LogCallback logfun)
Registers a log callback function.
|
static void |
SetCacheValidity(long cacheValidityMs)
Change the validity period of the data loaded by the library.
|
static void |
SetDeviceListValidity(int deviceListValidity)
Modifies the delay between each forced enumeration of the used YoctoHubs.
|
void |
SetHTTPCallbackCacheDir(String directory)
Enables the HTTP callback cache.
|
static String |
SetNetworkSecurityOptions(int opts)
Enables or disables certain TLS/SSL certificate checks.
|
static void |
SetNetworkTimeout(int networkMsTimeout)
Modifies the network connection delay for yRegisterHub() and yUpdateDeviceList().
|
static void |
SetThreadSpecificMode() |
static String |
SetTrustedCertificatesList(String certificatePath)
Set the path of Certificate Authority file on local filesystem.
|
static void |
SetUSBPacketAckMs(int pktAckDelay)
Enables the acknowledge of every USB packet received by the Yoctopuce library.
|
static int |
Sleep(long ms_duration)
Pauses the execution flow for a specified duration.
|
static int |
TestHub(String url,
int mstimeout)
Test if the hub is reachable.
|
static int |
TriggerHubDiscovery()
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.
|
static void |
UnregisterHub(String url)
Set up the Yoctopuce library to no more use modules connected on a previously
registered machine with RegisterHub.
|
static void |
UnregisterHubWebSocketCallback(Object session) |
static int |
UpdateDeviceList()
Triggers a (re)detection of connected Yoctopuce modules.
|
public static final String INVALID_STRING
public static final double INVALID_DOUBLE
public static final int INVALID_INT
public static final long INVALID_LONG
public static final int INVALID_UINT
public static final String YOCTO_API_VERSION_STR
public static final String YOCTO_API_BUILD_STR
public static final int YOCTO_VENDORID
public static final int YOCTO_DEVID_FACTORYBOOT
public static final int YOCTO_DEVID_BOOTLOADER
public static final int YOCTO_DEFAULT_PORT
public static final int YOCTO_DEFAULT_HTTPS_PORT
public static final int SUCCESS
public static final int NOT_INITIALIZED
public static final int INVALID_ARGUMENT
public static final int NOT_SUPPORTED
public static final int DEVICE_NOT_FOUND
public static final int VERSION_MISMATCH
public static final int DEVICE_BUSY
public static final int TIMEOUT
public static final int IO_ERROR
public static final int NO_MORE_DATA
public static final int EXHAUSTED
public static final int DOUBLE_ACCES
public static final int UNAUTHORIZED
public static final int RTC_NOT_READY
public static final int FILE_NOT_FOUND
public static final int SSL_ERROR
public static final int RFID_SOFT_ERROR
public static final int RFID_HARD_ERROR
public static final int BUFFER_TOO_SMALL
public static final int DNS_ERROR
public static final int SSL_UNK_CERT
public static final int UNCONFIGURED
public static final int NO_TRUSTED_CA_CHECK
public static final int NO_EXPIRATION_CHECK
public static final int NO_HOSTNAME_CHECK
public static final int LEGACY
public static final int YOCTO_MANUFACTURER_LEN
public static final int YOCTO_SERIAL_LEN
public static final int YOCTO_BASE_SERIAL_LEN
public static final int YOCTO_PRODUCTNAME_LEN
public static final int YOCTO_FIRMWARE_LEN
public static final int YOCTO_LOGICAL_LEN
public static final int YOCTO_FUNCTION_LEN
public static final int DETECT_NONE
public static final int DETECT_USB
public static final int DETECT_NET
public static final int RESEND_MISSING_PKT
public static final int DETECT_ALL
public static int _bincrc(byte[] content,
int ofs,
int len)
public static void SetThreadSpecificMode()
throws YAPI_Exception
YAPI_Exceptionpublic static void SetUSBPacketAckMs(int pktAckDelay)
pktAckDelay - : then number of milliseconds before the module
resend the last USB packet.public static String GetAPIVersion()
public static int InitAPI(int mode)
throws YAPI_Exception
mode - : an integer corresponding to the type of automatic
device detection to use. Possible values are
YAPI.DETECT_NONE, YAPI.DETECT_USB, YAPI.DETECT_NET,
and YAPI.DETECT_ALL.YAPI_Exceptionpublic static void FreeAPI()
public static int RegisterHub(String url) throws YAPI_Exception
url - : a string containing either "usb","callback" or the
root URL of the hub to monitorYAPI_Exceptionpublic static int RegisterHub(String url, InputStream request, OutputStream response) throws YAPI_Exception
YAPI_Exceptionpublic static int PreregisterHubWebSocketCallback(Object session) throws YAPI_Exception
YAPI_Exceptionpublic static int PreregisterHubWebSocketCallback(Object session, String user, String pass) throws YAPI_Exception
YAPI_Exceptionpublic static void UnregisterHubWebSocketCallback(Object session)
public static void EnableUSBHost(Object osContext) throws YAPI_Exception
osContext - : an object of class android.content.Context (or any subclass).YAPI_Exception - on errorpublic static int PreregisterHub(String url) throws YAPI_Exception
url - : a string containing either "usb","callback" or the
root URL of the hub to monitorYAPI_Exceptionpublic static void UnregisterHub(String url)
url - : a string containing either "usb" or the
root URL of the hub to monitorpublic static int TestHub(String url, int mstimeout) throws YAPI_Exception
url - : a string containing either "usb","callback" or the
root URL of the hub to monitormstimeout - : the number of millisecond available to test the connection.YAPI_Exceptionpublic static int UpdateDeviceList()
throws YAPI_Exception
YAPI_Exceptionpublic static int HandleEvents()
throws YAPI_Exception
YAPI_Exceptionpublic static int Sleep(long ms_duration)
throws YAPI_Exception
ms_duration - : an integer corresponding to the duration of the pause,
in milliseconds.YAPI_Exceptionpublic static int TriggerHubDiscovery()
throws YAPI_Exception
YAPI_Exceptionpublic static long GetTickCount()
public static boolean CheckLogicalName(String name)
name - : a string containing the name to check.public static void RegisterDeviceArrivalCallback(YAPI.DeviceArrivalCallback arrivalCallback)
arrivalCallback - : a procedure taking a YModule parameter, or null
to unregister a previously registered callback.public static void RegisterDeviceChangeCallback(YAPI.DeviceChangeCallback changeCallback)
public static void RegisterDeviceRemovalCallback(YAPI.DeviceRemovalCallback removalCallback)
removalCallback - : a procedure taking a YModule parameter, or null
to unregister a previously registered callback.public static void RegisterHubDiscoveryCallback(YAPI.HubDiscoveryCallback hubDiscoveryCallback)
hubDiscoveryCallback - : a procedure taking two string parameter, the serial
number and the hub URL. Use null to unregister a previously registered callback.public static void RegisterLogFunction(YAPI.LogCallback logfun)
logfun - : a procedure taking a string parameter, or null
to unregister a previously registered callback.public void SetHTTPCallbackCacheDir(String directory) throws YAPI_Exception
directory - : the path of the folder that will be used as cache.YAPI_Exception - on errorpublic void ClearHTTPCallbackCacheDir(boolean removeFiles)
removeFiles - : True to clear the content of the cache.YAPI_Exception - on errorpublic static void SetDeviceListValidity(int deviceListValidity)
deviceListValidity - : nubmer of seconds between each enumeration.public static int GetDeviceListValidity()
public static String GetYAPISharedLibraryPath()
public static String AddUdevRule(boolean force)
force - : if true, overwrites any existing rule.public static String DownloadHostCertificate(String url, long mstimeout)
url - : the root URL of the VirtualHub V2 or HTTP server.mstimeout - : the number of milliseconds available to download the certificate.public static String AddTrustedCertificates(String certificate)
certificate - : a string containing one or more certificates.public static String SetTrustedCertificatesList(String certificatePath)
certificatePath - : the path of the file containing all certificates in PEM format.public static String SetNetworkSecurityOptions(int opts)
opts - : The options are YAPI.NO_TRUSTED_CA_CHECK,
YAPI.NO_EXPIRATION_CHECK, YAPI.NO_HOSTNAME_CHECK.public static void SetNetworkTimeout(int networkMsTimeout)
networkMsTimeout - : the network connection delay in milliseconds.public static int GetNetworkTimeout()
public static void SetCacheValidity(long cacheValidityMs)
cacheValidityMs - : an integer corresponding to the validity attributed to the
loaded function parameters, in milliseconds.public static long GetCacheValidity()
public static YHub nextHubInUseInternal(int hubref)
public static YHub getYHubObj(int hubref)
Copyright © 2026. All rights reserved.