void requestHTTPAsync( String request, byte[] rest_of_request, YGenericHub.RequestAsyncResult asyncResult, Object context) throws YAPI_Exception { String shortRequest = formatRequest(request); _hub.devRequestAsync(this, shortRequest, rest_of_request, asyncResult, context); }
byte[] requestHTTPSync(String request, byte[] rest_of_request) throws YAPI_Exception { String shortRequest = formatRequest(request); return _hub.devRequestSync(this, shortRequest, rest_of_request); }
String requestHTTPSyncAsString(String request, byte[] rest_of_request) throws YAPI_Exception { String shortRequest = formatRequest(request); final byte[] bytes = _hub.devRequestSync(this, shortRequest, rest_of_request); return new String(bytes, YAPI.DeviceCharset); }
public NotificationStreams(String serial, byte[] data, boolean isV2) throws YAPI_Exception { int firstByte = data[0]; if (isV2 || firstByte <= NOTIFY_1STBYTE_MAXTINY || firstByte >= NOTIFY_1STBYTE_MINSMALL) { _funcvalType = (firstByte >> NOTIFY_V2_TYPE_OFS) & NOTIFY_V2_TYPE_MASK; _serial = serial; _funydx = firstByte & NOTIFY_V2_FUNYDX_MASK; if (_funcvalType == YGenericHub.NOTIFY_V2_FLUSHGROUP) { _notType = NotType.FUNCVALFLUSH; } else { _notType = NotType.FUNCVAL_TINY; if ((firstByte & NOTIFY_V2_IS_SMALL_FLAG) != 0) { // added on 2015-02-25, remove code below when confirmed dead code throw new YAPI_Exception(YAPI.IO_ERROR, "Hub Should not fwd notification"); } _funcval = YGenericHub.decodePubVal(_funcvalType, data, 1, data.length - 1); } } else { _serial = arrayToString(data, 0, YAPI.YOCTO_SERIAL_LEN); int p = YAPI.YOCTO_SERIAL_LEN; int type = data[p++]; switch (type) { case NOTIFY_PKT_NAME: _notType = NotType.NAME; _logicalname = arrayToString(data, p, YAPI.YOCTO_LOGICAL_LEN); _beacon = data[p + YAPI.YOCTO_LOGICAL_LEN]; break; case NOTIFY_PKT_PRODNAME: _notType = NotType.PRODNAME; _product = arrayToString(data, p, YAPI.YOCTO_PRODUCTNAME_LEN); break; case NOTIFY_PKT_CHILD: _notType = NotType.CHILD; _childserial = arrayToString(data, p, YAPI.YOCTO_SERIAL_LEN); p += YAPI.YOCTO_SERIAL_LEN; _onOff = data[p++]; _devydy = data[p]; break; case NOTIFY_PKT_FIRMWARE: _notType = NotType.FIRMWARE; _firmware = arrayToString(data, p, YAPI.YOCTO_FIRMWARE_LEN); p += YAPI.YOCTO_FIRMWARE_LEN; _vendorid = data[p] + (data[p + 1] << 8); p += 2; _deviceid = data[p] + (data[p + 1] << 8); break; case NOTIFY_PKT_FUNCNAME: _notType = NotType.FUNCNAME; _functionId = arrayToString(data, p, YAPI.YOCTO_FUNCTION_LEN); p += YAPI.YOCTO_FUNCTION_LEN; _funcname = arrayToString(data, p, YAPI.YOCTO_LOGICAL_LEN); break; case NOTIFY_PKT_FUNCVAL: _notType = NotType.FUNCVAL; _functionId = arrayToString(data, p, YAPI.YOCTO_FUNCTION_LEN); p += YAPI.YOCTO_FUNCTION_LEN; _funcval = arrayToString(data, p, YAPI.YOCTO_PUBVAL_SIZE); break; case NOTIFY_PKT_STREAMREADY: _notType = NotType.STREAMREADY; break; case NOTIFY_PKT_LOG: _notType = NotType.LOG; break; case NOTIFY_PKT_FUNCNAMEYDX: _notType = NotType.FUNCNAMEYDX; _functionId = arrayToString(data, p, YAPI.YOCTO_FUNCTION_LEN - 1); p += YAPI.YOCTO_FUNCTION_LEN - 1; _funclass = data[p++]; _funcname = arrayToString(data, p, YAPI.YOCTO_LOGICAL_LEN); p += YAPI.YOCTO_LOGICAL_LEN; _funydx = data[p]; break; default: throw new YAPI_Exception(YAPI.IO_ERROR, "Invalid Notification"); } } }