' SPDX-License-Identifier: BSD-2-Clause-Patent
' SPDX-FileCopyrightText: 2020 the prplMesh contributors (see AUTHORS.md)
' This code is subject to the terms of the BSD+Patent license.
' See LICENSE file for more details.

' from backhaul_fsm_main

ENABLED --> INIT_HAL : Wireless

' from backhaul_fsm_wireless

INIT_HAL --> WPA_ATTACH
WPA_ATTACH --> WAIT_WPS

INITIATE_SCAN --> WIRELESS_CONFIG_4ADDR_MODE
INITIATE_SCAN --> WAIT_FOR_SCAN_RESULTS
WAIT_FOR_SCAN_RESULTS --> INITIATE_SCAN
WIRELESS_CONFIG_4ADDR_MODE --> WIRELESS_ASSOCIATE_4ADDR
WIRELESS_ASSOCIATE_4ADDR --> INITIATE_SCAN
WIRELESS_ASSOCIATE_4ADDR --> WIRELESS_ASSOCIATE_4ADDR_WAIT
WIRELESS_ASSOCIATE_4ADDR_WAIT --> WIRELESS_ASSOCIATE_4ADDR
WIRELESS_ASSOCIATE_4ADDR_WAIT --> INITIATE_SCAN
WIRELESS_WAIT_FOR_RECONNECT --> INITIATE_SCAN

' from hal_event_handler

WAIT_WPS --> MASTER_DISCOVERY : "Connected" event
WIRELESS_ASSOCIATE_4ADDR_WAIT --> WIRELESS_CONFIG_4ADDR_MODE : "Connected" event
WIRELESS_ASSOCIATE_4ADDR_WAIT --> MASTER_DISCOVERY : "Connected" event
WIRELESS_WAIT_FOR_RECONNECT --> CONNECT_TO_MASTER : "Connected" event if both local gateway and controller
WIRELESS_WAIT_FOR_RECONNECT --> OPERATIONAL : "Connected" event

OPERATIONAL --> WIRELESS_WAIT_FOR_RECONNECT : "Disconnected" event
CONNECTED --> WIRELESS_WAIT_FOR_RECONNECT : "Disconnected" event
WIRELESS_ASSOCIATE_4ADDR_WAIT --> INITIATE_SCAN : "Disconnected" event

WAIT_FOR_SCAN_RESULTS --> INITIATE_SCAN : "ScanResults" event
WAIT_FOR_SCAN_RESULTS --> WIRELESS_CONFIG_4ADDR_MODE : "ScanResults" event
