You are reading a single comment by @favo and its replies. Click here to read the full conversation.
  • @allObjects its pretty easy, the documentation provided great examples, its just this:

    var wlan = require("CC3000").connect();
    if ( wlan ) {
      wlan.connect( "<network id>", "<network password>", function (s) {
      console.log("connect callback");
      if ( s == "dhcp" ) {
        LED3.write(1);
        console.log(wlan.getIP());
        }
      });
    }
    

    I've put a little longer test that also writes a logfile on a github gist: https://gist.github.com/ifavo/d3cc923dca­4c94526f35

    The connect() call on the required module takes a little while and freezes the the espurino for some seconds. It prints a timeout error if the wiring is wrong and returns a working wlan object only when everything is good.

    The wlan.connect() needs network id and password to identify on your wpa2 network. From the network code I understand that only WPA2 and unprotected (no password) networks are currently supported. If you are using WEP you may need to re-configure your router.

    And well, the callback is called multiple times (whenver the connection state changes) and only if its parameter is String("dhcp"), you'll have your connection. When it was working, I had multiple calls of it with no arguments provided, so you'll really want to check this.

    You can also use wlan.setIP() to set your static address like this:

    wlan.setIP({
    	ip: "192.168.176.63",
    	subnet: "255.255.255.0",
    	gateway: "192.168.178.1",
    	dns: "192.168.178.1"
    });
    
About

Avatar for favo @favo started