public class YAPIContext extends Object
Modifier and Type | Field and Description |
---|---|
protected long |
_defaultCacheValidity |
Constructor and Description |
---|
YAPIContext() |
Modifier and Type | Method and Description |
---|---|
static int |
_atoi(String str) |
static byte[] |
_bytesMerge(byte[] array_a,
byte[] array_b) |
static byte[] |
_hexStrToBin(String hex_str) |
String |
AddUdevRule_internal(boolean force) |
String |
AddUdevRule(boolean force)
Adds a UDEV rule which authorizes all users to access Yoctopuce modules
connected to the USB ports.
|
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.
|
void |
EnableUSBHost(Object osContext)
This function is used only on Android.
|
YHub |
FirstHubInUse() |
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.
|
long |
GetCacheValidity()
Returns the validity period of the data loaded by the library.
|
int |
GetDeviceListValidity()
Returns the delay between each forced enumeration of the used YoctoHubs.
|
int |
GetNetworkTimeout_internal() |
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.
|
int |
HandleEvents()
Maintains the device-to-library communication channel.
|
int |
InitAPI(int mode)
Initializes the Yoctopuce programming library explicitly.
|
YHub |
nextHubInUse(com.yoctopuce.YoctoAPI.YGenericHub genericHub) |
int |
PreregisterHub(String url)
Fault-tolerant alternative to yRegisterHub().
|
int |
PreregisterHubWebSocketCallback(Object session) |
int |
PreregisterHubWebSocketCallback(Object session,
String user,
String pass) |
void |
RegisterDeviceArrivalCallback(YAPI.DeviceArrivalCallback arrivalCallback)
Register a callback function, to be called each time
a device is plugged.
|
void |
RegisterDeviceChangeCallback(YAPI.DeviceChangeCallback changeCallback) |
void |
RegisterDeviceRemovalCallback(YAPI.DeviceRemovalCallback removalCallback)
Register a callback function, to be called each time
a device is unplugged.
|
int |
RegisterHub(String url)
Setup the Yoctopuce library to use modules connected on a given machine.
|
int |
RegisterHub(String url,
InputStream request,
OutputStream response) |
void |
RegisterHubDiscoveryCallback(YAPI.HubDiscoveryCallback hubDiscoveryCallback)
Register a callback function, to be called each time an Network Hub send
an SSDP message.
|
int |
RegisterHubHTTPCallback(InputStream request,
OutputStream response) |
void |
RegisterLogFunction(YAPI.LogCallback logfun)
Registers a log callback function.
|
void |
SetCacheValidity(long cacheValidityMs)
Change the validity period of the data loaded by the library.
|
void |
SetDeviceListValidity(int deviceListValidity)
Modifies the delay between each forced enumeration of the used YoctoHubs.
|
void |
SetHTTPCallbackCacheDir(String directory)
Enables the HTTP callback cache.
|
void |
SetNetworkTimeout_internal(int networkMsTimeout) |
void |
SetNetworkTimeout(int networkMsTimeout)
Modifies the network connection delay for yRegisterHub() and yUpdateDeviceList().
|
void |
SetUSBPacketAckMs(int pktAckDelay)
Enables the acknowledge of every USB packet received by the Yoctopuce library.
|
int |
Sleep(long ms_duration)
Pauses the execution flow for a specified duration.
|
int |
TestHub(String url,
int mstimeout)
Test if the hub is reachable.
|
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.
|
void |
UnregisterHub(String url)
Setup the Yoctopuce library to no more use modules connected on a previously
registered machine with RegisterHub.
|
void |
UnregisterHubWebSocketCallback(Object session) |
int |
UpdateDeviceList()
Triggers a (re)detection of connected Yoctopuce modules.
|
public YHub FirstHubInUse()
public YHub nextHubInUse(com.yoctopuce.YoctoAPI.YGenericHub genericHub)
public static int _atoi(String str)
public static byte[] _hexStrToBin(String hex_str)
public static byte[] _bytesMerge(byte[] array_a, byte[] array_b)
public String AddUdevRule_internal(boolean force)
public void SetNetworkTimeout_internal(int networkMsTimeout)
public int GetNetworkTimeout_internal()
public void SetDeviceListValidity(int deviceListValidity)
deviceListValidity
- : nubmer of seconds between each enumeration.public int GetDeviceListValidity()
public String AddUdevRule(boolean force)
force
- : if true, overwrites any existing rule.public void SetNetworkTimeout(int networkMsTimeout)
networkMsTimeout
- : the network connection delay in milliseconds.public int GetNetworkTimeout()
public void SetCacheValidity(long cacheValidityMs)
cacheValidityMs
- : an integer corresponding to the validity attributed to the
loaded function parameters, in milliseconds.public long GetCacheValidity()
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 void SetUSBPacketAckMs(int pktAckDelay)
pktAckDelay
- : then number of milliseconds before the module
resend the last USB packet.public static String GetAPIVersion()
public 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_Exception
- on errorpublic void FreeAPI()
public int RegisterHub(String url) throws YAPI_Exception
url
- : a string containing either "usb","callback" or the
root URL of the hub to monitorYAPI_Exception
- on errorpublic int RegisterHub(String url, InputStream request, OutputStream response) throws YAPI_Exception
YAPI_Exception
public int RegisterHubHTTPCallback(InputStream request, OutputStream response) throws YAPI_Exception
YAPI_Exception
public int PreregisterHubWebSocketCallback(Object session) throws YAPI_Exception
YAPI_Exception
public int PreregisterHubWebSocketCallback(Object session, String user, String pass) throws YAPI_Exception
YAPI_Exception
public void UnregisterHubWebSocketCallback(Object session)
public void EnableUSBHost(Object osContext) throws YAPI_Exception
osContext
- : an object of class android.content.Context (or any subclass).YAPI_Exception
- on errorpublic int PreregisterHub(String url) throws YAPI_Exception
url
- : a string containing either "usb","callback" or the
root URL of the hub to monitorYAPI_Exception
- on errorpublic void UnregisterHub(String url)
url
- : a string containing either "usb" or the
root URL of the hub to monitorpublic 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_Exception
public int UpdateDeviceList() throws YAPI_Exception
YAPI_Exception
- on errorpublic int HandleEvents() throws YAPI_Exception
YAPI_Exception
- on errorpublic int Sleep(long ms_duration) throws YAPI_Exception
ms_duration
- : an integer corresponding to the duration of the pause,
in milliseconds.YAPI_Exception
- on errorpublic int TriggerHubDiscovery() throws YAPI_Exception
YAPI_Exception
- on errorpublic static long GetTickCount()
public boolean CheckLogicalName(String name)
name
- : a string containing the name to check.public void RegisterDeviceArrivalCallback(YAPI.DeviceArrivalCallback arrivalCallback)
arrivalCallback
- : a procedure taking a YModule parameter, or null
to unregister a previously registered callback.public void RegisterDeviceChangeCallback(YAPI.DeviceChangeCallback changeCallback)
public void RegisterDeviceRemovalCallback(YAPI.DeviceRemovalCallback removalCallback)
removalCallback
- : a procedure taking a YModule parameter, or null
to unregister a previously registered callback.public 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 void RegisterLogFunction(YAPI.LogCallback logfun)
logfun
- : a procedure taking a string parameter, or null
to unregister a previously registered callback.Copyright © 2023. All rights reserved.