if (ret < 0)
                goto out;
 
-       /* FIXME: replace the magic numbers with proper definitions */
-       ret = wl1251_cmd_join(wl, wl->bss_type, 100, 1, false);
+       ret = wl1251_cmd_join(wl, wl->bss_type, wl->beacon_int,
+                                  wl->dtim_period, false);
        if (ret < 0)
                goto out_sleep;
 
                goto out;
 
        if (channel != wl->channel) {
-               /* FIXME: use beacon interval provided by mac80211 */
-               ret = wl1251_cmd_join(wl, wl->bss_type, 100, 1, false);
+               ret = wl1251_cmd_join(wl, wl->bss_type, wl->beacon_int,
+                                          wl->dtim_period, false);
                if (ret < 0)
                        goto out_sleep;
 
 
        if (changed & BSS_CHANGED_ASSOC) {
                if (bss_conf->assoc) {
+                       wl->beacon_int = bss_conf->beacon_int;
+                       wl->dtim_period = bss_conf->dtim_period;
+
+                       /* FIXME: call join */
+
                        wl->aid = bss_conf->aid;
 
                        ret = wl1251_build_ps_poll(wl, wl->aid);
                                if (ret < 0)
                                        goto out_sleep;
                        }
+               } else {
+                       /* use defaults when not associated */
+                       wl->beacon_int = WL1251_DEFAULT_BEACON_INT;
+                       wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD;
                }
        }
        if (changed & BSS_CHANGED_ERP_SLOT) {
                        goto out;
 
                if (wl->bss_type != BSS_TYPE_IBSS) {
-                       ret = wl1251_cmd_join(wl, wl->bss_type, 100, 5, true);
+                       ret = wl1251_cmd_join(wl, wl->bss_type,
+                                             wl->beacon_int,
+                                             wl->dtim_period, true);
                        if (ret < 0)
                                goto out_sleep;
                        wl1251_warning("Set ctsprotect failed %d", ret);
                if (ret < 0)
                        goto out;
 
-               ret = wl1251_cmd_join(wl, wl->bss_type, 100, 1, false);
+               ret = wl1251_cmd_join(wl, wl->bss_type, wl->beacon_int,
+                                     wl->dtim_period, false);
 
                if (ret < 0)
                        goto out;
        wl->psm_requested = false;
        wl->tx_queue_stopped = false;
        wl->power_level = WL1251_DEFAULT_POWER_LEVEL;
+       wl->beacon_int = WL1251_DEFAULT_BEACON_INT;
+       wl->dtim_period = WL1251_DEFAULT_DTIM_PERIOD;
 
        for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++)
                wl->tx_frames[i] = NULL;