Advertisement
Guest User

Untitled

a guest
Aug 8th, 2014
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. protected void startApp() throws MIDletStateChangeException {
  2. InPort5V inport = null;
  3. OutPort5V outport = null;
  4. try {
  5. m_Cmd = new ATCommand(false);
  6. m_Cmd.addListener(m_Listener);
  7. String Response = m_Cmd.send("-AT+CMEE=2\r");
  8. System.out.println(Response);
  9.  
  10. Response = m_Cmd.send("ati\r");
  11. System.out.println(Response);
  12.  
  13. Vector pins = new Vector(2);
  14. pins.addElement("GPIO21");
  15. pins.addElement("GPIO20");
  16.  
  17. inport = new InPort5V(pins);
  18. inport.addListener(new gpioListener());
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. } catch (ATCommandFailedException ex) {
  22. ex.printStackTrace();
  23. }
  24. catch (IllegalStateException ex) {
  25. ex.printStackTrace();
  26. } catch (IllegalArgumentException ex) {
  27. ex.printStackTrace();
  28.  
  29. }
  30.  
  31. int a = 0;
  32. boolean run = true;
  33. System.out.println("Inport : " + inport);
  34. while (run) {
  35.  
  36. a++;
  37. if(a > 20)
  38. {
  39. try {
  40. inport.release();
  41. } catch (IOException ex) {
  42. ex.printStackTrace();
  43. } catch (OperationNotSupported ex) {
  44. ex.printStackTrace();
  45. }
  46. destroyApp(true);
  47. run = false;
  48. }
  49. try {
  50. Thread.sleep(4000);
  51. System.out.println(inport.getValue());
  52. } catch (InterruptedException e) {
  53. e.printStackTrace();
  54. } catch (IOException e) {
  55. e.printStackTrace();
  56. }
  57. }
  58. destroyApp(true);
  59. }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement