Browse Source

Adjustments. Added config-defines.

Thomas Chef 4 years ago
parent
commit
fbe045143b
5 changed files with 34 additions and 9 deletions
  1. 16 0
      main/Kconfig.projbuild
  2. 2 0
      main/Sensors/esic.c
  3. 11 6
      main/Sensors/nexa.c
  4. 2 1
      main/receiver.c
  5. 3 2
      main/udp_client.c

+ 16 - 0
main/Kconfig.projbuild

@@ -1,5 +1,9 @@
 menu "WIFI_433_Transceiver Application Configuration"
 
+    config BACK_END_SERVER_IP_ADDRESS
+        string "Back-end server IP Address"
+        default "192.168.1.110"
+
     config ESP_WIFI_SSID
         string "WiFi SSID"
         default "Hemnet3"
@@ -12,4 +16,16 @@ menu "WIFI_433_Transceiver Application Configuration"
         help
             WiFi password (WPA or WPA2) to use.
 
+    config UNIT_ID
+        int "Unit ID"
+        default 1
+        help
+            Units ID. First transceiver is 1, the second one is 2 etc. Translates to 'B', 'C' etc.
+
+    config UDP_PORT_NO
+        int "UDP Port number"
+        default 53000
+        help
+            The UDP Port number to listen on.
+
 endmenu

+ 2 - 0
main/Sensors/esic.c

@@ -221,6 +221,8 @@ RES:    0000 0001 00 110 0000000 000000000000000 0  = 00000001001100000000000000
 					data >>= 1;
 				}
 				if( even % 2 != 0 ) {
+					temp3_x_data = 0;
+					printf("Wrong parity\n");
 					return -1;
 				}
 				// A correct code has been received

+ 11 - 6
main/Sensors/nexa.c

@@ -81,7 +81,9 @@ static int rx_decode(uint32_t width) {
         
 	switch (rx_state) {
         case UNKNOWN: // Start of frame
-            if ( 2240 <= width && width <= 3540 ) {
+            if ( 2240 <= width && width <= 3540 ) { // Hallway-button: 2760
+                //DEBUG_WIDTH_FUNC();
+
                 rx_state = T0;
             }
             else {
@@ -91,7 +93,8 @@ static int rx_decode(uint32_t width) {
 
         case T0: // First half of pulse
 
-            if ( 155 <= width && width <= 305 ) {
+            if ( 155 <= width && width <= 305 ) {   // Hallway-button: 230-250
+
                 rx_state = T1;
 
             }
@@ -106,10 +109,12 @@ static int rx_decode(uint32_t width) {
             break;
 
         case T1:
-            if ( 240 <= width && width <= 440 ) {
+            if ( 200 <= width && width <= 440 ) {   // Hallway-button: 250-270
+
                 addBit(0);
-            } else if ( (1410-300) <= width && width <= (1410+300) ) {
-                DEBUG_WIDTH_FUNC();
+            }
+            else if ( 950 <= width && width <= 1700 ) {  // Hallway-button: 1250-1270
+                
 
                 addBit(1);
             } else if( rx_numBits == 64 ) {	// end of frame
@@ -153,7 +158,7 @@ int64_t nextPulseNEXA(uint32_t width)
         now = millis();
         if( debug_data.max > debug_data_tot.max ) debug_data_tot.max = debug_data.max;
         if( debug_data.min < debug_data_tot.min ) debug_data_tot.min = debug_data.min;
-        //printf("OREGON DEbug min,max:%u %u\n",debug_data_tot.min,debug_data_tot.max);
+        printf("NEXA Debug min,max:%u %u\n",debug_data_tot.min,debug_data_tot.max);
 
         if( sensor_data != previous_data || (now > (old_time+1000)) ) {
             previous_data = sensor_data;

+ 2 - 1
main/receiver.c

@@ -104,6 +104,7 @@ void receiverTask(void *pvParameter)
                 // RR2A1904CE 0000 601600 70 = 001.660          0000    001660
                 // RR2A1904CE 2001 702000 60 = 002.070 = 0,41   0120    002070
                 // RR2A1904CE 0001 902400 A0 = 002.490 = 0,42           002490
+                // RR2A1904CE 0000 906600 F0 = 006.690 = 6.69 = 109,62903 cm2
                 // Sequence:       563412  
                 // 1 cubic mm of water = 0,001 gram
                 // 7 grams of water = 7000 mm2
@@ -119,7 +120,7 @@ void receiverTask(void *pvParameter)
                               0.01 * (ch_data_p[0+12]-'0') +
                              0.001 * (ch_data_p[1+12]-'0');
 
-                total = (total * 16387) / 1000;
+                total = (total * 16387) / 1000; // Convert to cubic centimeters
 
                 char ch_data[21];
                 strncpy(ch_data,ch_data_p, sizeof(ch_data));

+ 3 - 2
main/udp_client.c

@@ -1,5 +1,6 @@
 #include <string.h>
 #include <sys/param.h>
+#include "sdkconfig.h"
 #include "freertos/FreeRTOS.h"
 #include "freertos/task.h"
 #include "freertos/event_groups.h"
@@ -27,8 +28,8 @@
 
 #ifdef WIFI_ENABLED
 
-#define HOST_IP_ADDR "192.168.1.110"
-#define PORT 53000
+#define HOST_IP_ADDR CONFIG_BACK_END_SERVER_IP_ADDRESS
+#define PORT CONFIG_UDP_PORT_NO
 
 static QueueHandle_t udpTxQueue = NULL; // Queue for transmitting UDP-Data to back-end server