Advertisement
Guest User

Listener_Class_Java

a guest
Jun 18th, 2015
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. /**
  2. * Copyright (c) 2014-2015 Digi International Inc.,
  3. * All rights not expressly granted are reserved.
  4. *
  5. * This Source Code Form is subject to the terms of the Mozilla Public
  6. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  7. * You can obtain one at http://mozilla.org/MPL/2.0/.
  8. *
  9. * Digi International Inc. 11001 Bren Road East, Minnetonka, MN 55343
  10. * =======================================================================
  11. */
  12. package com.digi.xbee.api.receivedata;
  13.  
  14. import com.digi.xbee.api.listeners.IDataReceiveListener;
  15. import com.digi.xbee.api.models.XBeeMessage;
  16. import com.digi.xbee.api.utils.HexUtils;
  17.  
  18. /**
  19. * Class to manage the XBee received data that was sent by other modules in the
  20. * same network.
  21. *
  22. * <p>Acts as a data listener by implementing the
  23. * {@link IDataReceiveListener} interface, and is notified when new
  24. * data for the module is received.</p>
  25. *
  26. * @see IDataReceiveListener
  27. *
  28. */
  29. public class MyDataReceiveListener implements IDataReceiveListener {
  30. /*
  31. * (non-Javadoc)
  32. * @see com.digi.xbee.api.listeners.IDataReceiveListener#dataReceived(com.digi.xbee.api.models.XBeeMessage)
  33. */
  34. @Override
  35. public void dataReceived(XBeeMessage xbeeMessage) {
  36. System.out.format("From %s >> %s | %s%n", xbeeMessage.getDevice().get64BitAddress(),
  37. HexUtils.prettyHexString(HexUtils.byteArrayToHexString(xbeeMessage.getData())),
  38. new String(xbeeMessage.getData()));
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement