yjni.c
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yjni.c 21960 2015-11-06 15:59:59Z seb $
4  *
5  * Implementation of public entry points to the low-level API
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 #define __FILE_ID__ "yjni"
40 
41 #include "yapi.h"
42 #include "yproto.h"
43 #include "yhash.h"
44 #include "yjson.h"
45 #include "yprog.h"
46 
47 #ifdef YAPI_WITH_JNI
48 
49 #include <jni.h>
50 #include <stdio.h>
51 #include "yjni.h"
52 
53 
54 
55  jint throwYAPI_Exception( JNIEnv *env, char *message )
56 {
57  jclass exClass;
58  char *className = "com/yoctopuce/YoctoAPI/YAPI_Exception" ;
59  dbglog("Exception:%s\n", message);
60  exClass = (*env)->FindClass( env, className );
61  return (*env)->ThrowNew( env, exClass, message );
62 }
63 
64 
65 /*
66  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
67  * Method: getAPIVersion
68  * Signature: ()Ljava/lang/String;
69  */
70 JNIEXPORT jstring JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_getAPIVersion(JNIEnv *env, jclass thisObj)
71 {
72  const char *version;
73  const char *apidate;
74  yapiGetAPIVersion(&version, &apidate);
75 
76  return (*env)->NewStringUTF(env, version);
77 }
78 
79 
80 /*
81  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
82  * Method: reserveUSBAccess
83  * Signature: ()V;
84  */
85 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_reserveUSBAccess(JNIEnv *env, jclass thisObj)
86 {
87  char errmsg[YOCTO_ERRMSG_LEN];
88  YRETCODE res;
89 
90  res = yapiInitAPI(Y_DETECT_USB, errmsg);
91  if(YISERR(res)) {
92  throwYAPI_Exception(env, errmsg);
93  }
94 }
95 
96 /*
97  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
98  * Method: releaseUSBAccess
99  * Signature: ()V
100  */
101 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_releaseUSBAccess(JNIEnv *env, jclass thisObj)
102 {
103  yapiFreeAPI();
104 }
105 
106 
107 /*
108  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
109  * Method: getBootloaders
110  * Signature: ()Ljava/util/String;
111  */
112 JNIEXPORT jobject JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_getBootloaders(JNIEnv *env, jclass thisObj)
113 {
114  char errmsg[YOCTO_ERRMSG_LEN];
115  char buffer[1024];
116  char *p;
117  int fullsize;
118  YRETCODE res;
119  jobject result;
120 
121 
122  res = yapiGetBootloaders(buffer, 1024, &fullsize, errmsg);
123  if(YISERR(res)) {
124  throwYAPI_Exception(env, errmsg);
125  return NULL;
126  }
127  if (res == fullsize) {
128  return (*env)->NewStringUTF(env, buffer);
129  }
130 
131  p = yMalloc(fullsize+1);
132  memset(p, 0, fullsize+1);
133  res = yapiGetBootloaders(buffer, fullsize, &fullsize, errmsg);
134  if(YISERR(res)) {
135  yFree(p);
136  throwYAPI_Exception(env, errmsg);
137  return NULL;
138  }
139  result = (*env)->NewStringUTF(env, buffer);
140  yFree(p);
141  return result;
142 }
143 
144 
145 static jobject allocWPEntry(JNIEnv *env, yDeviceSt *infos)
146 {
147  jstring logicalName;
148  jstring productName;
149  jint productId;
150  jstring networkUrl;
151  jint beacon;
152  jstring serialNumber;
153  jobject res;
154  jmethodID constructor;
155 
156 
157  jclass cls = (*env)->FindClass(env, "com/yoctopuce/YoctoAPI/WPEntry");
158  if (cls == 0) {
159  throwYAPI_Exception(env, "Unable to find class WPEntry");
160  return NULL;
161  }
162 
163  constructor = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;Ljava/lang/String;ILjava/lang/String;ILjava/lang/String;)V");
164  if (constructor == 0) {
165  throwYAPI_Exception(env, "Unable to find constructor for WPEntry");
166  return NULL;
167  }
168 
169  logicalName = (*env)->NewStringUTF(env, infos->logicalname);
170  productName = (*env)->NewStringUTF(env, infos->productname);
171  networkUrl = (*env)->NewStringUTF(env, "");
172  serialNumber = (*env)->NewStringUTF(env, infos->serial);
173  productId = infos->vendorid;
174  beacon = 0; //fixme : use real beacon vallue
175 
176  res = (*env)->NewObject(env, cls, constructor, logicalName, productName, productId, networkUrl, beacon, serialNumber);
177  return res;
178 
179 }
180 
181 
182 
183 static jobject allocYPEntry(JNIEnv *env, const char *classname, const char *serial, const char *funcId, const char *logicalName, const char *advertisedValue, int baseType, int funIdx)
184 {
185  jstring j_classname;
186  jstring j_serial;
187  jstring j_funcId;
188  jstring j_logicalName;
189  jstring j_advertisedValue;
190  jmethodID constructor;
191 
192  jclass cls = (*env)->FindClass(env, "com/yoctopuce/YoctoAPI/YPEntry");
193  if (cls == 0) {
194  throwYAPI_Exception(env, "Unable to find class WPEntry");
195  return NULL;
196  }
197  constructor = (*env)->GetMethodID(env, cls, "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V");
198  if (constructor == 0) {
199  throwYAPI_Exception(env, "Unable to find constructor for YPEntry");
200  return NULL;
201  }
202  j_classname = (*env)->NewStringUTF(env, classname);
203  j_serial = (*env)->NewStringUTF(env, serial);
204  j_funcId = (*env)->NewStringUTF(env, funcId);
205  j_logicalName = (*env)->NewStringUTF(env, logicalName);
206  j_advertisedValue = (*env)->NewStringUTF(env, advertisedValue);
207  return (*env)->NewObject(env, cls, constructor, j_classname, j_serial, j_funcId, j_logicalName, j_advertisedValue, baseType, funIdx);
208 }
209 
210 
211 
212 
213 /*
214  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
215  * Method: updateDeviceList
216  * Signature: (Ljava/util/ArrayList;Ljava/util/HashMap;)V
217  */
218 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_updateDeviceList(JNIEnv *env, jclass thisObj, jobject wpArray, jobject ypArray)
219 {
220  char errmsg[YOCTO_ERRMSG_LEN];
221  YAPI_DEVICE *buffer, *dev_ptr;
222  int nbdev, buffsize, i;
223  yBlkHdl categ;
224 
225  jobject wpEntry, ypEntry;
226  jclass arrayList_class;
227  jmethodID arrayList_add;
228 
229  if (yapiUpdateDeviceList(1, errmsg) < 0) {
230  throwYAPI_Exception(env, errmsg);
231  return;
232  }
233 
234  // populate white pages
235  if (yapiGetAllDevices(NULL, 0, &buffsize, errmsg) < 0) {
236  throwYAPI_Exception(env, errmsg);
237  return;
238  }
239  buffer = (YAPI_DEVICE *)yMalloc(buffsize);
240  nbdev = yapiGetAllDevices(buffer, buffsize, &buffsize, errmsg);
241 
242  arrayList_class = (*env)->FindClass(env, "java/util/ArrayList");
243  if (arrayList_class == 0) {
244  throwYAPI_Exception(env, "Unable to find class ArrayList");
245  return;
246  }
247 
248  arrayList_add = (*env)->GetMethodID(env, arrayList_class, "add", "(Ljava/lang/Object;)Z");
249  if (arrayList_add == 0) {
250  throwYAPI_Exception(env, "Unable to find add method of ArrayList");
251  return;
252  }
253 
254  dev_ptr = buffer;
255  for (i = 0 ; i < nbdev; i++, dev_ptr++) {
256  yDeviceSt dev_info;
257  if (yapiGetDeviceInfo(*dev_ptr, &dev_info, errmsg) < 0) {
258  throwYAPI_Exception(env, errmsg);
259  return;
260  }
261  wpEntry = allocWPEntry(env, &dev_info);
262  if (wpEntry ==NULL) {
263  return;
264  }
265  (*env)->CallBooleanMethod(env, wpArray, arrayList_add, wpEntry);
266  }
267  yFree(buffer);
268 
269  // populate Yellow pages
270  categ = yYpListHead;
271  for (categ = yYpListHead; categ != INVALID_BLK_HDL; categ = yBlkListSeek(categ, 1)) {
272  char categname[YOCTO_FUNCTION_LEN];
273  yBlkHdl entry;
274 
275  ypGetCategory(categ, categname, &entry);
276  if (YSTRCMP(categname,"Module")==0){
277  continue;
278  }
279 
280  // add all Yellow pages
281  for (; entry != INVALID_BLK_HDL; entry = yBlkListSeek(entry, 1)) {
282  yStrRef serial, funcId, funcName;
283  Notification_funydx funcInfo;
284  int yidx, baseType;
285  char pubRaw[YOCTO_PUBVAL_SIZE];
286  char pubDecoded[YOCTO_PUBVAL_LEN];
287  yidx = ypGetAttributes(entry, &serial, &funcId, &funcName, &funcInfo, pubRaw);
288  baseType = ypGetType(entry);
289  decodePubVal(funcInfo, pubRaw, pubDecoded);
290  ypEntry = allocYPEntry(env, categname, yHashGetStrPtr(serial), yHashGetStrPtr(funcId), yHashGetStrPtr(funcName),
291  pubDecoded, baseType, yidx);
292  if (ypEntry == NULL) {
293  return;
294  }
295  (*env)->CallBooleanMethod(env, ypArray, arrayList_add, ypEntry);
296  }
297  }
298 
299 }
300 
301 
302 /*
303  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
304  * Method: devRequestSync
305  * Signature: (Ljava/lang/String;[B)[B
306  */
307 JNIEXPORT jbyteArray JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_devRequestSync(JNIEnv *env, jclass thisObj, jstring serial_java, jbyteArray request_java)
308 {
309  char errmsg[YOCTO_ERRMSG_LEN];
310  YRETCODE res;
311  YIOHDL iohdl;
312  char *reply;
313  int replysize = 0;
314  const char *serial = NULL;
315  jbyte *request_bytes = NULL;
316  jsize length;
317  jbyteArray result = NULL;
318 
319  // get serial
320  serial = (*env)->GetStringUTFChars(env, serial_java, NULL);
321  if (NULL == serial) {
322  throwYAPI_Exception(env, "Invalid String");
323  goto exit;
324  }
325 
326  // get request
327  request_bytes = (*env)->GetByteArrayElements(env, request_java, NULL);
328  if (NULL == request_bytes) {
329  throwYAPI_Exception(env, "Invalid Byte Array");
330  goto exit;
331  }
332  length = (*env)->GetArrayLength(env, request_java);
333 
334  if(YISERR(res = yapiHTTPRequestSyncStartEx(&iohdl, serial, (const char *)request_bytes, length, &reply, &replysize, errmsg))) {
335  throwYAPI_Exception(env, errmsg);
336  goto exit;
337  }
338  if (replysize < 0 || reply == NULL) {
339  replysize = 0;
340  }
341 
342  // compute return value
343  result = (*env)->NewByteArray(env, replysize); // allocate
344  if (NULL == result) {
345  throwYAPI_Exception(env, "Unable to allocate bytes array");
346  goto exit;
347  }
348 
349  if (replysize > 0) {
350  (*env)->SetByteArrayRegion(env, result, 0 , replysize, (jbyte*)reply); // copy
351  }
352 
353  if(YISERR(res=yapiHTTPRequestSyncDone(&iohdl, errmsg))) {
354  throwYAPI_Exception(env, errmsg);
355  }
356 
357 exit:
358  if (serial != NULL) {
359  (*env)->ReleaseStringUTFChars(env, serial_java, serial); // release resources
360  }
361 
362  if (request_bytes != NULL) {
363  (*env)->ReleaseByteArrayElements(env, request_java, request_bytes, 0); // release resources
364  }
365  return result;
366 }
367 
368 
369 /*
370  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
371  * Method: devRequestAsync
372  * Signature: (Ljava/lang/String;[BLcom/yoctopuce/YoctoAPI/YGenericHub/RequestAsyncResult;Ljava/lang/Object;)V
373  */
374 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_devRequestAsync(JNIEnv *env, jclass thisObj, jstring serial_java, jbyteArray request_java, jobject callback, jobject context)
375 {
376  char errmsg[YOCTO_ERRMSG_LEN];
377  YRETCODE res;
378  const char *serial = NULL;
379  jbyte *request_bytes = NULL;
380  jsize length;
381 
382  // get serial
383  serial = (*env)->GetStringUTFChars(env, serial_java, NULL);
384  if (NULL == serial) {
385  throwYAPI_Exception(env, "Invalid String");
386  goto exit;
387  }
388 
389  // get request
390  request_bytes = (*env)->GetByteArrayElements(env, request_java, NULL);
391  if (NULL == request_bytes) {
392  throwYAPI_Exception(env, "Invalid Byte Array");
393  goto exit;
394  }
395  length = (*env)->GetArrayLength(env, request_java);
396 
397 
398  if(YISERR(res=yapiHTTPRequestAsyncEx(serial, (const char *)request_bytes, length, NULL, NULL, errmsg))) {
399  throwYAPI_Exception(env, errmsg);
400  goto exit;
401  }
402  //Todo: handle correctly callback
403 
404 exit:
405  if (serial != NULL) {
406  (*env)->ReleaseStringUTFChars(env, serial_java, serial); // release resources
407  }
408 
409  if (request_bytes != NULL) {
410  (*env)->ReleaseByteArrayElements(env, request_java, request_bytes, 0); // release resources
411  }
412 }
413 
414 
415 static JavaVM *jvm;
416 
417 static jobject jObj;
418 
419 static JNIEnv* getThreadEnv()
420 {
421  JNIEnv *env;
422  // double check it's all ok
423  int getEnvStat = (*jvm)->GetEnv(jvm, (void**)&env, JNI_VERSION_1_6);
424  if (getEnvStat == JNI_EDETACHED) {
425  dbglog("GetEnv: not attached\n");
426  if ((*jvm)->AttachCurrentThread(jvm, (void **) &env, NULL) != 0) {
427  dbglog("Failed to attach\n");
428  return NULL;
429  }
430  } else if (getEnvStat == JNI_OK) {
431  //dbglog("attached\n");
432  } else if (getEnvStat == JNI_EVERSION) {
433  dbglog("GetEnv: version not supported\n");
434  return NULL;
435  }
436  return env;
437 }
438 
439 
440 static void jFunctionUpdateCallbackFwd(YAPI_FUNCTION fundesc,const char *value)
441 {
442  char serial[YOCTO_SERIAL_LEN];
443  char funcId[YOCTO_FUNCTION_LEN];
444  jstring j_serial;
445  jstring j_funcId;
446  jstring j_value;
447  jclass yUSBHub_class;
448  jmethodID yUSBHub_handleValueNotification;
449  JNIEnv *env;
450 
451  if (value==NULL){
452  return;
453  }
454 
455  env = getThreadEnv();
456  if (env == NULL){
457  return;
458  }
459 
460  ypGetFunctionInfo(fundesc, serial, funcId,NULL, NULL, NULL);
461  j_serial = (*env)->NewStringUTF(env, serial);
462  j_funcId = (*env)->NewStringUTF(env, funcId);
463  j_value = (*env)->NewStringUTF(env, value);
464 
465  yUSBHub_class = (*env)->FindClass(env, "com/yoctopuce/YoctoAPI/YUSBHub");
466  if (yUSBHub_class == 0) {
467  dbglog("Unable to find class YUSBHub\n");
468  return;
469  }
470 
471 
472  yUSBHub_handleValueNotification = (*env)->GetMethodID(env, yUSBHub_class, "handleValueNotification", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
473  if (yUSBHub_handleValueNotification == 0) {
474  dbglog("Unable to find add method of handleValueNotification\n");
475  return;
476  }
477 
478  (*env)->CallVoidMethod(env, jObj, yUSBHub_handleValueNotification, j_serial, j_funcId, j_value);
479 }
480 
481 static void jFunctionTimedReportCallbackFwd(YAPI_FUNCTION fundesc, double timestamp, const u8 *bytes, u32 len)
482 {
483  char serial[YOCTO_SERIAL_LEN];
484  char funcId[YOCTO_FUNCTION_LEN];
485  jstring j_serial;
486  jstring j_funcId;
487  jbyteArray result = NULL;
488  jclass yUSBHub_class;
489  jmethodID YUSBHub_handleTimedNotification;
490  JNIEnv *env;
491 
492  env = getThreadEnv();
493  if (env == NULL){
494  return;
495  }
496 
497  ypGetFunctionInfo(fundesc, serial, funcId, NULL, NULL, NULL);
498  j_serial = (*env)->NewStringUTF(env, serial);
499  j_funcId = (*env)->NewStringUTF(env, funcId);
500 
501  yUSBHub_class = (*env)->FindClass(env, "com/yoctopuce/YoctoAPI/YUSBHub");
502  if (yUSBHub_class == 0) {
503  dbglog("Unable to find class YUSBHub\n");
504  return;
505  }
506 
507  YUSBHub_handleTimedNotification = (*env)->GetMethodID(env, yUSBHub_class, "handleTimedNotification", "(Ljava/lang/String;Ljava/lang/String;D[B)V");
508  if (YUSBHub_handleTimedNotification == 0) {
509  dbglog("Unable to find add method of handleTimedNotification\n");
510  return;
511  }
512 
513 
514  // compute return value
515  result = (*env)->NewByteArray(env, len); // allocate
516  if (NULL == result) {
517  dbglog("Unable to allocate bytes array");
518  return;
519  }
520 
521  (*env)->SetByteArrayRegion(env, result, 0 , len, (jbyte*) bytes); // copy
522 
523  (*env)->CallVoidMethod(env, jObj, YUSBHub_handleTimedNotification, j_serial, j_funcId, timestamp, result);
524 }
525 
526 
527 
528 /*
529  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
530  * Method: startNotifications
531  * Signature: (Lcom/yoctopuce/YoctoAPI/YUSBHub;)V
532  */
533 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_startNotifications(JNIEnv * env, jclass thisObj, jobject yUSBHubRef)
534 {
535 
536  if ((*env)->GetJavaVM(env, &jvm) != 0) {
537  throwYAPI_Exception(env, "GetJavaVM: Unable to get VM");
538  return;
539  }
540  jObj = (*env)->NewGlobalRef(env, yUSBHubRef);
541  yapiRegisterFunctionUpdateCallback(jFunctionUpdateCallbackFwd);
542  yapiRegisterTimedReportCallback(jFunctionTimedReportCallbackFwd);
543 }
544 
545 /*
546  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
547  * Method: stopNotifications
548  * Signature: ()V
549  */
550 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_stopNotifications(JNIEnv * env, jclass thisObj)
551 {
554  (*env)->DeleteGlobalRef(env, jObj);
555  jObj = NULL;
556  jvm = NULL;
557 }
558 
559 /*
560  * Class: com_yoctopuce_YoctoAPI_YJniWrapper
561  * Method: usbProcess
562  * Signature: (Lcom/yoctopuce/YoctoAPI/YUSBHub;)V
563  */
564 JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_usbProcess(JNIEnv *env, jclass thisObj, jobject yUSBHubRef)
565 {
566  char errmsg[YOCTO_ERRMSG_LEN];
567  YRETCODE res;
568 
569  if(YISERR(res=yapiHandleEvents(errmsg))) {
570  throwYAPI_Exception(env, errmsg);
571  }
572 }
573 
574 
575 
576 #endif
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_updateDeviceList(JNIEnv *, jclass, jobject, jobject)
void * YIOHDL
Definition: ydef.h:260
s32 YAPI_FUNCTION
Definition: ydef.h:217
yHash yStrRef
Definition: ydef.h:214
YRETCODE YAPI_FUNCTION_EXPORT yapiGetBootloaders(char *buffer, int buffersize, int *fullsize, char *errmsg)
Definition: yapi.c:4673
void YAPI_FUNCTION_EXPORT yapiRegisterTimedReportCallback(yapiTimedReportCallback timedReportCallback)
Definition: yapi.c:4360
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_usbProcess(JNIEnv *, jclass, jobject)
const int Y_DETECT_USB
Definition: yocto_api.h:204
#define dbglog(args...)
Definition: yproto.h:413
JNIEXPORT jobject JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_getBootloaders(JNIEnv *, jclass)
#define YOCTO_SERIAL_LEN
Definition: ydef.h:420
void YAPI_FUNCTION_EXPORT yapiFreeAPI(void)
Definition: yapi.c:4304
#define YOCTO_ERRMSG_LEN
Definition: ydef.h:418
char * yHashGetStrPtr(yHash yhash)
Definition: yhash.c:401
int YAPI_FUNCTION_EXPORT yapiGetAllDevices(YAPI_DEVICE *buffer, int maxsize, int *neededsize, char *errmsg)
Definition: yapi.c:4497
YRETCODE YAPI_FUNCTION_EXPORT yapiHTTPRequestSyncStartEx(YIOHDL *iohdl, const char *device, const char *request, int requestsize, char **reply, int *replysize, char *errmsg)
Definition: yapi.c:4582
#define YOCTO_PUBVAL_LEN
Definition: ydef.h:428
YRETCODE
Definition: ydef.h:376
u16 vendorid
Definition: ydef.h:448
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_reserveUSBAccess(JNIEnv *, jclass)
void decodePubVal(Notification_funydx funInfo, const char *funcval, char *buffer)
Definition: yfifo.c:429
#define INVALID_BLK_HDL
Definition: ydef.h:220
#define YOCTO_PUBVAL_SIZE
Definition: ydef.h:427
JNIEXPORT jbyteArray JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_devRequestSync(JNIEnv *, jclass, jstring, jbyteArray)
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_releaseUSBAccess(JNIEnv *, jclass)
void ypGetCategory(yBlkHdl hdl, char *name, yBlkHdl *entries)
Definition: yhash.c:1508
u16 yBlkHdl
Definition: ydef.h:213
char logicalname[YOCTO_LOGICAL_LEN]
Definition: ydef.h:455
#define YOCTO_FUNCTION_LEN
Definition: ydef.h:425
YRETCODE YAPI_FUNCTION_EXPORT yapiHTTPRequestAsyncEx(const char *device, const char *request, int len, yapiRequestAsyncCallback callback, void *context, char *errmsg)
Definition: yapi.c:4620
YRETCODE YAPI_FUNCTION_EXPORT yapiHTTPRequestSyncDone(YIOHDL *iohdl, char *errmsg)
Definition: yapi.c:4611
u16 YAPI_FUNCTION_EXPORT yapiGetAPIVersion(const char **version, const char **apidate)
Definition: yapi.c:4472
int ypGetFunctionInfo(YAPI_FUNCTION fundesc, char *serial, char *funcId, char *baseType, char *funcName, char *funcVal)
Definition: yhash.c:1866
YRETCODE YAPI_FUNCTION_EXPORT yapiInitAPI(int detect_type, char *errmsg)
Definition: yapi.c:4295
int ypGetAttributes(yBlkHdl hdl, yStrRef *serial, yStrRef *funcId, yStrRef *funcName, Notification_funydx *funcInfo, char *funcVal)
Definition: yhash.c:1515
#define yFree(ptr)
Definition: yproto.h:199
int ypGetType(yBlkHdl hdl)
Definition: yhash.c:1551
JNIEXPORT jstring JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_getAPIVersion(JNIEnv *, jclass)
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_stopNotifications(JNIEnv *, jclass)
yBlkHdl yBlkListSeek(yBlkHdl hdl, u16 pos)
Definition: yhash.c:147
#define yMalloc(size)
Definition: yproto.h:198
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_devRequestAsync(JNIEnv *, jclass, jstring, jbyteArray, jobject, jobject)
JNIEXPORT void JNICALL Java_com_yoctopuce_YoctoAPI_YJniWrapper_startNotifications(JNIEnv *, jclass, jobject)
void YAPI_FUNCTION_EXPORT yapiRegisterFunctionUpdateCallback(yapiFunctionUpdateCallback updateCallback)
Definition: yapi.c:4353
char serial[YOCTO_SERIAL_LEN]
Definition: ydef.h:454
#define YISERR(retcode)
Definition: ydef.h:394
char productname[YOCTO_PRODUCTNAME_LEN]
Definition: ydef.h:453
s32 YAPI_DEVICE
Definition: ydef.h:216
#define YSTRCMP(A, B)
Definition: yproto.h:226
yBlkHdl yYpListHead
Definition: yhash.c:85
YRETCODE YAPI_FUNCTION_EXPORT yapiGetDeviceInfo(YAPI_DEVICE devdesc, yDeviceSt *infos, char *errmsg)
Definition: yapi.c:4506
YRETCODE YAPI_FUNCTION_EXPORT yapiUpdateDeviceList(u32 forceupdate, char *errmsg)
Definition: yapi.c:4437
YRETCODE YAPI_FUNCTION_EXPORT yapiHandleEvents(char *errmsg)
Definition: yapi.c:4446


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