Pages: [1]   Go Down
Author Topic: dtostrf with 0 value give error when send http  (Read 519 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi again,
             could it be possible that when temperature is start with 0, it unable to send the url it give me a error?

Code:
if ((timing ==1) && (millis() > timer)) {
    timer = millis() + 5000;
    sensors.requestTemperatures();
    Serial.println();
    Serial.println("<<< REQ ");
    float sensor1 = (sensors.getTempCByIndex(1));
    char buffer[10];
    dtostrf(sensor1, 5, 2, buffer);
    Serial.println("Sensor2 temperature is:");
    Serial.println(buffer);
    timing = 0;
    delay(500);
    ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);
   
« Last Edit: March 10, 2013, 06:36:09 pm by smallpoul » Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Dare we ask what the error is?

+++ OUT OF CHEESE ERROR +++
+++ REDO FROM START +++
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Really dont understand your answer
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Unless you actually tell us what is happening, we don't have a cat's chance in hell of helping you solve it.

Just saying "it give me an error" is like walking up to someone and saying "my car no go" and expecting them to tell you that the gear box is broken.

Please tell us at the very least what the error it gives you is.

For the last part of my answer, read some books.
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If value of the sensor is more then 1 , data is send to the server and i receive a ok message. as soon as the temperature is 0, i receive a bad request error 400.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe that when it convert the 0 in the first bytes, bytes is null? Could that be my problem and if so could a byte be 0 not null.
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you sniffed the network packets to see if the URL being transmitted is properly formed?

Have you tried manually interacting with the website to send a URL with a 0 value to see if it throws an error?
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Offline Offline
Jr. Member
**
Karma: 0
Posts: 67
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Mistake by me i always have bad request event if temp is more the 1 degree, If i put it manually like this everything is find and update:
Code:
ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value=7"), "", website, my_callback);

How the do i include the temerature after the=
Logged

UK
Offline Offline
Shannon Member
****
Karma: 223
Posts: 12577
-
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Code:
ether.browseUrl(PSTR("/data_request?id=variableset&DeviceNum=48&serviceId=urn:upnp-org:serviceId:TemperatureSensor1&Variable=CurrentTemperature&Value="), buffer, website, my_callback);

I don't recognise this browseUrl() method. I guess the first argument is a URL, and the URL you supply has a URL-encoded parameter ("Value") which does not have a value assigned, which could reasonably be deemed a bad request. You've put a value on the buffer variable. Was that supposed to be appended to your URL? If so, where do you think that happens?
Logged

I only provide help via the forum - please do not contact me for private consultancy.

Pages: [1]   Go Up
Jump to: