Skip to content

Commit 49a833a

Browse files
0.0.2 first attempt at reportQueue
1 parent 75b568a commit 49a833a

File tree

2 files changed

+40
-6
lines changed

2 files changed

+40
-6
lines changed

Makefile

+4
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ include $(SDK_PATH)/common.mk
1616

1717
monitor:
1818
$(FILTEROUTPUT) --port $(ESPPORT) --baud $(ESPBAUD) --elf $(PROGRAM_OUT)
19+
20+
signature:
21+
$(openssl sha384 -binary -out firmware/main.bin.sig firmware/main.bin)
22+
$(printf "%08x" `cat firmware/main.bin | wc -c`| xxd -r -p >>firmware/main.bin.sig)

main.c

+36-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,29 @@ void reverse_set(homekit_value_t value) {
129129

130130
homekit_characteristic_t reversed = HOMEKIT_CHARACTERISTIC_(CUSTOM_REVERSED, 0, .setter=reverse_set, .getter=reverse_get);
131131

132-
132+
struct _report {
133+
int position;
134+
int direction;
135+
//int data4;
136+
int status;
137+
//int data6;
138+
//int data7;
139+
//int data8;
140+
int calibr;
141+
} report;
142+
143+
QueueHandle_t reportQueue = NULL;
144+
void report_track(void *pvParameters){
145+
struct _report rep;
146+
if( reportQueue == 0 ) {LOG("NO QUEUE!\n");vTaskDelete(NULL);}
147+
while(1) {
148+
if( xQueueReceive( reportQueue, (void*)&rep, (TickType_t) 100 ) ) {
149+
//do things
150+
LOG("pos=%02x,dir=%02x,sta=%02x,cal=%02x\n",rep.position,rep.direction,rep.status,rep.calibr);
151+
}
152+
//send a position request
153+
}
154+
}
133155

134156
void uart_send_output(void *pvParameters){
135157
int i;
@@ -138,9 +160,9 @@ void uart_send_output(void *pvParameters){
138160
char pause[]={0x55,0xfe,0xfe,0x03,0x03,0x38,0xe5};
139161
vTaskDelay(1000); //wait 10 seconds
140162
while(1) {
141-
LOG(" open\n");for (i=0;i<7;i++) uart_putc(1, open[i]);uart_flush_txfifo(1);vTaskDelay(500);
142-
LOG("close\n");for (i=0;i<7;i++) uart_putc(1,close[i]);uart_flush_txfifo(1);vTaskDelay(500);
143-
LOG("pause\n");for (i=0;i<7;i++) uart_putc(1,pause[i]);uart_flush_txfifo(1);vTaskDelay(500);
163+
LOG(" open\n");for (i=0;i<7;i++) uart_putc(1, open[i]);uart_flush_txfifo(1);vTaskDelay(1000);
164+
LOG("close\n");for (i=0;i<7;i++) uart_putc(1,close[i]);uart_flush_txfifo(1);vTaskDelay(1000);
165+
LOG("pause\n");for (i=0;i<7;i++) uart_putc(1,pause[i]);uart_flush_txfifo(1);vTaskDelay(1000);
144166
}
145167
}
146168

@@ -162,6 +184,13 @@ void parse(int positions) {
162184
else {
163185
for (i=3;i<positions-2;i++) LOG("%02x",buff[i]);
164186
LOG("\n");
187+
if (buff[3]==0x04 && buff[4]==0x02 && buff[5]==0x08) {
188+
report.position=buff[6];
189+
report.direction=buff[7];
190+
report.status=buff[9];
191+
report.calibr=buff[13];
192+
xQueueSend( reportQueue, (void *) &report, ( TickType_t ) 0 );
193+
}
165194
}
166195
}
167196

@@ -230,8 +259,9 @@ void motor_init() {
230259
uart_set_baud(0, 9600);
231260

232261
xTaskCreate(uart_parse_input, "parse", 256, NULL, 1, NULL);
233-
xTaskCreate(uart_send_output, "send", 256, NULL, 1, NULL);
234-
//xTaskCreate(motor_loop_task, "loop", 512, NULL, 1, NULL);
262+
reportQueue = xQueueCreate(3, sizeof(struct _report));
263+
xTaskCreate(report_track, "track", 512, NULL, 2, NULL);
264+
//xTaskCreate(uart_send_output, "send", 256, NULL, 1, NULL);
235265
}
236266

237267
homekit_value_t obstruction_get() {

0 commit comments

Comments
 (0)