Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void startApp() throws MIDletStateChangeException {
- InPort5V inport = null;
- OutPort5V outport = null;
- try {
- m_Cmd = new ATCommand(false);
- m_Cmd.addListener(m_Listener);
- String Response = m_Cmd.send("-AT+CMEE=2\r");
- System.out.println(Response);
- Response = m_Cmd.send("ati\r");
- System.out.println(Response);
- Vector pins = new Vector(2);
- pins.addElement("GPIO21");
- pins.addElement("GPIO20");
- inport = new InPort5V(pins);
- inport.addListener(new gpioListener());
- } catch (IOException e) {
- e.printStackTrace();
- } catch (ATCommandFailedException ex) {
- ex.printStackTrace();
- }
- catch (IllegalStateException ex) {
- ex.printStackTrace();
- } catch (IllegalArgumentException ex) {
- ex.printStackTrace();
- }
- int a = 0;
- boolean run = true;
- System.out.println("Inport : " + inport);
- while (run) {
- a++;
- if(a > 20)
- {
- try {
- inport.release();
- } catch (IOException ex) {
- ex.printStackTrace();
- } catch (OperationNotSupported ex) {
- ex.printStackTrace();
- }
- destroyApp(true);
- run = false;
- }
- try {
- Thread.sleep(4000);
- System.out.println(inport.getValue());
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- destroyApp(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement