Advertisement
Guest User

Untitled

a guest
Sep 12th, 2014
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. public void configGPIO()
  2. {
  3. System.out.println("Config start.");
  4. ATCommand m_Cmd;
  5. CommConnection commConn;
  6. InputStream inStream;
  7. OutputStream outStream;
  8. System.out.println("Available COM-Ports: " + System.getProperty("microedition.commports"));
  9. String strCOM = "comm:COM1;blocking=on;baudrate=115200";
  10.  
  11. try {
  12. m_Cmd = new ATCommand(false);
  13. String Response = m_Cmd.send("AT^SSPI=\r");
  14. System.out.println("Response: " + Response);
  15. commConn = (CommConnection)Connector.open(strCOM);
  16. System.out.println("CommConnection(" + strCOM + ") opened");
  17. System.out.println("Real baud rate: " + commConn.getBaudRate());
  18. inStream = commConn.openInputStream();
  19. outStream = commConn.openOutputStream();
  20. System.out.println("InputStream and OutputStream opened");
  21.  
  22. Thread.sleep(2000);
  23. outStream.write(new String("<aD41800>\r").getBytes());
  24. Thread.sleep(2000);
  25. outStream.write(new String("<aD41900>\r").getBytes());
  26. Thread.sleep(2000);
  27. outStream.write(new String("#\r").getBytes());
  28. System.out.println("End of data stream");
  29. Thread.sleep(2000);
  30. outStream.close();
  31. commConn.close();
  32.  
  33. Response = m_Cmd.send("AT+CFUN=1,1\r");
  34. System.out.println("Response: " + Response);
  35. Thread.sleep(10000);
  36. } catch (ATCommandFailedException ex) {
  37. ex.printStackTrace();
  38. } catch (IllegalStateException ex) {
  39. ex.printStackTrace();
  40. } catch (IOException ex) {
  41. ex.printStackTrace();
  42. } catch (InterruptedException ex) {
  43. ex.printStackTrace();
  44. }
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement