Search Array Char
The project I am working on is a BURSTCOIN dash, it gets information from Poloniex using ESP8266, the first problem I ran into was that I was using http.getstring and it was big to go to string and it kept restarting the device. Then I decided to use a buffer and now I can get all the information to be printed in sequential order. Now the problem is that I am looking for BTC_BURST information in all the chunks I receive. I am wondering if instead of splitting my chunks into 128 or 256 bytes, if I can split it after each one it receives. Here is my code.
#include <ESP8266HTTPClient.h>
#include <ESP8266WiFi.h>
#include <DNSServer.h>
#include <ESP8266WebServer.h>
#include <WiFiManager.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
//#include <ArduinoJson.h>
#define LCD_ROWS 2
#define LCD_COLS 16
LiquidCrystal_I2C lcd(0x3F, LCD_COLS, LCD_ROWS);
WiFiManager wifiManager;
char apname[] = "ssid";
//char appass[] = "pass";
void configModeCallback (WiFiManager *myWiFiManager) {
lcd.home();
lcd.clear();
lcd.print("Now Entering");
lcd.setCursor(0, 1);
lcd.print("Setup Mode");
delay(2000);
lcd.home();
lcd.clear();
lcd.print("Pls Conn To AP");
lcd.setCursor(0, 1);
lcd.print(apname);
}
void setup() {
Serial.begin(115200);
Serial.println();
lcd.begin(4,5);
lcd.backlight();
startup();
thankyou();
lcd.home();
lcd.clear();
lcd.print("Connecting");
lcd.setCursor(0, 1);
lcd.print("To Local WiFi");
wifiManager.setTimeout(180);
wifiManager.setAPCallback(configModeCallback);
wifiManager.autoConnect(apname);//no password
//wifiManager.autoConnect(apname,appass);//with password
lcd.clear();
lcd.print("Connected!");
delay(2000);
}
void resetesp(){
wifiManager.resetSettings();
}
void startup(){
lcd.clear();
lcd.home();
lcd.print("Ticker Test");
lcd.setCursor(0, 1);
lcd.print("By Draknoid");
delay(2000);
}
void thankyou(){
lcd.clear();
lcd.home();
lcd.print("Thank You!");
lcd.setCursor(0, 1);
lcd.print("Your Name Here");
delay(2000);
}
void loop() {
if (WiFi.status() == WL_CONNECTED) { //Check WiFi connection status
HTTPClient http; //Declare an object of class HTTPClient
http.begin("https://poloniex.com/public?command=returnTicker","83:7D:87:4B:80:8B:B9:26:33:C0:5A:DC:30:18:58:D9:69:14:D1:4F"); //Specify request destination
int httpCode = http.GET();//Send the request
if(httpCode == HTTP_CODE_OK){
int len = http.getSize();// get lenght of document (is -1 when Server sends no Content-Length header)
// create buffer for read
char jsonBuffer[128]; // verify this
// get tcp stream
WiFiClient * stream = http.getStreamPtr();
// read all data from server
while(http.connected() && (len > 0 || len == -1)) {
// get available data size
size_t size = stream->available();
if(size) {
// read up to 128 byte
int c = stream->readBytes(jsonBuffer, ((size > sizeof(jsonBuffer)) ? sizeof(jsonBuffer) : size));
// write it to Serial
Serial.println(jsonBuffer);
if(len > 0) {
len -= c;
}
}
}
}
}
delay(10000);
}
+3
source to share
No one has answered this question yet
Check out similar questions: