2 #include <system_def.h>
8 // OBJECT INTERFACE VARIABLES
12 uint16_t oi_humidifier;
13 uint16_t oi_cid_humidifier;
15 uint16_t oi_cid_light;
18 // OBJECT INTERFACE FUNCTIONS
19 int oi_cid_fan_wrfnc(ULOI_PARAM_coninfo void *context){
20 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
24 int oi_cid_humidifier_wrfnc(ULOI_PARAM_coninfo void *context){
25 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
29 int oi_cid_light_wrfnc(ULOI_PARAM_coninfo void *context){
30 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
34 int oi_period_wrfnc(ULOI_PARAM_coninfo void *context){
35 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
39 //*********************************************************
40 int oi_fan_wrfnc(ULOI_PARAM_coninfo void *context){
41 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
43 SET_OUT_PIN(OUT_PORT,P1_27_FAN);
44 printf("FAN PIN UP\n");
46 CLR_OUT_PIN(OUT_PORT,P1_27_FAN);
47 printf("FAN PIN DOWN\n");
52 int oi_humidifier_wrfnc(ULOI_PARAM_coninfo void *context){
53 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
54 if (oi_humidifier == 1) {
55 SET_OUT_PIN(OUT_PORT,P1_28_HUMIDIFIER);
56 printf("HUM PIN UP\n");
58 CLR_OUT_PIN(OUT_PORT,P1_28_HUMIDIFIER);
59 printf("HUM PIN DOWN\n");
64 int oi_light_wrfnc(ULOI_PARAM_coninfo void *context){
65 uloi_uint_wrfnc(ULOI_ARG_coninfo context);
67 SET_OUT_PIN(OUT_PORT,P1_29_LIGHT);
68 printf("LIGHT PIN UP\n");
70 CLR_OUT_PIN(OUT_PORT,P1_29_LIGHT);
71 printf("LIGHT PIN DOWN\n");
75 //*********************************************************
82 len = DATA_BUF_LEN + 6;
83 // if (oi_period == 1) len = len + 6;
86 buf = (uchar *) malloc(len*sizeof(uchar)); // NULL NULL NULL TEMPERATURE_CID len_data oi_temperature CID_HUM len_data oi_humidity
87 for (i=0; i<=2; i++) buf[i] = 0;
90 int2buf(&buf[3],HEART_CID);
92 int2buf(&buf[7],status_val);
95 msgsend = ul_send_query(ul_fd, ul_dyac->ul_dysa, UL_CMD_PDO, UL_BFL_NORE, (void*) buf, len);
101 void accept_SDO(void) {
102 // setting lan configuration
103 if ((ul_inepoll(ul_fd)>0) && (ul_acceptmsg(ul_fd, &msginfo)>=0)) {
104 if ((msginfo.cmd != UL_CMD_PDO) && (msginfo.sadr != 98)) {
105 if (!(msginfo.flg&(UL_BFL_PROC | UL_BFL_FAIL))) {
106 //waiting for msg from bus
107 if (uloi_process_msg(ULOI_ARG_coninfo (uloi_objdes_array_t*)&uloi_objdes_main, &msginfo)<0) {
108 //checking dynamic adresation
109 if (uldy_process_msg(ULDY_ARG_ul_dyac &msginfo)>=0){
110 printf("message recieved - UL_CMD_NCS, sadr: %i, dadr: %i, cmd: %i\n",msginfo.sadr, msginfo.dadr, msginfo.cmd);
111 printf("server addr :%i\n",ul_dyac->ul_dysa);
114 printf("problem in uldy_process_msg\n");
117 printf("ULOI message processed\n");
126 void setmyaddr(void){
127 ul_setmyadr(ul_fd,98);
132 oi_cid_humidifier=244;
138 void work_with(void){
140 PINSEL1 &= 0xFFFFB3FF;
142 // u vetsi karbicky je SET z 0 do 3.3
143 // u mensi je SET z -3.3 do 0
146 // IO0SET = P0_21_BIT;
147 // IO0SET = P0_22_BIT;
149 SET_OUT_PIN(OUT_PORT, P1_27_FAN);
150 CLR_OUT_PIN(OUT_PORT, P1_28_HUMIDIFIER);
151 SET_OUT_PIN(OUT_PORT, P1_29_LIGHT);
153 IO0SET = LED1_BIT; //vypinani LED
154 IO0CLR = LED2_BIT; //zapinani LED
156 // IO0CLR = LED1_BIT;
157 // IO0SET = LED2_BIT;