Advertisement
Guest User

Java_MainApp

a guest
Jun 18th, 2015
357
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 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.recieve.message;
  13.  
  14. import com.digi.xbee.api.XBeeDevice;
  15. import com.digi.xbee.api.exceptions.XBeeException;
  16.  
  17. /**
  18. * XBee Java Library Receive Data sample application.
  19. *
  20. * <p>This example registers a listener to manage the received data.</p>
  21. *
  22. * <p>For a complete description on the example, refer to the 'ReadMe.txt' file
  23. * included in the root directory.</p>
  24. */
  25. public class MainApp {
  26.  
  27. /* Constants */
  28.  
  29. // TODO Replace with the serial port where your receiver module is connected.
  30. private static final String PORT = "COM4";
  31. // TODO Replace with the baud rate of you receiver module.
  32. private static final int BAUD_RATE = 9600;
  33.  
  34. /**
  35. * Application main method.
  36. *
  37. * @param args Command line arguments.
  38. */
  39. public static void main(String[] args) {
  40. System.out.println(" +-----------------------------------------+");
  41. System.out.println(" | XBee Java Library Receive Data Sample |");
  42. System.out.println(" +-----------------------------------------+\n");
  43.  
  44. XBeeDevice myDevice = new XBeeDevice(PORT, BAUD_RATE);
  45.  
  46. try {
  47. myDevice.open();
  48.  
  49. myDevice.addDataListener(new MyDataReceiveListener());
  50.  
  51. System.out.println("\n>> Waiting for data...");
  52.  
  53. } catch (XBeeException e) {
  54. e.printStackTrace();
  55. System.exit(1);
  56. }
  57. }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement