- name: Back up original e.g. OS-provided firmware (for RPi internal WiFi)
  copy:
    src: "/lib/firmware/brcm/{{ item }}"
    dest: "/lib/firmware/brcm/{{ item }}.orig"
  with_items:
    - brcmfmac43430-sdio.bin
    - brcmfmac43455-sdio.bin
    - brcmfmac43455-sdio.clm_blob

- name: Download high-capacity older firmware (for RPi internal WiFi, per https://github.com/iiab/iiab/issues/823#issuecomment-662285202)
  get_url:
    url: "{{ item.url }}"
    dest: "{{ item.dest }}"
  with_items:
    - { url: 'http://d.iiab.io/packages/brcmfmac43430-sdio.bin_2018-09-11_7.45.98.65', dest: '/lib/firmware/brcm/brcmfmac43430-sdio.bin.iiab' }
    - { url: 'http://d.iiab.io/packages/brcmfmac43430-sdio.clm_blob_2018-09-11_7.45.98.65', dest: '/lib/firmware/brcm/brcmfmac43430-sdio.clm_blob.iiab' }
    - { url: 'http://d.iiab.io/packages/brcmfmac43455-sdio.bin_2015-03-01_7.45.18.0_ub19.10.1', dest: '/lib/firmware/brcm/brcmfmac43455-sdio.bin.iiab' }
    - { url: 'http://d.iiab.io/packages/brcmfmac43455-sdio.clm_blob_2018-02-26_rpi', dest: '/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob.iiab' }


# RECORD firmware AS DOWNLOADED

- name: "Set 'firmware_downloaded: True'"
  set_fact:
    firmware_downloaded: True

- name: "Add 'firmware_downloaded: True' to {{ iiab_state_file }}"
  lineinfile:
    path: "{{ iiab_state_file }}"    # /etc/iiab/iiab_state.yml
    regexp: '^firmware_downloaded'
    line: 'firmware_downloaded: True'

# SEE ALSO firmware_installed in install.yml
