Example sketches for the new Arduino IDE for ESP8266

Moderator: igrr

User avatar
By fgomes
#24716 As far as I know the ack will be done only at the TCP level, not application, but if I'm not invoking yield periodically probably the TCP stack is not able to run, so maybe no TCP acks are sent, this is just a possible justification, I'll test it later today and I'll post here the results.

Best regards

Fernando
User avatar
By redflag2k
#27209 Hi.. Did you solve the problem?

I have same issue with ESP8266 (Arduino IDE)+ VS1053 audio module.
Max play time is 53sec. in general, 10~15 sec.

My code is as follows (Selected line)
-- ----
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <SPI.h>
const char* ssid     = "...";
const char* password = "...";

#define BUFFER_LENGTH 512       //Ethernet data bufer length.
#define BUFFER_LENGTH2 32       //VS1053 data buffer length

////////////////////////////////////////////////////////////////////////
//VS1053 player(0, 2, 4, 5); // cs_pin, dcs_pin, dreq_pin, reset_pin
#define cs_pin 0
#define dcs_pin 2
#define dreq_pin 4
#define reset_pin 5

const uint8_t vs1053_chunk_size = 32;

void setup () {
    //for ESP8266 SPI Pin setting (2015.06.20)
    pinMode(12, FUNCTION_2); //MISO
    pinMode(13, FUNCTION_2); //MOSI
    pinMode(14, FUNCTION_2); //SCLK
     
    SPI.begin();   // Start SPI
    Serial.begin(115200); // Start Serial

  Serial.println("Booting VS1053...");   // Boot VS1053D
  delay(1);
  SPI.setClockDivider(SPI_CLOCK_DIV64); // Slow!
  digitalWrite(reset_pin,HIGH);    //Mp3ReleaseFromReset();

  write_register(SCI_VOL,0xffff); // Volume
  write_register(SCI_AUDATA,10);    /* Declick: Slow sample rate for slow analog part startup */ // 10 Hz

  delay(100);
......
  modeSwitch(); //Change mode from MIDI to MP3 decoding (Vassilis Serasidis).
  setVolume(0x20);   //Set the volume to the maximux.

//--------End of SPI  setting ---.
//--------Wifi connecting------------------//
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);    Serial.print(".");
  }
  Serial.println("");  Serial.println("WiFi connected");  Serial.println("IP address: ");  Serial.println(WiFi.localIP());
 
}   // End of Setup()

void loop() {
    if(Serial.available()){
       int temp = Serial.parseInt();
      if(temp == 1) {
         Serial.println("Input 1");
         playWebRadioStation(station1_IP, station1_Port, "01");
      } else if(temp == 2) { 
         Serial.println("Input 2");
         playWebRadioStation(station2_IP, station2_Port, "02");     
      } else if(temp == 3) {
         Serial.println("Input 3");
         playWebRadioStation(station3_IP, station3_Port, "03");           
      }
    }
}   // End of loop()

//=====================================================================================================
void playWebRadioStation ( const char* host, const int hisPort, char* preset )
{
  Serial.print("\n\n<"); //Print the station info to the serial port
  Serial.print(host); Serial.print(hisPort);
  Serial.println(preset);
  Serial.println("> ============================================================");

  stopSong();
  ViewStationInfo = false;
  indexCounter = 0;

  WiFiClient client;

  if (!client.connect(host, hisPort)) {
    Serial.println("Connection failed");
  }
  else {
    client.print(String("GET ") + "/" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");
    Serial.println(String("GET ") + "/" + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: close\r\n\r\n");

    delay(10);

   while(client.available()){
        client.readBytes(VS1053DATA, BUFFER_LENGTH);
       while ( !digitalRead(dreq_pin) );
       playChunk(VS1053DATA,BUFFER_LENGTH);
  }
      delay(1);
}
User avatar
By fgomes
#28317 Hi redflag2k, I didn't solved it, I will try to replicate it with a local icecast server and wireshark active running both on my laptop, in order to identify the difference between the network traffic profile when the requests are from the ESP8266 client and when they are from a working webradio client, to see if this can show us some clue to the problem... There are examples working with the ESP8266 but using the SDK/FreeRTOS instead of the Arduino platform.

Do you have any clue about this issue?

Best regards

Fernando