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) |
boolean |
_checkForDuplicateHub(com.yoctopuce.YoctoAPI.YGenericHub newhub) |
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.
|
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.
|
com.yoctopuce.YoctoAPI.YGenericHub |
getGenHub(int hubref) |
com.yoctopuce.YoctoAPI.YGenericHub |
getHubWithBootloader(String serial) |
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.
|
YHub |
getYHubObj(int hubref) |
int |
HandleEvents()
Maintains the device-to-library communication channel.
|
int |
InitAPI(int mode)
Initializes the Yoctopuce programming library explicitly.
|
YHub |
nextHubInUseInternal(int hubref) |
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 static int _atoi(String str)
public static byte[] _hexStrToBin(String hex_str)
public static byte[] _bytesMerge(byte[] array_a, byte[] array_b)
public boolean _checkForDuplicateHub(com.yoctopuce.YoctoAPI.YGenericHub newhub)
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 YHub nextHubInUseInternal(int hubref)
public YHub getYHubObj(int hubref)
public com.yoctopuce.YoctoAPI.YGenericHub getGenHub(int hubref)
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
public 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
public 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
public 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
public int HandleEvents() throws YAPI_Exception
YAPI_Exception
public int Sleep(long ms_duration) throws YAPI_Exception
ms_duration
- : an integer corresponding to the duration of the pause,
in milliseconds.YAPI_Exception
public int TriggerHubDiscovery() throws YAPI_Exception
YAPI_Exception
public 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.public com.yoctopuce.YoctoAPI.YGenericHub getHubWithBootloader(String serial) throws YAPI_Exception, InterruptedException
YAPI_Exception
InterruptedException
Copyright © 2023. All rights reserved.