I have question about sending an image over GPRS, I have done everything and I am trying to send a file ( in that case an image ) and I have chosen the SD Library.
My code is very simple:
sendData("st");
if (myPhoto) {
int count = 0;
sendDataStart();
Serial.println("test.txt:");
// read from the file until there's nothing else in it:
while (myPhoto.available()) {
//Serial.write(myPhoto.read());
cell.print(myPhoto.read());
count++;
if (count == 200) {
sendDataStop();
delay(1000);
sendDataStart();
count = 0;
}
}
Serial.println("end");
sendDataStop();
// delay(1000);
// close the file:
myPhoto.close();
} else {
// if the file didn't open, print an error:
Serial.println("error opening test.txt");
}
sendData("eu");
What it does is sending a package of 200 reads to a nodejs server, the problem is that I have to send it in integer otherwise I am getting some error.
The string to send a data over GPRS is: AT+SSTRSEND=1,"blabalbalba"
and what I am getting from my server is:
Get data: 2332321671836378123140204292262182175741441082101831191402109530560155571853912925261791651182502171901302142181611019814023791859816702431362065823125502145023417511515213685139118711642487410516017918488522531052033325588522331792212141011901701262081786510117220217265869350232134719068125431502332341825423113869111138141861431341081691106812209551491517918492252202163170142281162453018122710223217689622071248117713124689112217224127151262221911361742028416416916911612328211171301181336155142203616410822725460230249191241218681531292181092392122426625315092156995627127206695214720951577845112311861592482432122325422137255022610516698733110219059782417317217320777112541157854902209224112348223341331111782344415253572047925412977251671795421912567112232361151242232482377610015518920223087208669313525212295250992362101592531501541652461402182343511814126201491992545923790243164183662311392081191562492022182343114117216325501011632049665251381606728127199156220311271501791397516811519681351343123215123125422110125502261066348167202150154
I can transfer all the image without any problems but I don't know what should I do to make it visible from another computer, because what I understood is that I have all the file in binary source, am I right?
I know that I can try to encode my image in Base64 but I don't know if that is the best way, how does it work with a normal socket transmiton ?
Do you have any suggestions to convert all the integers that I getting to a image file?
You need, if you are going to convert each byte to a string, to put delimiters between each byte, so that the stream of ints on the other end can be parsed.
It's simpler, though, to simply not convert each byte to a string. Just send the byte(s).
You commented out a call to Serial.write() and used a cell.print() statement in it's place. Why are you using cell.print() instead of cell.write() when what you want to send is binary data?
Ok, I got that write is sending binary data to the serial port.
I made a mistake that's all, I just need to understand it, this topic is going to be a long one instead of give me advices.
You answered me, thank you ,but if you don't want to help me, so stop it, because I need help not to ask each time something.
You could answer me something like that:
The print does something that you don't need, use write instead that writes binary data
You told me to create a DELIMITERS between each byte, maybe I misunderstood what you are saying .... what I can imagine is to create a buffer "10;2;2;" and then convert each byte to char on the nodejs side.
I don't have any idea how does it work with a normal socket, I know how to exchange message between two machine but I don't have any clue to send a file.
You told me to create a DELIMITERS between each byte,
No. I said that IF you were going to convert each byte to a string, which is what print() does, that you needed to put a delimiter between each string. If you use write(), instead, each byte is sent as-is, so no delimiters are needed.
I couldn't make it works, I tried to send only ascii number with a separation:
cell.print((int)myPhoto.read()); cell.print("%");
My string is something like that: 178%31%9%63%237%188%147%124%167%178%0%5 , on the server side I am splitting the string and then convert every number to char.
The server created a file image that I can't open it, my understanding is where I am doing wrong, how can I send this image over a socket?
And I managed to send to have the same buffer on my NodeJS, the problem is to convert these bytes into a file, I tried to use a convert but I am able to have an exactly copy, the header is kind of the same.
The image is a GIF and I can have the same first few letters: GIF89a2
There is a special converter to recreate the file?
I'm hoping to do something similar with an Arduino Uno and the GPRS v2.0 shield. Please help me understand but to have an image appear on my website I will need the gprs to send the image in bytes then have my server parse the image? If so my main question is how will I parse the byte data? I have been using thingspeak, would I do something similar to the plugins provided by thingspeak?