• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java LFXByteUtils类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中lifx.java.android.util.LFXByteUtils的典型用法代码示例。如果您正苦于以下问题:Java LFXByteUtils类的具体用法?Java LFXByteUtils怎么用?Java LFXByteUtils使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

LFXByteUtils类属于lifx.java.android.util包,在下文中一共展示了LFXByteUtils类的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: removeLightFromTaggedLightCollection

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public void removeLightFromTaggedLightCollection(LFXLight light, LFXTaggedLightCollection taggedLightCollection) {
    LFXDeviceMapping deviceMapping = routingTable.getDeviceMappingForDeviceID(light.getDeviceID());
    LFXSiteID siteID = deviceMapping.getSiteID();

    //LFXTagMapping tagMapping = routingTable.getTagMappingsForSiteIDAndTag( siteID, taggedLightCollection.getTag()).get( 0);
    ArrayList<LFXTagMapping> mappings = routingTable.getTagMappingsForSiteIDAndTag(siteID, taggedLightCollection.getTag());

    if (mappings.size() == 0) {
        return;
    }

    LFXTagMapping tagMapping = mappings.get(0);

    if (tagMapping == null) {
        return;
    }

    LFXMessage setTags = LFXMessage.messageWithTypeAndPath(Type.LX_PROTOCOL_DEVICE_SET_TAGS, LFXBinaryPath.getBroadcastBinaryPathWithSiteID(tagMapping.getSiteID()));
    Object padding = new Object();
    UInt64 tags = new UInt64(LFXByteUtils.bitwiseAndByteArrays(deviceMapping.getTagField().tagData, LFXByteUtils.inverseByteArrayBits(tagMapping.getTagField().tagData)));
    LxProtocolDevice.SetTags payload = new SetTags(padding, tags);
    setTags.setPayload(payload);
    sendMessage(setTags);
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:25,
代码来源:LFXNetworkContext.java

示例2: addTagToSiteWithSiteID

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public void addTagToSiteWithSiteID(String tag, LFXSiteID siteID) {
    TagField nextAvailableTagField = new TagField();
    nextAvailableTagField.tagData = new byte[8];
    for (int tagIndex = 0; tagIndex < 64; tagIndex++) {
        LFXByteUtils.clearByteArray(nextAvailableTagField.tagData);
        LFXByteUtils.setBit(nextAvailableTagField.tagData, tagIndex);
        if (routingTable.getTagMappingForSiteIDAndTagField(siteID, nextAvailableTagField) == null) {
            //nextAvailableTagField = tagField;
            break;
        }
    }

    if (LFXByteUtils.isByteArrayEmpty(nextAvailableTagField.tagData)) {
        if (LFXLog.isErrorEnabled()) LFXLog.e(TAG, "Unable to create tag " + tag + " in site " + siteID.getStringValue() + ", no available tag slots");
    } else {
        if (LFXLog.isErrorEnabled()) LFXLog.e(TAG, "Creating tag " + tag + " in site " + siteID.getStringValue() + " with tagField " + LFXByteUtils.byteArrayToHexString(nextAvailableTagField.tagData));
        LFXMessage setTagLabels = LFXMessage.messageWithTypeAndPath(Type.LX_PROTOCOL_DEVICE_SET_TAG_LABELS, LFXBinaryPath.getBroadcastBinaryPathWithSiteID(siteID));
        Object padding = new Object();
        UInt64 tags = new UInt64(nextAvailableTagField.tagData);
        LxProtocolDevice.SetTagLabels payload = new SetTagLabels(padding, tags, tag);
        setTagLabels.setPayload(payload);
        sendMessage(setTagLabels);
    }
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:25,
代码来源:LFXNetworkContext.java

示例3: enumerateTagField

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static ArrayList<TagField> enumerateTagField(TagField tagField) {
    ArrayList<TagField> singularTagFields = new ArrayList<TagField>();

    for (int tagIndex = 0; tagIndex < TAG_TARGET_ID_BITS; tagIndex++) {
        if (LFXByteUtils.isBitSet(tagField.tagData, tagIndex)) {
            TagField tempTagField = new TagField();
            byte[] tempTagBytes = new byte[TAG_TARGET_ID_BYTES];
            LFXByteUtils.setBit(tempTagBytes, tagIndex);
            tempTagField.tagData = tempTagBytes;

            singularTagFields.add(tempTagField);
        }
    }

    return singularTagFields;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:17,
代码来源:LFXBinaryTargetID.java

示例4: getIndividualGroupTargetIDs

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public ArrayList<LFXBinaryTargetID> getIndividualGroupTargetIDs() {
    // For future optimisation, this could get generated once, when a groupTargetID is created
    ArrayList<LFXBinaryTargetID> targetIDs = new ArrayList<LFXBinaryTargetID>();

    for (int bit = 0; bit < TAG_TARGET_ID_BITS; bit++) {
        if (LFXByteUtils.isBitSet(groupTagField.tagData, bit)) {
            byte[] newTag = new byte[TAG_TARGET_ID_BYTES];
            LFXByteUtils.setBit(newTag, bit);
            TagField tagField = new TagField();
            tagField.tagData = newTag;
            targetIDs.add(getGroupTargetIDWithTagField(tagField));
        }
    }

    return targetIDs;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:17,
代码来源:LFXBinaryTargetID.java

示例5: equal

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public boolean equal(LFXBinaryTargetID aTargetID) {
    if (aTargetID == null) {
        return false;
    }

    if (targetType != aTargetID.targetType) {
        return false;
    }

    switch (targetType) {
        case BROADCAST:
            return true;
        case DEVICE:
            return LFXByteUtils.areByteArraysEqual(deviceBytes, aTargetID.deviceBytes);//[_deviceBytes isEqualToData:aTargetID->_deviceBytes];
        case TAG:
            return LFXByteUtils.areByteArraysEqual(groupTagField.tagData, aTargetID.groupTagField.tagData);
    }

    return false;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:21,
代码来源:LFXBinaryTargetID.java

示例6: addTagToSiteWithSiteID

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public void addTagToSiteWithSiteID(String tag, LFXSiteID siteID) {
    TagField nextAvailableTagField = new TagField();
    nextAvailableTagField.tagData = new byte[8];
    for (int tagIndex = 0; tagIndex < 64; tagIndex++) {
        LFXByteUtils.clearByteArray(nextAvailableTagField.tagData);
        LFXByteUtils.setBit(nextAvailableTagField.tagData, tagIndex);
        if (routingTable.getTagMappingForSiteIDAndTagField(siteID, nextAvailableTagField) == null) {
            //nextAvailableTagField = tagField;
            break;
        }
    }

    if (LFXByteUtils.isByteArrayEmpty(nextAvailableTagField.tagData)) {
        LFXLog.e(TAG, "Unable to create tag " + tag + " in site " + siteID.getStringValue() + ", no available tag slots");
    } else {
        LFXLog.e(TAG, "Creating tag " + tag + " in site " + siteID.getStringValue() + " with tagField " + LFXByteUtils.byteArrayToHexString(nextAvailableTagField.tagData));
        LFXMessage setTagLabels = LFXMessage.messageWithTypeAndPath(Type.LX_PROTOCOL_DEVICE_SET_TAG_LABELS, LFXBinaryPath.getBroadcastBinaryPathWithSiteID(siteID));
        Object padding = new Object();
        UInt64 tags = new UInt64(nextAvailableTagField.tagData);
        String label = tag;
        LxProtocolDevice.SetTagLabels payload = new SetTagLabels(padding, tags, label);
        setTagLabels.setPayload(payload);
        sendMessage(setTagLabels);
    }
}
 

开发者ID:davidvavra,
项目名称:MoodSync,
代码行数:26,
代码来源:LFXNetworkContext.java

示例7: messageWithMessageData

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXMessage messageWithMessageData(byte[] data) {
    if (data == null || data.length == 0 || getTypeFromMessageData(data) == null) {
        LFXLog.w(TAG, "Warning: invalid type: " + StructleTypes.getShortValue(data[32], data[33]));
        return null;
    }

    byte[] bytes = new byte[data.length];
    LFXByteUtils.copyBytesIntoByteArray(bytes, data);

    if (!messageIsAddressable(bytes)) {
        // We don't know how to deal with non-addressable messages, but the bulbs are sometimes not setting this flag correctly
        LFXLog.w(TAG, "Warning: Message claims to be non-addressable: " + data);
        return null;
    }

    int protocol = getProtocolFromMessageData(bytes);
    if (protocol != CURRENT_PROTOCOL) {
        LFXLog.w(TAG, "Handling non-protocol message of protocol " + protocol);
        return LFXMessage.initWithNonProtocolMessageData(data);
    }

    return LFXMessage.initWithMessageData(data);    //[[class alloc] initWithMessageData:data];
}
 

开发者ID:davidvavra,
项目名称:MoodSync,
代码行数:24,
代码来源:LFXMessage.java

示例8: getTargetIDWithString

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXBinaryTargetID getTargetIDWithString( String stringValue)
{
	if( stringValue.contains( "*"))
	{
		return getBroadcastTargetID();
	}
	
	if( stringValue.contains( "#"))
	{
		String hexString = stringValue.substring( stringValue.indexOf( '#') + 1);
		TagField tagField = new TagField();
		tagField.tagData = LFXByteUtils.hexStringToByteArray( hexString);
		return getGroupTargetIDWithTagField( tagField);
	}
	else
	{
		// Device Target (6 bytes)
		return getDeviceTargetIDWithString( stringValue);
	}
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:21,
代码来源:LFXBinaryTargetID.java

示例9: enumerateTagField

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static ArrayList<TagField> enumerateTagField( TagField tagField)
{
	ArrayList<TagField> singularTagFields = new ArrayList<TagField>();
	
	for( int tagIndex = 0; tagIndex < TAG_TARGET_ID_BITS; tagIndex++)
	{
		if( LFXByteUtils.isBitSet( tagField.tagData, tagIndex))
		{
			TagField tempTagField = new TagField();
			byte[] tempTagBytes = new byte[TAG_TARGET_ID_BYTES];
			LFXByteUtils.setBit( tempTagBytes, tagIndex);
			tempTagField.tagData = tempTagBytes;
			
			singularTagFields.add( tempTagField);
		}
	}
	
	return singularTagFields;
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:20,
代码来源:LFXBinaryTargetID.java

示例10: getStringValue

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public String getStringValue()
{
	switch( targetType)
	{
		case BROADCAST:
		{
			return "*";
		}
		case TAG:
		{
			return "#" + LFXByteUtils.byteArrayToHexString( groupTagField.tagData);
		}
		case DEVICE:
		{
			return LFXByteUtils.byteArrayToHexString( deviceBytes);	//[_deviceBytes lfx_hexStringValue];
		}
	}
	
	return "LFXBinaryTarget: Unknown Type";
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:21,
代码来源:LFXBinaryTargetID.java

示例11: getIndividualGroupTargetIDs

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public ArrayList<LFXBinaryTargetID> getIndividualGroupTargetIDs()
{
	// For future optimisation, this could get generated once, when a groupTargetID is created
	ArrayList<LFXBinaryTargetID> targetIDs = new ArrayList<LFXBinaryTargetID>();
	
	for( int bit = 0; bit < TAG_TARGET_ID_BITS; bit++)
	{
		if( LFXByteUtils.isBitSet( groupTagField.tagData, bit))
		{
			byte[] newTag = new byte[TAG_TARGET_ID_BYTES];
			LFXByteUtils.setBit( newTag, bit);
			TagField tagField = new TagField();
			tagField.tagData = newTag;
			targetIDs.add( getGroupTargetIDWithTagField( tagField));
		}
	}
	
	return targetIDs;
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:20,
代码来源:LFXBinaryTargetID.java

示例12: equal

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public boolean equal( LFXBinaryTargetID aTargetID)
{
	if( aTargetID == null)
	{
		return false;
	}
	
	if( targetType != aTargetID.targetType) 
	{
		return false;
	}
	
	switch( targetType)
	{
		case BROADCAST:
			return true;
		case DEVICE:
			return LFXByteUtils.areByteArraysEqual( deviceBytes, aTargetID.deviceBytes);//[_deviceBytes isEqualToData:aTargetID->_deviceBytes];
		case TAG:
			return LFXByteUtils.areByteArraysEqual( groupTagField.tagData, aTargetID.groupTagField.tagData);
	}
	
	return false;
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:25,
代码来源:LFXBinaryTargetID.java

示例13: messageWithMessageData

点赞 3

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXMessage messageWithMessageData( byte [] data)
{
	if( data == null || data.length == 0)
	{
		return null;
	}
	
	byte[] bytes = new byte[data.length];
	LFXByteUtils.copyBytesIntoByteArray( bytes, data);
	
	if( !messageIsAddressable( bytes))
	{
		// We don't know how to deal with non-addressable messages, but the bulbs are sometimes not setting this flag correctly
		LFXLog.warn( "Warning: Message claims to be non-addressable: " + data);
		return null;
	}
	
	int protocol = getProtocolFromMessageData( bytes);
	if( protocol != CURRENT_PROTOCOL)
	{
		LFXLog.warn( "Handling non-protocol message of protocol " + protocol);
		return LFXMessage.initWithNonProtocolMessageData( data);
	}
	
	return LFXMessage.initWithMessageData( data);	//[[class alloc] initWithMessageData:data];
}
 

开发者ID:jmcgill,
项目名称:lifx-alarm,
代码行数:27,
代码来源:LFXMessage.java

示例14: addLightToTaggedLightCollection

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public void addLightToTaggedLightCollection(LFXLight light, LFXTaggedLightCollection taggedLightCollection) {
    String tag = taggedLightCollection.getTag();
    LFXDeviceMapping deviceMapping = routingTable.getDeviceMappingForDeviceID(light.getDeviceID());
    LFXSiteID siteID = deviceMapping.getSiteID();

    ArrayList<LFXTagMapping> mappings = routingTable.getTagMappingsForSiteIDAndTag(siteID, tag);
    if (mappings.size() == 0) {
        addTagToSiteWithSiteID(tag, siteID);

        mappings = routingTable.getTagMappingsForSiteIDAndTag(siteID, tag);

        if (mappings.size() == 0) {
            return;
        }
    }

    LFXTagMapping tagMapping = mappings.get(0);

    if (tagMapping == null) {
        return;
    }

    LFXMessage setTags = LFXMessage.messageWithTypeAndTarget(Type.LX_PROTOCOL_DEVICE_SET_TAGS, light.getTarget());
    Object padding = new Object();
    UInt64 tags = new UInt64(LFXByteUtils.bitwiseOrByteArrays(deviceMapping.getTagField().tagData, tagMapping.getTagField().tagData));
    LxProtocolDevice.SetTags payload = new SetTags(padding, tags);
    setTags.setPayload(payload);
    sendMessage(setTags);
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:30,
代码来源:LFXNetworkContext.java

示例15: SocketMessage

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public SocketMessage(byte[] message, byte[] ipAddress, int port) {
    int size = LFXMessage.getSizeFromMessageData(message);
    byte[] bytes = new byte[size];
    LFXByteUtils.copyBytesIntoByteArrayUpToLength(bytes, message, size);
    this.message = bytes;
    this.ipAddress = ipAddress;
    this.port = port;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:9,
代码来源:LFXSocketGeneric.java

示例16: getStringValue

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public String getStringValue() {
    if (this.isZeroSite()) {
        return "*";
    }

    return LFXByteUtils.byteArrayToHexString(data);
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:8,
代码来源:LFXSiteID.java

示例17: equals

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public boolean equals(TagField otherTagField) {
    if (otherTagField == null) {
        return false;
    }

    if (LFXByteUtils.areByteArraysEqual(tagData, otherTagField.tagData)) {
        return true;
    }

    return false;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:12,
代码来源:LFXBinaryTargetID.java

示例18: getTargetIDWithString

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXBinaryTargetID getTargetIDWithString(String stringValue) {
    if (stringValue.contains("*")) {
        return getBroadcastTargetID();
    }

    if (stringValue.contains("#")) {
        String hexString = stringValue.substring(stringValue.indexOf('#') + 1);
        TagField tagField = new TagField();
        tagField.tagData = LFXByteUtils.hexStringToByteArray(hexString);
        return getGroupTargetIDWithTagField(tagField);
    } else {
        // Device Target (6 bytes)
        return getDeviceTargetIDWithString(stringValue);
    }
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:16,
代码来源:LFXBinaryTargetID.java

示例19: getDeviceTargetIDWithData

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXBinaryTargetID getDeviceTargetIDWithData(byte[] data) {
    LFXBinaryTargetID targetID = new LFXBinaryTargetID();
    targetID.targetType = LFXBinaryTargetType.DEVICE;
    targetID.deviceBytes = new byte[DEVICE_TARGET_ID_BYTES];
    LFXByteUtils.copyBytesIntoByteArrayUpToLength(targetID.deviceBytes, data, DEVICE_TARGET_ID_BYTES);
    return targetID;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:8,
代码来源:LFXBinaryTargetID.java

示例20: getStringValue

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public String getStringValue() {
    switch (targetType) {
        case BROADCAST: {
            return "*";
        }
        case TAG: {
            return "#" + LFXByteUtils.byteArrayToHexString(groupTagField.tagData);
        }
        case DEVICE: {
            return LFXByteUtils.byteArrayToHexString(deviceBytes);    //[_deviceBytes lfx_hexStringValue];
        }
    }

    return "LFXBinaryTarget: Unknown Type";
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:16,
代码来源:LFXBinaryTargetID.java

示例21: getDebugStringValue

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public String getDebugStringValue() {
    if (getTargetType() == LFXBinaryTargetType.DEVICE) {
        return LFXByteUtils.byteArrayToHexString(this.deviceBytes);
    } else if (getTargetType() == LFXBinaryTargetType.TAG) {
        return LFXByteUtils.byteArrayToHexString(this.groupTagField.tagData);
    } else {
        return LFXByteUtils.byteArrayToHexString(this.groupTagField.tagData);
    }
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:10,
代码来源:LFXBinaryTargetID.java

示例22: messageWithMessageData

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public static LFXMessage messageWithMessageData(byte[] data) {
    // Theoretically the minimum message length should be 36 but I think the last 2 bytes aren't used
    if (data == null || data.length < 34 || getTypeFromMessageData(data) == null) {
        if (LFXLog.isWarningEnabled())
            LFXLog.w(TAG, "Warning: invalid type: " + StructleTypes.getShortValue(data[32], data[33]));
        return null;
    }

    byte[] bytes = new byte[data.length];
    LFXByteUtils.copyBytesIntoByteArray(bytes, data);

    if (!messageIsAddressable(bytes)) {
        // We don't know how to deal with non-addressable messages, but the bulbs are sometimes not setting this flag correctly
        if (LFXLog.isWarningEnabled())
            LFXLog.w(TAG, "Warning: Message claims to be non-addressable: " + data);
        return null;
    }

    int protocol = getProtocolFromMessageData(bytes);
    if (protocol != CURRENT_PROTOCOL) {
        if (LFXLog.isWarningEnabled())
            LFXLog.w(TAG, "Handling non-protocol message of protocol " + protocol);
        return LFXMessage.initWithNonProtocolMessageData(data);
    }

    return LFXMessage.initWithMessageData(data);    //[[class alloc] initWithMessageData:data];
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:28,
代码来源:LFXMessage.java

示例23: initWithMessageData

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
private static LFXMessage initWithMessageData(byte[] data) {
    Type messageType = getTypeFromMessageData(data);

    LFXMessage message = new LFXMessage(messageType);
    message.timestamp = System.currentTimeMillis();
    message.messageDirection = LFXMessageDirection.INCOMING;

    byte[] bytes = new byte[data.length];
    LFXByteUtils.copyBytesIntoByteArray(bytes, data);

    message.size = getSizeFromMessageData(bytes);
    message.protocol = getProtocolFromMessageData(bytes);
    message.atTime = getAtTimeFromMessageData(bytes);
    message.messageType = getTypeFromMessageData(bytes);

    LFXSiteID site = LFXSiteID.getSiteIDWithData(getSiteIDFromMessageData(bytes));

    LFXBinaryTargetID target;
    if (getIsTaggedFromMessageData(bytes)) {
        TagField tagField = new TagField();
        tagField.tagData = getTargetFromMessageData(bytes);
        target = LFXBinaryTargetID.getGroupTargetIDWithTagField(tagField);
    } else {
        target = LFXBinaryTargetID.getDeviceTargetIDWithData(getTargetFromMessageData(bytes));
    }

    message.path = LFXBinaryPath.getPathWithSiteIDAndTargetID(site, target);

    message.payload = getPayloadFromMessageData(bytes);

    message.rawData = data;

    return message;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:35,
代码来源:LFXMessage.java

示例24: initWithNonProtocolMessageData

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
private static LFXMessage initWithNonProtocolMessageData(byte[] data) {
    Type type = getTypeFromMessageData(data);

    LFXMessage message = new LFXMessage(type);
    message.timestamp = System.currentTimeMillis();
    message.messageDirection = LFXMessageDirection.INCOMING;

    byte[] bytes = new byte[data.length];
    LFXByteUtils.copyBytesIntoByteArray(bytes, data);

    message.size = getSizeFromMessageData(data);
    message.protocol = getProtocolFromMessageData(data);
    message.messageType = getTypeFromMessageData(data);

    LFXSiteID site = LFXSiteID.getSiteIDWithData(getSiteIDFromMessageData(data));

    LFXBinaryTargetID target;
    if (getIsTaggedFromMessageData(bytes)) {
        TagField tagField = new TagField();
        tagField.tagData = getTargetFromMessageData(bytes);
        target = LFXBinaryTargetID.getGroupTargetIDWithTagField(tagField);
    } else {
        target = LFXBinaryTargetID.getDeviceTargetIDWithData(getTargetFromMessageData(bytes));
    }

    message.path = LFXBinaryPath.getPathWithSiteIDAndTargetID(site, target);

    message.rawData = data;
    message.isNonProtocolMessage = true;

    return message;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:33,
代码来源:LFXMessage.java

示例25: getMessageDataRepresentation

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
public byte[] getMessageDataRepresentation() {
    byte[] data;

    if (payload != null) {
        data = new byte[getMessageDataRepresentationLength()];
    } else {
        data = new byte[BASE_MESSAGE_SIZE];
    }

    writeSizeToMessage((short) data.length, data);
    writeProtocolToMessage((short) protocol, data);
    writeIsAddressableToMessage(true, data);
    data[22] = 1; // Request response
    writeAtTimeToMessage(atTime, data);
    writeTypeToMessage(messageType, data);
    if (path != null && path.getSiteID() != null) {
        writeSiteIDToMessage(path.getSiteID().getDataValue(), data);
    } else {
        if (LFXLog.isErrorEnabled())
            LFXLog.e(TAG, "getMessageDataRepresentation() - Message with no path/siteId:" + Arrays.toString(data));
    }

    if (path.getBinaryTargetID().geTargetType() == LFXBinaryTargetType.DEVICE) {
        writeTargetIDtoMessage(path.getBinaryTargetID().getDeviceDataValue(), data);
        writeIsTaggedToMessage(false, data);
    } else {
        writeTargetIDtoMessage(path.getBinaryTargetID().getGroupTagField().tagData, data);
        writeIsTaggedToMessage(true, data);
    }

    if (payload != null) {
        byte[] payloadData = payload.getBytes();

        LFXByteUtils.copyBytesIntoByteArrayAtOffset(data, payloadData, PAYLOAD_START_INDEX);
    }

    return data;
}
 

开发者ID:getsenic,
项目名称:lifx-sdk-android,
代码行数:39,
代码来源:LFXMessage.java

示例26: equals

点赞 2

import lifx.java.android.util.LFXByteUtils; //导入依赖的package包/类
@Override
public boolean equals(Object aSiteID) {
    if (aSiteID == null) {
        return false;
    }

    if (!LFXByteUtils.areByteArraysEqual(data, ((LFXSiteID)aSiteID).data)) {
        return false;
    }

    return true;
}
 

开发者ID:davidvavra,
项目名称:MoodSync,
代码行数:13,
代码来源:LFXSiteID.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)