I had this issue, it wasn't showing a solution here, so I registered to provide my fix.
I used Brackets (http://brackets.io/) NOT TextEdit, you need to do this because Terminal doesn't show you your commands when you type them in.
Type the command for setting the modem to use wireless network
M587 S"Your-WIFI-SSID" P"your-password"
Using Brackets app prevents your Mac using smart quotes...
Don't forget after you do this, to go into your config file and switch from using Access mode to WiFi mode. Note the Enable WiFi doesn't have the semi colon ;
; Configure Connection - ENABLE ONLY ONE OF THE BELOW THREE
M552 S1 ; Enable Wifi Network
;M552 S2 ; Enable Access Point Mode
;M552 S1 P192.168.2.14 ; Enable Ethernet - Change IP Address to suit