10 gatewayRequestInterval = 6 * time.Second
11 gatewayExchangeTimeout = 5 * time.Second
19 func (g *gateway) status(ctx context.Context) ([]State, error) {
22 return nil, fmt.Errorf("wait for status slot: %w", err)
25 ctx, cancel := context.WithTimeout(ctx, gatewayExchangeTimeout)
28 states, err := g.client.Status(ctx)
30 return nil, fmt.Errorf("read gateway status: %w", err)
36 func (g *gateway) action(ctx context.Context, mac string, action Action) (State, error) {
39 return State{}, fmt.Errorf("wait for action slot: %w", err)
42 ctx, cancel := context.WithTimeout(ctx, gatewayExchangeTimeout)
45 state, err := g.client.Action(ctx, mac, action)
47 return State{}, fmt.Errorf("exchange gateway action: %w", err)
53 func (g *gateway) wait(ctx context.Context) error {
59 delay := time.Until(g.nextStart)
61 timer := time.NewTimer(delay)
76 g.nextStart = time.Now().Add(gatewayRequestInterval)