@@ -47,7 +47,7 @@ void log_send(void *pvParameters){
47
47
}
48
48
}
49
49
50
- bool hold = 0 ,calibrate = 0 ,reverse = 0 , obstruction = 0 ;
50
+ bool hold = 0 ,calibrate = 0 ,reverse = 0 ;
51
51
bool changed = 0 ;
52
52
int target = 0 ; //homekit values
53
53
@@ -96,8 +96,7 @@ homekit_characteristic_t revision = HOMEKIT_CHARACTERISTIC_(FIRMWARE_REVISIO
96
96
97
97
homekit_characteristic_t state = HOMEKIT_CHARACTERISTIC_ (POSITION_STATE , 2 );
98
98
homekit_characteristic_t current = HOMEKIT_CHARACTERISTIC_ (CURRENT_POSITION , 0 );
99
-
100
-
99
+ homekit_characteristic_t obstruction = HOMEKIT_CHARACTERISTIC_ (OBSTRUCTION_DETECTED , 0 );
101
100
102
101
homekit_value_t calibrate_get () {
103
102
return HOMEKIT_BOOL (calibrate );
@@ -180,6 +179,9 @@ void report_track(void *pvParameters){
180
179
if (rep .status == 1 ){state .value .int_value = 0 ;homekit_characteristic_notify (& state ,HOMEKIT_UINT8 (state .value .int_value ));} //going min
181
180
if (rep .status == 2 ){state .value .int_value = 1 ;homekit_characteristic_notify (& state ,HOMEKIT_UINT8 (state .value .int_value ));} //going max
182
181
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
183
185
LOG ("pos=%02x,dir=%02x,sta=%02x,cal=%02x\n" ,rep .position ,rep .direction ,rep .status ,rep .calibr );
184
186
LOG ("state: %d\n" ,state .value .int_value );
185
187
}
@@ -217,6 +219,7 @@ void parse(int positions) {
217
219
if (buff [6 ]== 0xff ){
218
220
current .value .int_value = j ++ ;
219
221
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 ));
220
223
LOG ("current: %d\n" ,current .value .int_value );
221
224
}
222
225
else {
@@ -297,10 +300,6 @@ void motor_init() {
297
300
//xTaskCreate(uart_send_output, "send", 256, NULL, 1, NULL);
298
301
}
299
302
300
- homekit_value_t obstruction_get () {
301
- return HOMEKIT_BOOL (obstruction );
302
- }
303
-
304
303
homekit_value_t hold_get () {
305
304
return HOMEKIT_BOOL (hold );
306
305
}
@@ -370,10 +369,7 @@ homekit_accessory_t *accessories[] = {
370
369
.getter = hold_get ,
371
370
.setter = hold_set
372
371
),
373
- HOMEKIT_CHARACTERISTIC (
374
- OBSTRUCTION_DETECTED , false,
375
- .getter = obstruction_get ,
376
- ),
372
+ & obstruction ,
377
373
& ota_trigger ,
378
374
& calibrated ,
379
375
& reversed ,
0 commit comments