package com.ociweb.grove;


import static com.ociweb.iot.grove.GroveTwig.Button;
import static com.ociweb.iot.grove.GroveTwig.LED;

import com.ociweb.iot.maker.Hardware;
import com.ociweb.iot.maker.FogCommandChannel;
import com.ociweb.iot.maker.FogRuntime;
import com.ociweb.iot.maker.FogApp;
import com.ociweb.iot.maker.Port;

import static com.ociweb.iot.maker.Port.*;

import com.ociweb.gl.api.GreenCommandChannel;

public class IoTApp implements FogApp
{
    private static final Port BUTTON_PORT = D3;
    private static final Port LED_PORT    = D2;
    
    @Override
    public void declareConnections(Hardware c) {
              
        c.connect(Button, BUTTON_PORT); 
        c.connect(LED, LED_PORT);        
        c.useI2C();
    }


    @Override
    public void declareBehavior(FogRuntime runtime) {
           
    	final FogCommandChannel channel1 = runtime.newCommandChannel(GreenCommandChannel.DYNAMIC_MESSAGING);
        //this digital listener will get all the button press and un-press events 
        runtime.addDigitalListener((port, connection, time, value)->{
        	if (BUTTON_PORT == port){
                	channel1.setValueAndBlock(LED_PORT, value, 200); 
                }
        });
    }
}

@@ -20,17 +20,16 @@
 grove;%0A%0A
-%0A
 import s
@@ -69,67 +69,11 @@
 wig.
-Button
+*
 ;%0A
-import static com.ociweb.iot.grove.GroveTwig.LED;%0A%0A
 impo
@@ -96,24 +96,17 @@
 t.maker.
-Hardware
+*
 ;%0Aimport
@@ -110,247 +110,42 @@
 ort 
-com.ociweb.iot.maker.FogCommandChannel;%0Aimport com.ociweb.iot.maker.FogRuntime;%0Aimport com.ociweb.iot.maker.FogApp;%0Aimport com.ociweb.iot.maker.Port;%0A%0Aimport static com.ociweb.iot.maker.Port.*;%0A%0Aimport com.ociweb.gl.api.GreenCommandChannel
+static com.ociweb.iot.maker.Port.*
 ;%0A%0Ap
@@ -231,20 +231,17 @@
 T = D3;%0A
-    
+%09
 private 
@@ -276,20 +276,16 @@
   = D2;%0A
-    
 %0A    @Ov
@@ -465,17 +465,16 @@
 %0A    %7D%0A%0A
-%0A
     @Ove
@@ -534,30 +534,24 @@
 ime) %7B%0A     
-      
 %0A    %09final 
@@ -609,28 +609,8 @@
 nel(
-GreenCommandChannel.
 DYNA
@@ -782,51 +782,8 @@
 -%3E%7B%0A
-        %09if (BUTTON_PORT == port)%7B%0A        
     
@@ -828,16 +828,21 @@
 T, value
+ == 1
 , 200); 
@@ -846,26 +846,8 @@
 ); %0A
-                %7D%0A
     

Update IoTApp.java