Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - MitchLampert

Pages: 1
1
I would like to connect a local address like this: http://192.168.1.4:8080/GetValue.php?key=XYZ
Note that: I am calling the IP address directly, using a nonstandard port (8080), and there are parameters after the web page name.

I believe I should be able to do this with the following code. However it doesn't seem to be reliable:

Code: [Select]
  ip = 3232235780; //192.168.1.4 converted to int.
 
  Adafruit_CC3000_Client www = cc3000.connectTCP(ip, 8080);
  if (www.connected()) {
    www.fastrprint(F("GET "));
    www.fastrprint("/GetValue.php?key=XYZ");
    www.fastrprint(F(" HTTP/1.1\r\n"));
    www.fastrprint(F("Host: ")); www.fastrprint("192.168.1.4"); www.fastrprint(F("\r\n"));
    www.fastrprint(F("\r\n"));
    www.println();
    Serial.println(F("Connected!"));   
  } else {
    Serial.println(F("Connection failed"));   
    return;
  }


  Serial.println(F("-------------------------------------"));
 
  /* Read data until either the connection is closed, or the idle timeout is reached. */
  unsigned long lastRead = millis();
  while (www.connected() && (millis() - lastRead < IDLE_TIMEOUT_MS)) {
    while (www.available()) {
      char c = www.read();
      Serial.print(c);
      lastRead = millis();
    }
  }
  Serial.println("");Serial.println("");
  www.close();

Whenever I call the address at the top of the post in a browser, it always works reliably. But, the code above seems to load the wrong content most of the time. And, weirdly, might start working properly after a while.

Any ideas on what's going on, and what to do about that?

2
I am trying to compile the Smart Watch example code for Android, from this project:
https://tinycircuits.hackster.io/tbatey_tiny-circuits/tinyscreen-smartwatch-785938

I also added these to the libraries:
Tiny Screen: https://github.com/TinyCircuits/TinyCircuits-TinyScreen_Lib
Time, which I found referenced in another thread: https://github.com/PaulStoffregen/Time

But, I get this compile error:
variable 'setup_msgs' must be const in order to be put into read-only section by means of '__attribute__((progmem))'

Points to this line in UART.h:
static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;

If I make that line const, I get this error, instead:
invalid conversion from 'const hal_aci_data_t*' to 'hal_aci_data_t*' [-fpermissive]

Anyone know what is going on?


I am using Arduino 1.6.7

Pages: 1
SMF spam blocked by CleanTalk