PushingBox offline? or router error?

Hello, i used for a couple of months speed port w701v router and spark core with my code:


// Oma_02 // Wird Pin_D0 "HIGH" dann wird eine  push_Nachricht gesendet. Version 1.1 Marc Rudorfer
// Mit 433Mhz anbindung an Wetterstation (Basisstation 1). Und deren Auswertung zu Temperatur und Regen.

 int incomingByte;      



 const char * DEVID1 = "vF1F2377B7C07D1C";                              // "bei PushingBox.com Scenario code erstellen und hier einfügen" (Oma_versucht_aufzustehen).
 const char * DEVID2 = "vCF39F9B1E79B3FA";                              // "bei PushingBox.com Scenario code erstellen und hier einfügen" (Es regnet).
 const char * DEVID3 = "v4AF3168D1527B8F";                              // "bei PushingBox.com Scenario code erstellen und hier einfügen" (Temperatur mehr als 30,00 Grad).

 
 
 
 const int buttonPin = D0;                                              //  Pin an dem der Button angeschlossen ist. Pin über 4,7kOhm auf GND. pin -> auf 3,3v wechselt.
                                                                        //  Wird über Relais gesteuert. 
 boolean DEBUG = true;

 int LED = D7;                                                          //  LED zeigt Status an. (nachricht gesendet oder nicht. Led blau Pin_"D7").
 const char * serverName = "api.pushingbox.com";                        //  PushingBox API URL

 int buttonState = 0;                                                   //  Variable zu lesen des Pin_Status.

 TCPClient client;
 

 void setup() {
   
    Serial1.begin(9600);

    pinMode(LED, OUTPUT);                                               // LED als Output festlegen.
    
    pinMode(buttonPin, INPUT);                                          // buttonPin als Eingang festlegen.

    
    delay(1000);                                                        // Pause (1 Sekunde).

    
    }

 void loop() {

 buttonState = digitalRead(buttonPin);                                  // Pin Status lesen.

  if (buttonState == HIGH) {
      
                      sendToPushingBox(DEVID1);                         // auslösen des oben declarierten ersten Scenarios. 


    delay(60000);                                                       // Pause um Fehlarlarme zu vermeiden.
      
  }
  
  else {
      
      
   }
   
   if (Serial1.available() > 0) {

    incomingByte = Serial1.read();

     if (incomingByte == 'R') {
         
         sendToPushingBox(DEVID2);
         
         delay(60000);
         
         
        
    } 
    
    
     if (incomingByte == 'T') {
         
         sendToPushingBox(DEVID3);
         
         delay(60000);
        
    } 
              
   }         
         
 }


 void sendToPushingBox(const char * devid) {
   
   
    digitalWrite(LED, HIGH);                                             //  LED einschalten
    

    client.stop();
    
    if(DEBUG){
  }
    if (client.connect(serverName, 80)) {
        
    if(DEBUG){
  }
  
    client.print("GET /pushingbox?devid=");
    client.print(devid);
    client.println(" HTTP/1.1");
    client.print("Host: ");
    client.println(serverName);
    client.println("User-Agent: Spark");
    client.println();
    client.flush();
    
    if(DEBUG) {
      
       
        }
        
        digitalWrite(LED, LOW);                                          // LED ausschalten.
        
    } else {
      
        digitalWrite(LED, HIGH);                                         // LED einschalten, falls LED dauerhaft an ist war die letzte Verbindung fehlerhaft!
        
        if(DEBUG){
      }
    }
  }

Today i bought a new fritzbox 3272 and now i have one problem :

If pin D0 changes to high signal , the blue led light changes from off to on solid state.

And no push message is send…

i can’t find the error? because with the speed port router all works fine.

can anybody help me?

regards from germany :wink:

Seems like no one has answered this yet…

I’m not really familiar (or no idea about PushingBox :p) but what i would do it so revert to the old speed port w701v router and test things out.

Chances are…the router should not be causing the issue.

Let us know how it turns out?

I have seen a few times where TCPclient DNS lookup fails, could you ping pushingbox from your computer and try connecting to the IP instead of the Host name?

Good discussion here:

1 Like

Thank you all :wink:

I don’t know why a router change from speed port w701v to fritzbox 3272 with the same settings can make so much trouble but now all works fine :wink:

i added some lines in my code for use with the fritzbox router:

byte serverIP[] = {213, 186, 33, 19 };

and

if (client.connect(serverIP, 80)) {

thats work fine!

Great forum! Thank you all :wink:

regards from germany

Marc Rudorfer

Glad you got it working, seems to be a fairly common problem at the moment!

To me that fix sounds like a bit of a work around, that will work until pushingbox’s IP address changes, then you will have to find the new one and re-flash to update it again.

@bko whats your thoughts on this, seems to be a reoccurring issue with the DNS lookup. I would suggest the DNS library again, but like you mention it shouldn’t be needed.

1 Like

Hi @MarcGermany and @Hootie81

Glad you got it working too! The fact that you had to go a numeric IP address indicates that DNS is not working on your core and could cause other problems. Normally your DNS host is your router and it gets configured by asking the upstream connection or by manual configuration.

My cores work with my routers for DNS–that has never been a problem for me.

I think @Hootie81 DNS implementation is great! But should be used when you know you have DNS problem on other hosts on the same network. For most users it should not be needed and I would try to debug the DNS issue first.

I posted a little piece of code in another thread that shows you how to read what your core thinks it DNS host is. Normally this is the same as the gateway and is your router.

    IPAddress dnshost(ip_config.aucDNSServer[3], 
                      ip_config.aucDNSServer[2], 
                      ip_config.aucDNSServer[1], 
                      ip_config.aucDNSServer[0]);
    Serial.print(dnshost);
1 Like

I put the code in and got following. It does not sound correct.

76.83.0.0

1 Like

My test code is like this

    getIPfromName("www.google.com");            // TESTING

void getIPfromName(char *hostname)
{
uint32_t ip_addr = 0;

unsigned long tic = millis();
int32_t retval = gethostbyname(hostname, strlen(hostname), &ip_addr);
unsigned long toc = millis();
IPAddress resolvedIP(BYTE_N(ip_addr, 3), BYTE_N(ip_addr, 2), BYTE_N(ip_addr, 1), BYTE_N(ip_addr, 0));
IPAddress dnshost(ip_config.aucDNSServer[3], ip_config.aucDNSServer[2], 
                  ip_config.aucDNSServer[1], ip_config.aucDNSServer[0]);
Serial.println(" ");
Serial.println(hostname);       // Host name
Serial.println(dnshost);        // DNS host
Serial.println(resolvedIP);     // IP
Serial.println(retval);
Serial.println(toc-tic);
Serial.println(" ");

}

The result of the print is

www.google.com
76.83.0.0
0.0.0.0
-85
901

Just a note - I’ve been using PushingBox all week/weekend with no issues and just the standard web address…

const char * serverName = "api.pushingbox.com";   // PushingBox API URL

Finally, I had integrated the code from @Hootie81 to isolate issue.
I got the DNS address from my router.

const char serverName ="api.pushingbox.com";
IPAddress dnsServerIP(64,71,255,204);
IPAddress remote_addr;
DNSClient dns;

start = millis();
dns.begin(dnsServerIP);
dns.getHostByName(serverName, remote_addr);
end   = millis();
Serial.print("Time spent : ");
Serial.println(end-start);
Serial.println(remote_addr);

Time spent : 166
213.186.33.19

I think this result indicate my router and ISP DNS service "should be" fine. So, I suppose something else is wrong causing the internal DNS service not working.
btw, during my test, not just "pushingbox.com" but any Host name I tried will failed.

Is there a way to debug what "Host name" actually get into low level call of TCPClient.connect() ?

Hi @Dilbert

TCPClient.connect() just calls gethostbyname like you are. The problem is that your are getting 76.83.0.0 as your DNS address. This is not a valid host address and DNS doesn’t work.

This thread at Adafruit has the exact same problem–they decide to replace the board so sending email to spark to get a replacement started (ping @Dave so he can forward to the right person):

https://forums.adafruit.com/viewtopic.php?f=22&t=55574

Just curious: is your broadband connection via Road Runner? They own that IP range. Would your external internet address start with 76.83.xx.xx? You can find out by visiting many sites like whatismyip.com.

1 Like

the DNS lookup that I ported uses the DNS server that you specify not the ones in the router or isp dns, it was pointed to google at 8.8.8.8

1 Like

Yes, I tried on both DNS server to make sure not a problem with my ISP service or router.

No, I am using Rogers and my IP start with 98.

In the adafruit forum, its indicate possible issue in EEPROM of CC3000, I tried factory reset the board twice but still same result (wrong DNS server). Does this reset CC3000 ?

what happens if you connect the core to your phones hotspot and set the SSID and password with a serial terminal or the CLI? it should have a different DNS server to your home one

The factory reset process won’t re-patch the cc3000 quite yet, you can re-patch it by putting your core into DFU mode (blinking yellow), by holding both buttons, and releasing RESET, keep holding mode until the core blinks yellow. Then run

spark flash --usb cc3000

Thanks!
David

Finally, after 3 retry to re-flash cc3000 and my FW. The system is back to normal (like 1 week before). There are still a few unknown

  1. After I call spark flash --usb cc3000, the core still in DFU mode, I need to flash my FW in order to back to listening mode (flashing blue)
  2. Connect with Tinker Apps did not work at 1 try. After I try to connect, it back to DFU mode again. Had repeat the code loading and WiFi connect 3 times before it works again.
  3. After 3 try, it finally connect. But the WiFi seems very unstable, it keeps flashing Blue and it stables for a while. Then flashing again. It finally stable after 10 minutes.
  4. Still do not know what had trigger this SW bug to cause the CC3000 into reading wrong DNS number.

I had print the WiFi info which the signal is very good

WIFI RSSI : -69
DNS : 192.168.0.1 which is same as Gateway number
time taken for DNS : 205ms (which is not bad)

1 Like

Wow this is interesting!

I think the procedure is to flash cc3000 then flash tinker… sorry should have mentioned that!

Im now finding some info on the ti forums, relating to DHCP and the DNS being messed up… stay tuned!

I had reserved the DHCP in router for the Spark Core last week, may be that’s what it all get started.
By reserving it in the router, I thought it is better is a way. Since I notice from router DHCP list, it always expire in 4 hours.
I do notice that the Spark will be flashing blue once a while. May be this is why.

May be there is a bug that I could not do this ??

I dont think that should make a difference though because the spark is still in DHCP and the router just assigns the same IP each time…

Its seems the trick is to set static IP, mask and Gateway to 0,0,0,0 this then allows the dns to fix itself… last post here

http://forums.adafruit.com/viewtopic.php?f=31&t=47004

and another similar one where new DNS gets ignored

https://forums.adafruit.com/viewtopic.php?f=31&t=56693