Browse Source

remove master

Juraj Ďuďák 8 months ago
parent
commit
05d26e7490

+ 0 - 6
include/nbus_app.h

@@ -9,13 +9,7 @@
 
 #include "nbus_types.h"
 
-#if MODULE_SLAVE == 1
 #include "nbus_slave.h"
-#endif
-#if MODULE_MASTER == 1
-#include "nbus_master_module.h"
-#endif
-
 #include "nbus_cmd.h"
 
 #ifdef __cplusplus

+ 0 - 6
include/nbus_master_module.h

@@ -12,11 +12,5 @@
 #include "nbus_config.h"
 #include "nbus_types.h"
 
-#if MODULE_MASTER == 1
-
-void nbus_master_unicastToModuleGet(nBus_TypeDef *nbus);
-void nbus_master_unicastToModuleSet(nBus_TypeDef *nbus);
-
-#endif
 
 #endif /* MODULES_NBUS_INC_NBUS_MASTER_MODULE_H_ */

+ 1 - 2
include/nbus_slave.h

@@ -18,7 +18,6 @@
 void setErrorResponse(nBus_TypeDef *nbus, uint8_t code);
 // nBusCommandType_t get_request_type();
 
-#if MODULE_SLAVE == 1
 
 void nbus_slave_unicastToSensorGet(nBus_TypeDef *nbus);
 void nbus_slave_unicastToModuleGet(nBus_TypeDef *nBus);
@@ -28,6 +27,6 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nBus);
 
 void nbus_slave_broadcast(nBus_TypeDef *nBus, nBusCommandType_t request_type);
 void sensor_store_param(nBus_TypeDef *nbus, uint8_t sensor_index, uint8_t param_name);
-#endif
+
 
 #endif

+ 13 - 34
src/nbus_app.c

@@ -44,17 +44,13 @@ inline static void send_response()
 {
     if (nBus.send_response == SEND_RESPONSE)
     {
+    	nBus.hw_platform->led_on();
         nBus.tx_buffer[0] -= 1; // prvý bajt sa nepočíta
         nBus.hw_platform->uart_transmit(nBus.tx_buffer, nBus.tx_length);
+        nBus.hw_platform->led_off();
     }
-    nBus.hw_platform->led_off();
-}
 
-#if MODULE_MASTER == 1
-inline static void receive_slave_response()
-{
 }
-#endif
 
 static nBusCommandType_t get_request_type()
 {
@@ -93,34 +89,34 @@ static void process_request()
     nBus.tx_buffer[1] = nBus.rx_buffer[0]; // Module address
     nBus.tx_buffer[2] = nBus.rx_buffer[1]; // Sensor address
 
+    // paket nie je adresovany tomuto modulu
+    if (nBus.addressModule != MODULE_ADDRESS)
+    {
+        nBus.send_response = NO_RESPONSE;
+        receivePacket();
+        return;
+    }
+
     uint8_t crcC = crc8x_fast(nBus.rx_buffer, nBus.rx_length - 1);
     if (crcC != nBus.rx_buffer[nBus.rx_length - 1])
     {
         nBus.send_response = NO_RESPONSE;
+        receivePacket();
         return;
     }
 
-#if MODULE_SLAVE == 1
     // spracovanie broadcast komunikacie
     if ((request_type == BROADCAST_SPECIFIC_SENSORS || request_type == BROADCAST_GLOBAL))
     {
         nbus_slave_broadcast(&nBus, request_type);
         return;
     }
-#endif
 
-    // paket nie je adresovany tomuto modulu
-    if (nBus.addressModule != MODULE_ADDRESS)
-    {
-        nBus.send_response = NO_RESPONSE;
-        receivePacket();
-        return;
-    }
+    nBus.hw_platform->led_on();
 
     nBus.function_code.error = 0;
     nBus.tx_length = META_SIZE;
 
-#if MODULE_SLAVE == 1
     if (nBus.function_code.notReadWrite == REQUEST_GET)
     {
         if (request_type == UNICAST_TO_SENSOR)
@@ -146,18 +142,7 @@ static void process_request()
             nbus_slave_unicastToModuleSet(&nBus);
         }
     }
-#endif
 
-#if MODULE_MASTER == 1
-    if (nBus.function_code.notReadWrite == REQUEST_GET)
-    {
-        nbus_master_unicastToModuleGet(&nBus);
-    }
-    else
-    {
-        nbus_master_unicastToModuleSet(&nBus);
-    }
-#endif
     nBus.tx_buffer[3] = *(uint8_t *)&nBus.function_code;
     nBus.tx_buffer[nBus.tx_length - 1] = crc8x_fast(&nBus.tx_buffer[1], nBus.tx_length - 2);
     nBus.tx_buffer[0] = nBus.tx_length;
@@ -298,15 +283,9 @@ void nbus_stack(void)
         {
 
             process_request();
+            nBus.hw_platform->led_off();
             nBus.uart_state = UART_RX_WAIT;
-#if MODULE_SLAVE == 1
-            send_response();
-#endif
-#if MODULE_MASTER == 1
-            // test
             send_response();
-            // receive_slave_response();
-#endif
         }
 
         if (nBus.hw_platform->loop_callback != NULL)

+ 0 - 31
src/nbus_master_module.c

@@ -8,34 +8,3 @@
 #include "nbus_master_module.h"
 #include "nbus_types.h"
 
-#if MODULE_MASTER == 1
-
-inline void setErrorResponse(nBus_TypeDef *nbus, uint8_t code)
-{
-    nbus->function_code.error = 1;
-    nbus->tx_buffer[4] = code;
-    nbus->tx_length += 1;
-}
-
-void nbus_master_unicastToModuleSet(nBus_TypeDef *nbus)
-{
-}
-
-void nbus_master_unicastToModuleGet(nBus_TypeDef *nbus)
-{
-    switch (nbus->function_code.function)
-    {
-    case CMD_ECHO: {
-        for (uint8_t i = 3; i < nbus->rx_length - 1; i++)
-        {
-            nbus->tx_buffer[i + 1] = nbus->rx_buffer[i] + 1;
-        }
-        nbus->tx_length += (nbus->rx_length - 4);
-        break;
-    }
-    default: {
-        setErrorResponse(nbus, ILLEGAL_FUNCTION);
-    }
-    }
-}
-#endif

+ 0 - 3
src/nbus_slave_broadcast.c

@@ -1,7 +1,5 @@
 #include "nbus_slave.h"
 
-#if MODULE_SLAVE == 1
-
 inline void setErrorResponse(nBus_TypeDef *nbus, uint8_t code)
 {
     nbus->function_code.error = 1;
@@ -41,4 +39,3 @@ void nbus_slave_broadcast(nBus_TypeDef *nbus, nBusCommandType_t request_type)
     nbus->send_response = NO_RESPONSE;
 }
 
-#endif

+ 0 - 3
src/nbus_slave_module_unicast.c

@@ -1,5 +1,4 @@
 #include "nbus_slave.h"
-#if MODULE_SLAVE == 1
 
 void nbus_slave_unicastToModuleGet(nBus_TypeDef *nbus)
 {
@@ -305,5 +304,3 @@ void nbus_slave_unicastToModuleSet(nBus_TypeDef *nbus)
     }
     }
 }
-
-#endif

+ 0 - 4
src/nbus_slave_sensor_unicast.c

@@ -1,7 +1,5 @@
 #include "nbus_slave.h"
 
-#if MODULE_SLAVE == 1
-
 void nbus_slave_unicastToSensorGet(nBus_TypeDef *nbus)
 {
     nBus_sensorType_t sensor_type = nbus->interface->getType(nbus->rx_buffer[RX_SA]);
@@ -211,5 +209,3 @@ void sensor_store_param(nBus_TypeDef *nbus, uint8_t sensor_index, uint8_t param_
     uint32_t param_value = nbus->interface->getParam(sensor_index, param_name);
     nbus->memoryInterface->storeParam(sensor_index, param_name, param_value);
 }
-
-#endif