@@ -37,20 +37,21 @@ const char strWindDirection[16][4] =
3737 " W" , " WNW" , " NW" , " NNW"
3838};
3939
40+ /*
4041struct __freelist
4142{
4243 size_t sz;
4344 struct __freelist *nx;
4445};
45-
46+ */
4647
4748// Variables need to be moved to private or public part of the object - TODO
48- uint16_t biggest;
49+ // uint16_t biggest;
4950NinjaObjects nOBJECTS;
5051char serInStr[recvLEN]; // array to hold the incoming serial string bytes
5152
52- extern char * const __brkval;
53- extern struct __freelist *__flp;
53+ // extern char * const __brkval;
54+ // extern struct __freelist *__flp;
5455
5556char strGUID[GUID_LEN];
5657int intVID=0 ;
@@ -160,6 +161,8 @@ void dec2binWzerofill(char* bin, unsigned long long Dec, unsigned int bitLength)
160161 return ;
161162}
162163
164+
165+ /*
163166// given a PROGMEM string, use Serial.print() to send it out
164167// this is needed to save precious memory
165168//thanks to todbot for this http://todbot.com/blog/category/programming/
@@ -175,7 +178,9 @@ void printProgStr(const prog_char* str) {
175178 str++;
176179 }
177180}
181+ */
178182
183+ /*
179184uint16_t freeMem(uint16_t *biggest)
180185{
181186 char *brkval;
@@ -211,6 +216,7 @@ void freeMem(char* message)
211216 Serial.print(":\t");
212217 Serial.println(freeMem(&biggest));
213218}
219+ */
214220
215221
216222// read a string from the serial and store it in an array
@@ -589,7 +595,7 @@ void NinjaObjects::doJSONError(int errorCode)
589595 aJsonObject* root = aJson.createObject ();
590596 if (root == NULL )
591597 {
592- Serial.println (" error root" );
598+ // Serial.println("error root");
593599 return ;
594600 }
595601
@@ -615,7 +621,7 @@ void NinjaObjects::doJSONResponse()
615621 aJsonObject* root = aJson.createObject ();
616622 if (root == NULL )
617623 {
618- Serial.println (" error root" );
624+ // Serial.println("error root");
619625 return ;
620626 }
621627
@@ -653,7 +659,7 @@ void NinjaObjects::doJSONData(char * strGUID, int intVID, int intDID, char * str
653659 aJsonObject* root = aJson.createObject ();
654660 if (root == NULL )
655661 {
656- Serial.println (" error root" );
662+ // Serial.println("error root");
657663 return ;
658664 }
659665
@@ -794,6 +800,37 @@ void NinjaObjects::doOnBoardAccelerometer()
794800}
795801#endif
796802
803+ void NinjaObjects::doWT450 (unsigned long long value)
804+ {
805+ char strAddress[5 ];
806+ unsigned long data;
807+ int house=0 ;
808+ byte station=0 ;
809+ int humidity=0 ;
810+ double temperature=0 ;
811+ double tempdecimal=0 ;
812+ byte tempfraction=0 ;
813+
814+ data=(unsigned long )value;
815+
816+ house=(data>>28 ) & (0x0f );
817+ station=((data>>26 ) & (0x03 ))+1 ;
818+ humidity=(data>>16 )&(0xff );
819+ temperature=((data>>8 ) & (0xff ))-50 ;
820+ tempfraction=(data>>4 ) & (0x0f );
821+
822+ tempdecimal=((tempfraction>>3 & 1 ) * 0.5 ) + ((tempfraction>>2 & 1 ) * 0.25 ) + ((tempfraction>>1 & 1 ) * 0.125 ) + ((tempfraction & 1 ) * 0.0625 );
823+ temperature=temperature+tempdecimal;
824+ temperature=(int )(temperature*10 );
825+ temperature=temperature/10 ;
826+
827+ sprintf (strAddress," %02d%02d" , house, station);
828+
829+ doJSONData (strAddress, 0 , 30 , NULL , humidity, false ,0 );
830+ doJSONData (strAddress, 0 , 31 , NULL , temperature, false ,0 );
831+
832+ }
833+
797834void NinjaObjects::doLacrosseTX3 (unsigned long long tx3value)
798835{
799836 byte nibble[10 ];
@@ -904,7 +941,7 @@ void NinjaObjects::do433(void)
904941
905942 mySwitch.enableReceive (RX433_INT);
906943
907- if (mySwitch.available ())
944+ if (mySwitch.available () && (mySwitch. getReceivedProtocol ()> 0 && mySwitch. getReceivedProtocol ()< 6 ))
908945 {
909946 unsigned long long value = mySwitch.getReceivedValue ();
910947 if (value == 0 ) // unknown encoding
@@ -932,6 +969,8 @@ void NinjaObjects::do433(void)
932969 doLacrosseTX3 (value);
933970 else if (mySwitch.getReceivedProtocol ()==4 )
934971 doLacrosseWS2355 (value);
972+ else if (mySwitch.getReceivedProtocol ()==5 )
973+ doWT450 (value);
935974 else
936975 {
937976 if (mySwitch.getReceivedBitlength ()> (DATA_LEN/2 ))
@@ -1196,6 +1235,7 @@ boolean NinjaObjects::doPort3(byte* DHT22_PORT)
11961235 return IsDHT22;
11971236}
11981237
1238+
11991239void NinjaObjects::doDHT22 (byte port)
12001240{
12011241 int intTemperature;
0 commit comments