Exemplo n.º 1
0
void handleDeviceInput() {
    bool throttle = false;
    bool dataSent = false;
    if ((millis()-throttleMark<1500)) {
        throttle=true;
    }
    switch (device.keyValue()) {
        case _LOG_:
            logData(device.arguments());                
            break;
        case _TS1_: 
            if (!throttle) {
                dataSent=true;
                toPachube(0, device.arguments());
            } break;
        case _TS2_: 
            if (!throttle) {
                dataSent=true;
                toPachube(1, device.arguments());
            } break;
        case _TS3_: 
            if (!throttle) {
                dataSent=true;
                toPachube(2, device.arguments());
            } break;
        case _TS4_: 
            if (!throttle) {
                dataSent=true;
                toPachube(3, device.arguments()); 
            } break;
        case _TS5_: 
            if (!throttle) {
                dataSent=true;
                toPachube(4, device.arguments()); 
            } break;
        case _FAN_: 
            if (!throttle) {
                dataSent=true;
                toPachube(5, device.arguments());
            } break;
        case _CHL_: 
            if (!throttle) {
                dataSent=true;
                toPachube(6, device.arguments());
            } break;
        case _STC_: 
            char * finger;
            if ((finger=strchr(device.arguments(),' ')) != NULL) {
                finger[0]='\0';
                toPachube(8, finger+1);
            }
            toPachube(7, device.arguments()); break; 
        case _FTL_: toPachube(7, device.arguments()); break;
            break;
        default:
            console.printf("%s",device.line());
            break;
    }
        if (dataSent) throttleMark=millis();
}
void handleConsoleInput() {
    uint8_t retval;
	uint8_t index=0;
	uint8_t ch='0';
    switch (console.keyValue()) {
        case _NSC_:  
			console.printf("SOD:\r\n");
			retval=networkScan();
			console.printf("EOD:\r\n");
            console.printf("\nDBG: found=%d\r\n",retval);
            break;
        case _NJN_:  
			//console.printf("SOD:\r\n");
			retval=networkJoin(console.arguments());
			//console.printf("EOD:\r\n");
            console.printf("\nDBG: joined=%s\r\n",retval?"TRUE":"FALSE");
            break;
        case _NPW_:  
			//console.printf("SOD:\r\n");
			retval=networkSetPassword(console.arguments());
			//console.printf("EOD:\r\n");
            console.printf("\nDBG: pwd set=%s\r\n",retval?"TRUE":"FALSE");
            break;
        case _NST_:  
			retval=networkStatus();
            console.printf("NST: %s\r\n",retval?"CONNECTED":"NOT CONNECTED");
            break;
            
		case _TPT_:
			toTheEthers(1, console.arguments());
			break;
        case _TX2_:
            radio.printf("%s",console.arguments());
            index=0;
            // delay(1000);
            while (radio.available()) {
                inBuffer[index++]=ch=radio.read();
				if( index>= 99 || ((ch== '\n') || ch !='\r')) {
					inBuffer[index]='\0';
					console.puts(inBuffer);
					index=0; 
					delay(100);
				}
            } 
            inBuffer[index]='\0';
            console.puts(inBuffer);
			console.puts((char *) "\r\n");
            break;
        case _PKY_:
            strncpy(pachubeKey, console.arguments(), MAX_PATCHUBE_KEY_LENGHT-1);
            stripcrlf(pachubeKey);
            break;
        default:
            console.printf("DBG: forwarding (%s) to device\r\n",console.key());
            //device.puts("\r\n");
            break;
    }
    
    
}
Exemplo n.º 3
0
void handleConsoleInput() {
    uint8_t retval;
	uint8_t index=0;
	uint8_t ch='0';
	SdFile finger;
    
    switch (console.keyValue()) {
        case _DIR_:
			console.printf("SOD:\r\n");
            root.ls(LS_DATE | LS_SIZE);
 			console.printf("EOD:\r\n");
			break;
        case _LSV_:
			console.printf("LSV:" BOM_VERSION "\r\n");
			break;
        case _TYP_:  
            typeFile(console.arguments());
            break;
        case _NSC_:  
			console.printf("SOD:\r\n");
			retval=networkScan();
			console.printf("EOD:\r\n");
            console.printf("\nDBG: found=%d\r\n",retval);
            break;
        case _NJN_:  
			//console.printf("SOD:\r\n");
			retval=networkJoin(console.arguments());
			//console.printf("EOD:\r\n");
            console.printf("\nDBG: joined=%s\r\n",retval?"TRUE":"FALSE");
            break;
        case _NPW_:  
			//console.printf("SOD:\r\n");
			retval=networkSetPassword(console.arguments());
			//console.printf("EOD:\r\n");
            console.printf("\nDBG: pwd set=%s\r\n",retval?"TRUE":"FALSE");
            break;
        case _NST_:  
			retval=networkStatus();
            console.printf("NST: %s\r\n",retval?"CONNECTED":"NOT CONNECTED");
            break;
		case _FMT_: // there really should be some REALLY do you mean this here but.....
			root.openRoot(&volume);
			if (finger.open(&root, ".", O_WRITE|O_READ)) {
				console.printf("\nDBG: Opened / \r\n");
				finger.rmRfStar();
			} else {
				console.printf("\nDBG: FAIL \r\n");
			}	
			break;
            
		case _TPT_:
			toPachube(1, console.arguments());
			break;
        case _TX2_:
            radio.printf("%s",console.arguments());
            index=0;
            // delay(1000);
            while (radio.available()) {
                inBuffer[index++]=ch=radio.read();
				if( index>= 99 || ((ch== '\n') || ch !='\r')) {
					inBuffer[index]='\0';
					console.puts(inBuffer);
					index=0; 
					delay(100);
				}
            } 
            inBuffer[index]='\0';
            console.puts(inBuffer);
			console.puts((char *) "\r\n");
            break;
// set to one to test output for.
#if 1
        case _TS1_: toPachube(0, console.arguments()); break;
        case _TS2_: toPachube(1, console.arguments()); break;
        case _TS3_: toPachube(2, console.arguments()); break;
        case _TS4_: toPachube(3, console.arguments()); break;
        case _TS5_: toPachube(4, console.arguments()); break;
        case _FAN_: toPachube(5, console.arguments()); break;
        case _CHL_: toPachube(6, console.arguments()); break;
        case _STC_: toPachube(7, console.arguments()); break;
#endif			

        case _PKY_:
            strncpy(pachubeKey, console.arguments(), MAX_PATCHUBE_KEY_LENGHT-1);
            stripcrlf(pachubeKey);
            break;
        case _PFD_:
            strncpy(pachubeFeed, console.arguments(), MAX_PATCHUBE_FEED_LENGHT-1);
            stripcrlf(pachubeFeed);
            break;
        case _SGT_ :
            readSettings();
            break;
        case _SSV_ :
            writeSettings();
            break;
            
        default:
            console.printf("DBG: forwarding (%s) to device\r\n",console.key());
            device.puts(console.line());
            //device.puts("\r\n");
            break;
    }
    
    
}