+static int8_t check_opp_frame(uint16_t frame, uint16_t time)
+{
+ int8_t beacon_id = -1;
+ uint16_t cksum;
+
+ /* ignore bad cksum */
+ cksum = verify_cksum(frame);
+ if (cksum == 0xFFFF)
+ goto fail;
+
+ beacon_id = frame & TSOP_OPP_BEACON_ID_MASK;
+ if (beacon_id != TSOP_OPP_BEACON_ID)
+ goto fail;
+
+ /* if motor speed is not good, skip values */
+ if (current_motor_period < MOTOR_PERIOD_MIN)
+ goto fail;
+ if (current_motor_period > MOTOR_PERIOD_MAX)
+ goto fail;
+
+ return beacon_id;
+ fail:
+ /* display if needed */
+ if (beacon_tsop.debug_frame) {
+ printf("OPP ID=%d frame=%x time=%d cksum=%x d=%d\r\n",
+ beacon_id, frame, time, cksum,
+ (frame & TSOP_OPP_FRAME_DATA_MASK) >>
+ TSOP_OPP_FRAME_DATA_SHIFT);
+ }
+ return -1;
+}
+