Skip to content

Commit e8268dd

Browse files
0.0.5 obstruction test
1 parent 712bf90 commit e8268dd

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

main.c

+7-11
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ void log_send(void *pvParameters){
4747
}
4848
}
4949

50-
bool hold=0,calibrate=0,reverse=0,obstruction=0;
50+
bool hold=0,calibrate=0,reverse=0;
5151
bool changed=0;
5252
int target=0; //homekit values
5353

@@ -96,8 +96,7 @@ homekit_characteristic_t revision = HOMEKIT_CHARACTERISTIC_(FIRMWARE_REVISIO
9696

9797
homekit_characteristic_t state = HOMEKIT_CHARACTERISTIC_(POSITION_STATE, 2);
9898
homekit_characteristic_t current = HOMEKIT_CHARACTERISTIC_(CURRENT_POSITION, 0);
99-
100-
99+
homekit_characteristic_t obstruction = HOMEKIT_CHARACTERISTIC_(OBSTRUCTION_DETECTED, 0);
101100

102101
homekit_value_t calibrate_get() {
103102
return HOMEKIT_BOOL(calibrate);
@@ -180,6 +179,9 @@ void report_track(void *pvParameters){
180179
if (rep.status==1){state.value.int_value=0;homekit_characteristic_notify(&state,HOMEKIT_UINT8(state.value.int_value));} //going min
181180
if (rep.status==2){state.value.int_value=1;homekit_characteristic_notify(&state,HOMEKIT_UINT8(state.value.int_value));} //going max
182181
if (rep.status==0){state.value.int_value=2;homekit_characteristic_notify(&state,HOMEKIT_UINT8(state.value.int_value));timer=1500;} //stopped
182+
// if (rep.status==4){state.value.int_value=2;homekit_characteristic_notify(&state,HOMEKIT_UINT8(state.value.int_value));
183+
// obstruction.value.bool_value=1;homekit_characteristic_notify(&obstruction,HOMEKIT_UINT8(obstruction.value.int_value));
184+
// timer=1500;} //obstructed
183185
LOG("pos=%02x,dir=%02x,sta=%02x,cal=%02x\n",rep.position,rep.direction,rep.status,rep.calibr);
184186
LOG("state: %d\n",state.value.int_value);
185187
}
@@ -217,6 +219,7 @@ void parse(int positions) {
217219
if (buff[6]==0xff){
218220
current.value.int_value=j++;
219221
homekit_characteristic_notify(&current,HOMEKIT_UINT8(current.value.int_value));
222+
if (j==3) obstruction.value.bool_value=1;homekit_characteristic_notify(&obstruction,HOMEKIT_UINT8(obstruction.value.int_value));
220223
LOG("current: %d\n",current.value.int_value);
221224
}
222225
else {
@@ -297,10 +300,6 @@ void motor_init() {
297300
//xTaskCreate(uart_send_output, "send", 256, NULL, 1, NULL);
298301
}
299302

300-
homekit_value_t obstruction_get() {
301-
return HOMEKIT_BOOL(obstruction);
302-
}
303-
304303
homekit_value_t hold_get() {
305304
return HOMEKIT_BOOL(hold);
306305
}
@@ -370,10 +369,7 @@ homekit_accessory_t *accessories[] = {
370369
.getter=hold_get,
371370
.setter=hold_set
372371
),
373-
HOMEKIT_CHARACTERISTIC(
374-
OBSTRUCTION_DETECTED, false,
375-
.getter=obstruction_get,
376-
),
372+
&obstruction,
377373
&ota_trigger,
378374
&calibrated,
379375
&reversed,

0 commit comments

Comments
 (0)