diff --git a/.gitignore b/.gitignore index ff1c3f5..bc98479 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ cube/build/ cube/w5500.a +cube/pubsubc.a .*.sw? *.o test diff --git a/cube/Makefile b/cube/Makefile index 0b3ee86..f1acde9 100644 --- a/cube/Makefile +++ b/cube/Makefile @@ -37,7 +37,7 @@ BUILD_DIR = build ###################################### # C sources C_SOURCES = \ -User/Src/tcpTest.c User/Src/ports.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c User/Src/utils.c User/Src/wizHelper.c hottislib/PontCoopScheduler.c \ +User/Src/mqttTest.c User/Src/tcpTest.c User/Src/ports.c User/Src/eeprom.c User/Src/frontend.c User/Src/logger.c User/Src/loopCtrl.c User/Src/main2.c User/Src/mbusComm.c User/Src/ringbuffer.c User/Src/show.c User/Src/utils.c User/Src/wizHelper.c hottislib/PontCoopScheduler.c \ libmbus/mbus/mbus-protocol.c \ Core/Src/main.c \ Core/Src/gpio.c \ @@ -126,6 +126,7 @@ C_INCLUDES = \ -IioLibrary_Driver/Ethernet \ -IioLibrary_Driver/Internet/DHCP \ -IioLibrary_Driver/Internet/MQTT \ +-Ipubsubc/src \ -ICore/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ @@ -169,14 +170,18 @@ all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET # list of objects OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o))) vpath %.c $(sort $(dir $(C_SOURCES))) -OBJECTS += $(addprefix $(BUILD_DIR)/,w5500.a) +OBJECTS += $(addprefix $(BUILD_DIR)/,pubsubc.a w5500.a) # list of ASM program objects OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) + $(BUILD_DIR)/w5500.a: (cd ioLibrary_Driver && $(MAKE) && cp w5500.a ../$(BUILD_DIR) && cd ..) +$(BUILD_DIR)/pubsubc.a: + (cd pubsubc && $(MAKE) && cp pubsubc.a ../$(BUILD_DIR) && cd ..) + $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ diff --git a/cube/Makefile-bak b/cube/Makefile-bak index 2994942..fa22faf 100644 --- a/cube/Makefile-bak +++ b/cube/Makefile-bak @@ -35,35 +35,35 @@ BUILD_DIR = build # source ###################################### # C sources -C_SOURCES = \ -Core/Src/main.c \ -Core/Src/gpio.c \ -Core/Src/adc.c \ -Core/Src/spi.c \ -Core/Src/usart.c \ -Core/Src/stm32f1xx_it.c \ -Core/Src/stm32f1xx_hal_msp.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ -Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ +C_SOURCES = \ +Core/Src/main.c \ +Core/Src/gpio.c \ +Core/Src/adc.c \ +Core/Src/spi.c \ +Core/Src/usart.c \ +Core/Src/stm32f1xx_it.c \ +Core/Src/stm32f1xx_hal_msp.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_rcc_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_gpio.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_cortex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_pwr.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_flash_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_exti.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_spi.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_tim_ex.c \ +Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ Core/Src/system_stm32f1xx.c # ASM sources -ASM_SOURCES = \ +ASM_SOURCES = \ startup_stm32f103xe.s @@ -107,8 +107,8 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI) AS_DEFS = # C defines -C_DEFS = \ --DUSE_HAL_DRIVER \ +C_DEFS = \ +-DUSE_HAL_DRIVER \ -DSTM32F103xE @@ -116,12 +116,12 @@ C_DEFS = \ AS_INCLUDES = # C includes -C_INCLUDES = \ --ICore/Inc \ --IDrivers/STM32F1xx_HAL_Driver/Inc \ --IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ --IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ --IDrivers/CMSIS/Include \ +C_INCLUDES = \ +-ICore/Inc \ +-IDrivers/STM32F1xx_HAL_Driver/Inc \ +-IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ +-IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ +-IDrivers/CMSIS/Include \ -IDrivers/CMSIS/Include @@ -164,6 +164,13 @@ vpath %.c $(sort $(dir $(C_SOURCES))) OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) +$(BUILD_DIR)/w5500.a: + (cd ioLibrary_Driver && $(MAKE) && cp w5500.a ../$(BUILD_DIR) && cd ..) + +$(BUILD_DIR)/pubsubc.a: + (cd pubsubc && $(MAKE) && cp pubsubc.a ../$(BUILD_DIR) && cd ..) + + $(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ diff --git a/cube/User/Inc/mqttTest.h b/cube/User/Inc/mqttTest.h new file mode 100644 index 0000000..11b411c --- /dev/null +++ b/cube/User/Inc/mqttTest.h @@ -0,0 +1,10 @@ +#ifndef _MQTTTEST_H_ +#define _MQTTTEST_H_ + + +void mqttTestInit(); + + +#endif // _MQTTTEST_H_ + + diff --git a/cube/User/Src/main2.c b/cube/User/Src/main2.c index 1fcc3f6..5b63d4e 100644 --- a/cube/User/Src/main2.c +++ b/cube/User/Src/main2.c @@ -18,6 +18,8 @@ #include #include #include +#include + void my_setup_1() { schInit(); @@ -191,7 +193,7 @@ void my_setup_2() { wizInit(); - tcpTestInit(); + mqttTestInit(); // frontendInit(); diff --git a/cube/User/Src/mqttTest.c b/cube/User/Src/mqttTest.c new file mode 100644 index 0000000..b4ff9f2 --- /dev/null +++ b/cube/User/Src/mqttTest.c @@ -0,0 +1,35 @@ +#include +#include + +#include +#include + +#include +#include +#include + + + +extern const uint8_t MQTT_SOCK; + +client_t client; +mqttClient_t mqttClient; + + +// typedef void (*callback_t)(char*, uint8_t*, uint16_t); +static void mqttCallback(char *topic, uint8_t *payload, uint16_t payloadLength) { + logMsg("mcb"); +} + +void mqttTestInit() { + logMsg("mti: initializing mqtt client"); + client.sockNum = MQTT_SOCK; + mqttClientInit(&mqttClient, &client, mqttCallback); + logMsg("mti: mqtt client initialized"); + + logMsg("mti: connecting to broker"); + uint8_t brokerAddress[] = { 172, 16, 2, 16 }; + bool res = mqttConnect(&mqttClient, brokerAddress, 1883, "mbv3gw-client", NULL, NULL, NULL, 0, false, NULL, false); + logMsg("mti: mqttConnect returns %d", res); +} + diff --git a/cube/User/Src/tcpTest.c b/cube/User/Src/tcpTest.c index 2977ea6..e78fbe6 100644 --- a/cube/User/Src/tcpTest.c +++ b/cube/User/Src/tcpTest.c @@ -12,7 +12,7 @@ #include -const uint8_t TCPTEST_SOCK; +extern const uint8_t TCPTEST_SOCK; uint8_t remoteAddr[] = { 172, 16, 3, 31 }; uint16_t remotePort = 5000; diff --git a/cube/pubsubc b/cube/pubsubc index 11d4a04..477f3e2 160000 --- a/cube/pubsubc +++ b/cube/pubsubc @@ -1 +1 @@ -Subproject commit 11d4a046e11b0afda3e32f46f9059b9191e9a5f3 +Subproject commit 477f3e2e3f3d4245867f3cb7ad1deba9d33f85d2