public class YAPIContext extends Object
Modifier and Type | Field and Description |
---|---|
protected static char[] |
_hexArray |
int |
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) |
boolean |
CheckLogicalName(String name)
Checks if a given string is valid as logical name for a module or a function.
|
void |
EnableUSBHost(Object osContext)
This function is used only on Android.
|
void |
FreeAPI()
Frees dynamically allocated memory blocks used by the Yoctopuce library.
|
static String |
GetAPIVersion()
Returns the version identifier for the Yoctopuce library in use.
|
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.
|
int |
PreregisterHub(String url)
Fault-tolerant alternative to RegisterHub().
|
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 |
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.
|
protected static final char[] _hexArray
public int DefaultCacheValidity
public static int _atoi(String str)
public static byte[] _hexStrToBin(String hex_str)
public static byte[] _bytesMerge(byte[] array_a, byte[] array_b)
public 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 © 2018. All rights reserved.