Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library/src/main/java/com/digi/xbee/api/IPDevice.java
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ private NetworkMessage readNetworkDataPacket(IP32BitAddress remoteIPAddress, int
case RX_IPV4:
RXIPv4Packet receivePacket = (RXIPv4Packet)xbeePacket;
data = receivePacket.getData();
ipAddress = receivePacket.getDestAddress();
ipAddress = receivePacket.getSourceAddress();
sourcePort = receivePacket.getSourcePort();
destPort = receivePacket.getDestPort();
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ private void packetReceived(XBeePacket packet) {
case RX_IPV4:
RXIPv4Packet rxIPv4Packet = (RXIPv4Packet)apiPacket;
notifyNetworkDataReceived(new NetworkMessage(
rxIPv4Packet.getDestAddress(),
rxIPv4Packet.getSourceAddress(),
rxIPv4Packet.getSourcePort(),
rxIPv4Packet.getDestPort(),
rxIPv4Packet.getProtocol(),
Expand Down
15 changes: 15 additions & 0 deletions library/src/main/java/com/digi/xbee/api/io/IOSample.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
package com.digi.xbee.api.io;

import java.util.Arrays;
import java.util.HashMap;

import com.digi.xbee.api.exceptions.OperationNotSupportedException;
Expand Down Expand Up @@ -553,4 +554,18 @@ public String toString() {
s = s.substring(0, s.length() - 2);
return s + "}";
}

/*
* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
try {
IOSample sample = (IOSample)obj;
return Arrays.equals(ioSamplePayload, sample.ioSamplePayload);
} catch (ClassCastException e) {
return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package com.digi.xbee.api.models;

import java.util.HashMap;

/**
* Enumerates the different Device Cloud statuses.
*/
public enum DeviceCloudStatus {

// Enumeration types.
SUCCESS(0x00, "Success"),
BAD_REQUEST(0x01, "Bad request"),
RESPONSE_UNAVAILABLE(0x02, "Response unavailable"),
DEVICE_CLOUD_ERROR(0x03, "Device Cloud error"),
CANCELED(0x20, "Device Request canceled by user"),
TIME_OUT(0x21, "Session timed out"),
UNKNOWN_ERROR(0x40, "Unknown error");

// Variables.
private int id;

private String name;

private static HashMap<Integer, DeviceCloudStatus> lookupTable = new HashMap<Integer, DeviceCloudStatus>();

static {
for (DeviceCloudStatus status:values())
lookupTable.put(status.getID(), status);
}

/**
* Creates a new {@code DeviceCloudStatus} entry with the given ID.
*
* @param id Status ID.
* @param name Status name.
*/
DeviceCloudStatus(int id, String name) {
this.id = id;
this.name = name;
}

/**
* Retrieves the status ID.
*
* @return The Status ID.
*/
public int getID() {
return id;
}

/**
* Retrieves the status name.
*
* @return The status name.
*/
public String getName() {
return name;
}

/**
* Retrieves the {@code DeviceCloudStatus} for the given ID.
*
* @param id ID to retrieve.
*
* @return The {@code DeviceCloudStatus} associated to the given ID.
*/
public static DeviceCloudStatus get(int id) {
return lookupTable.get(id);
}

/*
* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return name;
}
}
78 changes: 78 additions & 0 deletions library/src/main/java/com/digi/xbee/api/models/FrameError.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.digi.xbee.api.models;

import java.util.HashMap;

/**
* Enumerates the different frame errors.
*/
public enum FrameError {

// Enumeration types.
INVALID_TYPE(0x02, "Invalid frame type"),
INVALID_LENGTH(0x03, "Invalid frame length"),
INVALID_CHECKSUM(0x04, "Erroneous checksum on last frame"),
PAYLOAD_TOO_BIG(0x05, "Payload of last API frame was too big to fit into a buffer"),
STRING_ENTRY_TOO_BIG(0x06, "String entry was too big on last API frame sent"),
WRONG_STATE(0x07, "Wrong state to receive frame"),
WRONG_REQUEST_ID(0x08, "Device request ID of device response didn't match the number in the request");

// Variables.
private int id;

private String name;

private static HashMap<Integer, FrameError> lookupTable = new HashMap<Integer, FrameError>();

static {
for (FrameError frameError:values())
lookupTable.put(frameError.getID(), frameError);
}

/**
* Creates a new Frame Error entry with the given ID.
*
* @param id Frame Error ID.
* @param name Frame Error name.
*/
FrameError(int id, String name) {
this.id = id;
this.name = name;
}

/**
* Retrieves the Frame Error ID.
*
* @return Frame Error ID.
*/
public int getID() {
return id;
}

/**
* Retrieves the Frame Error name.
*
* @return Frame Error name.
*/
public String getName() {
return name;
}

/**
* Retrieves the Frame Error for the given ID.
*
* @param id ID to retrieve the Frame Error.
* @return The Frame Error associated with the given ID.
*/
public static FrameError get(int id) {
return lookupTable.get(id);
}

/*
* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return name;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.digi.xbee.api.models;

import java.util.HashMap;

import com.digi.xbee.api.packet.devicecloud.SendDataRequestPacket;

/**
* Enumerates the different options for the {@link SendDataRequestPacket}.
*/
public enum SendDataRequestOptions {

// Enumeration types.
OVERWRITE(0, "Overwrite"),
ARCHIVE(1, "Archive"),
APPEND(2, "Append"),
TRANSIENT(3, "Transient data (do not store)");

// Variables.
private int id;

private String name;

private static HashMap<Integer, SendDataRequestOptions> lookupTable = new HashMap<Integer, SendDataRequestOptions>();

static {
for (SendDataRequestOptions option:values())
lookupTable.put(option.getID(), option);
}

/**
* Creates a new {@code SendDataRequestOptions} entry with the given ID.
*
* @param id Option ID.
* @param name Option name.
*/
SendDataRequestOptions(int id, String name) {
this.id = id;
this.name = name;
}

/**
* Retrieves the option ID.
*
* @return The option ID.
*/
public int getID() {
return id;
}

/**
* Retrieves the option name.
*
* @return The option name.
*/
public String getName() {
return name;
}

/**
* Retrieves the {@code SendDataRequestOptions} for the given ID.
*
* @param id ID to retrieve.
*
* @return The {@code SendDataRequestOptions} associated to the given ID.
*/
public static SendDataRequestOptions get(int id) {
return lookupTable.get(id);
}

/*
* (non-Javadoc)
* @see java.lang.Enum#toString()
*/
@Override
public String toString() {
return name;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ private boolean ipAddressesMatch(XBeePacket xbeePacket, IP32BitAddress ipAddress
APIFrameType packetType = ((XBeeAPIPacket)xbeePacket).getFrameType();
switch (packetType) {
case RX_IPV4:
if (((RXIPv4Packet)xbeePacket).getDestAddress().equals(ipAddress))
if (((RXIPv4Packet)xbeePacket).getSourceAddress().equals(ipAddress))
return true;
break;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,36 @@ public enum APIFrameType {
UNKNOWN (-1, "Unknown packet"),
TX_64 (0x00, "TX (Transmit) Request 64-bit address"),
TX_16 (0x01, "TX (Transmit) Request 16-bit address"),
REMOTE_AT_COMMAND_REQUEST_WIFI (0x07, "Remote AT Command Request (Wi-Fi)"),
AT_COMMAND (0x08, "AT Command"),
AT_COMMAND_QUEUE (0x09, "AT Command Queue"),
TRANSMIT_REQUEST (0x10, "Transmit Request"),
EXPLICIT_ADDRESSING_COMMAND_FRAME (0x11, "Explicit Addressing Command Frame"),
REMOTE_AT_COMMAND_REQUEST (0x17, "Remote AT Command Request"),
TX_SMS (0x1F, "TX SMS"),
TX_IPV4 (0x20, "TX IPv4"),
SEND_DATA_REQUEST (0x28, "Send Data Request"),
DEVICE_RESPONSE (0x2A, "Device Response"),
RX_64 (0x80, "RX (Receive) Packet 64-bit Address"),
RX_16 (0x81, "RX (Receive) Packet 16-bit Address"),
RX_IO_64 (0x82, "IO Data Sample RX 64-bit Address Indicator"),
RX_IO_16 (0x83, "IO Data Sample RX 16-bit Address Indicator"),
REMOTE_AT_COMMAND_RESPONSE_WIFI (0x87, "Remote AT Command Response (Wi-Fi)"),
AT_COMMAND_RESPONSE (0x88, "AT Command Response"),
TX_STATUS (0x89, "TX (Transmit) Status"),
MODEM_STATUS (0x8A, "Modem Status"),
TRANSMIT_STATUS (0x8B, "Transmit Status"),
IO_DATA_SAMPLE_RX_INDICATOR_WIFI (0x8F, "IO Data Sample RX Indicator (Wi-Fi)"),
RECEIVE_PACKET (0x90, "Receive Packet"),
EXPLICIT_RX_INDICATOR (0x91, "Explicit RX Indicator"),
IO_DATA_SAMPLE_RX_INDICATOR (0x92, "IO Data Sample RX Indicator"),
REMOTE_AT_COMMAND_RESPONSE (0x97, "Remote Command Response"),
RX_SMS (0x9F, "RX SMS"),
RX_IPV4 (0xB0, "RX IPv4"),
SEND_DATA_RESPONSE (0xB8, "Send Data Response"),
DEVICE_REQUEST (0xB9, "Device Request"),
DEVICE_RESPONSE_STATUS (0xBA, "Device Response Status"),
FRAME_ERROR (0xFE, "Frame Error"),
GENERIC (0xFF, "Generic");

// Variables.
Expand Down
Loading