@@ -279,31 +279,6 @@ void NinjaObjects::doReactors()
279279 {
280280 if (decodeJSON ())
281281 {
282- // Print out decoded Params
283- /*
284- Serial.println();
285- Serial.print("GUID=");
286- Serial.print(strGUID);
287- Serial.print(",");
288-
289- Serial.print("VID=");
290- Serial.print(intVID);
291- Serial.print(",");
292-
293- Serial.print("DID=");
294- Serial.print(intDID);
295- Serial.print(",");
296-
297- Serial.print("DATA=");
298-
299- if (IsDATAString)
300- Serial.println(strDATA);
301- else
302- Serial.println(intDATA);
303-
304- Serial.println();
305- */
306-
307282 if (intVID==0 ) // VID 0 is reserved for Ninja Blocks
308283 {
309284 switch (intDID)
@@ -327,10 +302,9 @@ void NinjaObjects::doReactors()
327302
328303 BLUE_LED_VALUE = int ((colorVal&0x0000ff )>>0 );
329304 analogWrite (BLUE_LED_PIN, 255 -BLUE_LED_VALUE);
330- #endif
305+ #endif
331306
332307 doJSONResponse ();
333- // memset(strDATA,0, DATA_LEN);
334308 break ;
335309 }
336310
@@ -360,7 +334,6 @@ void NinjaObjects::doReactors()
360334 mySwitch.send (strDATA);
361335 mySwitch.disableTransmit ();
362336 doJSONResponse ();
363- // memset(strDATA,0, DATA_LEN);
364337 break ;
365338 }
366339
@@ -669,58 +642,46 @@ void NinjaObjects::doLacrosseWS2355(unsigned long long ws2344value)
669642 checksum=checksum & 0xf ;
670643 if ((nibble[0 ]==0x9 ) && (nibble[11 ]==checksum))
671644 {
672- // good packet
673-
674645 byte SensorAddress = (nibble[2 ]<<4 ) + nibble[3 ];
675646 sprintf (strAddress," %X" , SensorAddress);
676647 byte Type = nibble[1 ] & 0x3 ;
677648
678649 switch (Type)
679650 {
680- case 0 :
651+ case 0 : // temperature in Celsius
681652 double temperature;
682653 temperature =nibble[6 ] *100 ;
683654 temperature +=nibble[7 ] *10 ;
684655 temperature +=nibble[8 ];
685656 temperature =(temperature-300 )/10 ;
686657 doJSONData (strAddress, 0 , 20 , NULL , temperature, false );
687- // Serial.print (" Temp=");
688- // printDouble(temperature,1);
689658 break ;
690- case 1 :
659+
660+ case 1 : // humidity in %
691661 int humidity;
692662 humidity = nibble[6 ]*10 ;
693663 humidity += nibble[7 ];
694664 doJSONData (strAddress, 0 , 21 , NULL , humidity, false );
695- // Serial.print(" Humidity=");
696- // Serial.print(humidity);
697665 break ;
698- case 2 :
666+
667+ case 2 : // total rainfall in mm
699668 double rainfall;
700669 rainfall = nibble[6 ]<<8 ;
701670 rainfall += nibble[7 ]<<4 ;
702671 rainfall += nibble[8 ];
703672 rainfall = (rainfall*518 )/1000 ;
704673 doJSONData (strAddress, 0 , 22 , NULL , rainfall, false );
705- // Serial.print(" Rainfall=");
706- // printDouble(rainfall,2);
707- // Serial.print("mm");
708674 break ;
709- case 3 :
675+
676+ case 3 : // wind direction in NSEW and wind spped in KMH
710677 double windspeed;
711678 windir = (byte)nibble[8 ];
712679 windspeed = (nibble[5 ] & 0x1 )<<8 ;
713680 windspeed += nibble[6 ]<<4 ;
714681 windspeed += nibble[7 ];
715682 windspeed =(windspeed/10 )*3.6 ;
716683 doJSONData (strAddress, 0 , 23 , (char *)strWindDirection[windir], 0 , true );
717-
718684 doJSONData (strAddress, 0 , 24 , NULL , windspeed, false );
719- // Serial.print(" Wind ");
720- // Serial.print( strWindDirection[windir]);
721- // Serial.print(" ");
722- // printDouble(windspeed,1);
723- // Serial.print("KMH");
724685 break ;
725686
726687 default :
@@ -743,7 +704,13 @@ void NinjaObjects::do433(void)
743704 unsigned long long value = mySwitch.getReceivedValue ();
744705 if (value == 0 ) // unknown encoding
745706 {
707+ #ifdef V11
708+ doJSONData (" 1" , 0 , tempID, " 0" , 0 , true );
709+ #endif
710+
711+ #ifdef V12
746712 doJSONData (" 0" , 0 , tempID, " 0" , 0 , true );
713+ #endif
747714 }
748715 else
749716 {
@@ -757,17 +724,29 @@ void NinjaObjects::do433(void)
757724 else
758725 {
759726 if (mySwitch.getReceivedBitlength ()> (DATA_LEN/2 ))
727+ #ifdef V11
728+ doJSONData (" 1" , 0 , tempID, " 0" , 0 , true );
729+ #endif
730+
731+ #ifdef V12
760732 doJSONData (" 0" , 0 , tempID, " 0" , 0 , true );
733+ #endif
761734 else
762735 {
763736 dec2binWzerofill (strDATA, mySwitch.getReceivedValue (), mySwitch.getReceivedBitlength ());
737+ #ifdef V11
738+ doJSONData (" 1" , 0 , tempID, strDATA, 0 , true );
739+ #endif
740+
741+ #ifdef V12
764742 doJSONData (" 0" , 0 , tempID, strDATA, 0 , true );
743+ #endif
765744 }
766745 }
767746 }
768747 mySwitch.resetAvailable ();
769748 }
770- else
749+ // else
771750 // doJSONData("0", 0, tempID, "-1", 0, true);
772751
773752 if (Serial.available ()>0 ) doReactors ();
@@ -808,34 +787,9 @@ boolean NinjaObjects::doPort1(byte* DHT22_PORT)
808787#ifdef V11
809788 else if (tempID==11 ) // 433Mhz Receiver
810789 {
790+ if (_lastPort1ID != tempID)
791+ doJSONData (" 1" ,0 ,tempID, " -1" ,0 ,true );
811792 do433 ();
812- /*
813- if (mySwitch.available())
814- {
815- int value = mySwitch.getReceivedValue();
816- if (value == 0) // unknown encoding
817- {
818- doJSONData("1", 0, tempID, "0", 0, true);
819- }
820- else
821- {
822- // Blink Green LED to show data valid
823- blinkLED(GREEN_LED_PIN);
824- //String recvSTR = String(mySwitch.getReceivedValue(), BIN);
825- //recvSTR.toCharArray(strDATA, DATA_LEN);
826- if (mySwitch.getReceivedBitlength()> (DATA_LEN/2))
827- doJSONData("1", 0, tempID, "0", 0, true);
828- else
829- {
830- dec2binWzerofill(strDATA, mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength());
831- doJSONData("1", 0, tempID, strDATA,0, true);
832- }
833- }
834- mySwitch.resetAvailable();
835- }
836- else
837- doJSONData("1", 0, tempID, "-1", 0, true);
838- */
839793 }
840794#endif
841795 else
@@ -866,7 +820,7 @@ boolean NinjaObjects::doPort2(byte* DHT22_PORT)
866820 }
867821 else
868822 {
869- if (tempID>-1 )
823+ if (( tempID>-1 ) && (tempID != 11 ) )
870824 {
871825 if (tempID==0 )
872826 doJSONData (" 2" , 0 , tempID, NULL , getIDPinReading (ID_PIN_P2),false );
@@ -899,7 +853,7 @@ boolean NinjaObjects::doPort3(byte* DHT22_PORT)
899853 }
900854 else
901855 {
902- if (tempID>-1 )
856+ if (( tempID>-1 ) && (tempID != 11 ) )
903857 {
904858 if (tempID==0 )
905859 doJSONData (" 3" , 0 , tempID, NULL , getIDPinReading (ID_PIN_P3), false );
@@ -946,7 +900,7 @@ void NinjaObjects::sendObjects()
946900 byte DHT22_PORT=0 ;
947901
948902#ifdef V11
949- // doOnBoardAccelerometer();
903+ doOnBoardAccelerometer ();
950904#endif
951905
952906#ifdef V12
0 commit comments