green-mod / bacnet-stack-rs Goto Github PK
View Code? Open in Web Editor NEW๐ฆ Rust wrapper for a famous BACnet Protocol Stack library in C
๐ฆ Rust wrapper for a famous BACnet Protocol Stack library in C
Hi can you make a BACnet server app from this? This code below doesn't work but curious if it would be hard putting something together like did with the BACnet client apps in rust? The idea would be to just make one AnalogValue point with a fake temperature sensor reading. I dont know enough on the C stack to complete it curious if you had any ideas?
#include "bacnet/basic/sys/mstimer.h"
#include "bacnet/datalink/bip.h"
#include "bacnet/basic/object/device.h"
#include "bacnet/basic/object/av.h"
#include "bacnet/datalink/bip.h"
static struct mstimer Update_Timer;
static float space_temperature = 24.5;
void Analog_Value_Init(void) {
static bool initialized = false;
if (!initialized) {
initialized = true;
Analog_Value_Create(0); // Instance 0
Analog_Value_Units_Set(0, UNITS_DEGREES_CELSIUS);
Analog_Value_Present_Value_Set(0, space_temperature, 10);
}
}
void Update_Analog_Value(void) {
mstimer_reset(&Update_Timer);
space_temperature += 0.1; // Update the temperature for simulation
Analog_Value_Present_Value_Set(0, space_temperature, 10);
}
int main(void) {
BACNET_ADDRESS src = {0}; // source address
Device_Set_Object_Instance_Number(12345); // Set device instance number
bip_init(NULL); // BACnet/IP initialization
Analog_Value_Init(); // Initialize the Analog Value object
mstimer_set(&Update_Timer, 1000); // 1 second timer
while (1) {
bip_network_layer_task(); // BACnet tasks
if (mstimer_expired(&Update_Timer)) {
Update_Analog_Value();
}
}
return 0;
}
And a Makefile???
BACNET_SRC_DIR = $(realpath ../../src)
BACNET_LIB_DIR = $(realpath ../../lib)
CC = gcc
#CFLAGS = -I$(BACNET_SRC_DIR) -std=gnu99
CFLAGS = -I$(BACNET_SRC_DIR) -std=gnu99 -Wall -Wextra
LFLAGS = -L$(BACNET_LIB_DIR) -lbacnet
TARGET = simple_server
# Include all necessary C source files
SRC = main.c \
$(BACNET_SRC_DIR)/bacnet/basic/object/av.c \
$(BACNET_SRC_DIR)/bacnet/basic/sys/mstimer.c \
$(BACNET_SRC_DIR)/bacnet/datalink/bip.c \
$(BACNET_SRC_DIR)/bacnet/basic/object/device.c \
$(BACNET_SRC_DIR)/bacnet/basic/sys/sfilename.c \
$(BACNET_SRC_DIR)/bacnet/basic/sys/sbuf.c
OBJS = $(SRC:.c=.o)
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(OBJS) $(LFLAGS) -o $@
.c.o:
$(CC) -c $(CFLAGS) $< -o $@
clean:
rm -f $(OBJS) $(TARGET)
.PHONY: all clean
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.