Avatar for AlessioBacin

AlessioBacin

Member since Nov 2016 • Last active Jan 2017
  • 2 conversations
  • 9 comments

Most recent activity

  • in Interfacing
    Avatar for AlessioBacin

    Hi Gordon,
    thanks for your fast reply... i'll do some research and post if there is any update on this... i guess someone would be interested if possible.
    Thanks for now.

  • in Interfacing
    Avatar for AlessioBacin

    Hi,
    is there any way of sending a vcard file from an espruino microcontroller to a smartphone interfacing the microcontroller with an AT-09 with HM-10 BLE module?
    It would be very usefull for creating an ibeacon that sends proximity messages without paring devices.
    A help would be appreciated.
    THanks

    Alessio

  • in ESP8266
    Avatar for AlessioBacin

    Hi tve,
    thanks for the advices. In the next days i'll try and let you know.

  • in ESP8266
    Avatar for AlessioBacin

    Ok i connected NodeMcu with espruino IDE through wifi and then used serial1 to comunicate to sim800L.
    Comunication now is not conflicting with the only UART available but i cannot get to work AT commands on sim800...

  • in ESP8266
    Avatar for AlessioBacin

    What if i connect to nodemcu over wifi plugged to a wall power supply and i connect rx tx to sim900? does it still conflict?

  • in ESP8266
    Avatar for AlessioBacin

    Ok so in case i would like to require mqtt where it was i still can do it but the create function should be placed inside the wifi callback function.

    Ok Ollie very glad you help me.

  • in ESP8266
    Avatar for AlessioBacin

    Hi Ollie,
    thanks... now it seams working even if i don't understand why as mqtt connects only after wifi is up so mqtt object is just creating something that is been "called" on wifi up.

    Can you just tell me last thing about why i'm getting "ERROR: Prompt not detected - upload failed" everytime i was executing my previous code?

  • in ESP8266
    Avatar for AlessioBacin

    Hi Ollie,
    thanks for your reply. So this is my new code:

    var http = require('http');
    var wifi = require('Wifi');
    var mqtt = require("tinyMQTT").create("............­.",{username:"owntracks",password:".....­.........",port:1883});
    
    var server = function(ssid, password){
          wifi.connect("Newbiz",{password: "pwdinewbiz"}, function(err) {
                  if (err) throw err;
                  wifi.save();
    
                  console.log(wifi.getIP());
    
                  console.log(wifi.getDetails());
    
                  wifi.startAP("NewbizCentral",{authMode:"­wpa", password:"pwdinewbiz",channel:5},functio­n(a){console.log("AP created");});
    
                  setTimeout(function(){      
                    console.log(wifi.getAPIP());
                    http.createServer(
    
                      function (req, res) {
                                var a = url.parse(req.url, true);
                                if(req.url.length>15){
                                  var wifiSetterPageContent = "<h3>Credendiali AP settate. Staccare dalla presa il dispositivo e riattaccarlo dopo qualche secondo<h3>";
                                  res.writeHead(200, {'Content-Type': 'text/html'});
                                  res.end(wifiSetterPageContent);
                                  var pressid = req.url.replace("/setWifiCredentials/?",­ "");
                                  var UsrPwd = pressid.split("&");
                                  ssid = UsrPwd[0];
                                  password = UsrPwd[1];
                                  console.log("from onPageRequest " + ssid + " " + password);
                                  message =  message + " ssid is: "+ssid + " password is: "+ password;
                                  connectWifi(ssid, password);
                                }
                                else{
                                  var pageContent = "<h1>Newbiz s.r.l.<h1><h2>Seleziona le credenziali del tuo Access Point<h2><p>Nome Wifi</p> <input type='text' name='wifiid' id='wifiid'> <p>Password</p> <input type='text' name='passwd' id='passwd'></br></br> <button onclick='setWifiCredentials()'>Setta le credenziali e riavvia</button> <script> function setWifiCredentials(){location.href = '../setWifiCredentials/?'+document.getEl­ementById('wifiid').value+'&'+document.g­etElementById('passwd').value;} </script>";
                                  res.writeHead(200, {'Content-Type': 'text/html'});
                                  res.end(pageContent);
                                }
                      }
    
                    ).listen(8080);
    
                    setTimeout(function(){
                        var message = JSON.stringify(wifi.getIP()) + JSON.stringify(wifi.getDHCPHostname()) + JSON.stringify(wifi.getHostname());
                        mqtt.on("connected", function(){
                          mqtt.subscribe("owntracks");
                          var topic = "owntracks";
                          mqtt.publish(topic, message);
                        });
    
                        mqtt.on("message", function(msg){
                          console.log(msg.topic);
                          console.log(msg.message);
                        });
    
                        mqtt.on("published", function(){
                          console.log("message sent");
                        });
    
                        mqtt.on("disconnected", function(){
                          console.log("disconnected");
                        });
    
                        mqtt.connect();
                    }, 5000);
    
                  },5000);
          });
    };
    
    E.on("init", server);
    
    
    

    everything is perfectly working before saving...
    This is the correct and expected reponse:

    { "ip": "192.168.1.54", "netmask": "255.255.255.0", "gw":
    "192.168.1.1", "mac": "5c:cf:7f:19:e0:c7" } { "status":
    "connected", "ssid": "Newbiz", "password": "pwdinewbiz", "rssi":
    -71, "savedSsid": null } AP created { "ip": "192.168.4.1", "netmask": "255.255.255.0", "gw": "192.168.4.1", "mac":
    "5e:cf:7f:19:e0:c7" } message sent

    as soon as i save() on the console, unplug and replug usb i see this in the console:

    { "ip": "192.168.1.54", "netmask": "255.255.255.0", "gw":
    "192.168.1.1", "mac": "5c:cf:7f:19:e0:c7" } { "status":
    "connected", "ssid": "Newbiz", "password": "pwdinewbiz", "rssi":
    -71, "savedSsid": null } AP created { "ip": "192.168.4.1", "netmask": "255.255.255.0", "gw": "192.168.4.1", "mac":
    "5e:cf:7f:19:e0:c7" }

    You can notice that everything is working but not the last "message sent".
    The other strange thing that happends is that while you would think that message has not been sent(and usually on another mqtt client when message is published the client get immediately updated) if from another mqtt client i unsubscribe and subscribe again i get that message there.

    so qhat can it be??!!

Actions