My cam is connected on my internal network, and I control it well with Postman, sending a simple POST request.
you could find below the preview of what Postman is sending:
Unfortunately I never succeed to translate that for the Spark Core, and since November I have headache with this issue!
bko already try to help me but this is always not working
Hi @harrisonhjones, here is the result from RequestBin after some correction on my code
-The request coming from POSTMAN which is working with my cam: -The request coming from the Spark Core which is not working with my cam:
Same result from my point of view⦠there is just the cookie which is not present on the spark requestPerhaps there is an issue of sending? It seems very long when I control the request with my serial port terminal application (time between: āconnection okā and ātest finishā)
really sorry for the delay⦠my internet is very intermittent at the moment⦠i pushed reply 2 hours ago and it was still not sent when i got back to my desk!
what type of camera are you controlling? and what does the request above do? it would be awesome to see the whole api and know what the camera can do
Thank you @Hootie81 for this reply (you didnāt have any deadline )
What should I put in the library application.h?
is this the declaration of void out(),void in() and void cameraControl() parts? I never see them in a spark core code.
I control a D-link cam over my private network (in wifi) to manage the Motion detection option.
A0 (Spark Core input) is connected to my alarm,
When alarm is activated, the Motion detection of my cam is enabled, and when disarm the Motion detection will be disabled.
Try adjusting the Content-Length and/or removing the \r\n at the end of the message.
It looks like you are setting up a 190 char message, setting C-L header to 190, but then sending 192 chars because of the \r\n?
In my last post with RequestBin results, you can see that 190 bytes has been sent (after modification of the code).
This is still not working for the cam side with the Spark POST request. (it work with Postman)
the body is not the answer, the body is what you are sending
If you use the code i sent, you should see the reply come up in the terminal. when you power up the little blue led should come on letting you know to open a terminal, then open your terminal application and press any key to start the user code running again.
you should then see the outgoing request with all the connect and headers and then the body. if you wait a second you should see the reply, it should start with 200 OK or maybe 400 something because its not working⦠that will be the biggest clue to whats happening
I cannot compile your code @Hootie81 , there is to many error like if it miss an application.h for declaration??
I would like to test it, but it cannot compile:
In file included from ā¦/inc/spark_wiring.h:29:0,
from ā¦/inc/application.h:29,
from enable_cam_dlink.cpp:1:
ā¦/ā¦/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning āDefaulting to Release Buildā [-Wcpp] #warning āDefaulting to Release Buildā
^
enable_cam_dlink.cpp:6:20: error: āuint8_tā has not been declared
void in(char *ptr, uint8_t timeout);
^
enable_cam_dlink.cpp:7:20: error: variable or field ācameraControlā declared void
void cameraControl(IPAddress hostname, int port, char *url, char *logon);
^
enable_cam_dlink.cpp:7:20: error: āIPAddressā was not declared in this scope
enable_cam_dlink.cpp:7:40: error: expected primary-expression before 'intā
void cameraControl(IPAddress hostname, int port, char *url, char *logon);
^
enable_cam_dlink.cpp:7:50: error: expected primary-expression before 'charā
void cameraControl(IPAddress hostname, int port, char *url, char *logon);
^
enable_cam_dlink.cpp:7:61: error: expected primary-expression before 'charā
void cameraControl(IPAddress hostname, int port, char *url, char *logon);
^
enable_cam_dlink.cpp:3:6: error: previous declaration of āvoid setup()ā with āC++ā linkage
void setup();
^
In file included from ā¦/inc/spark_wiring.h:33:0,
from ā¦/inc/application.h:29,
from enable_cam_dlink.cpp:1:
ā¦/inc/spark_utilities.h:169:35: error: conflicts with new declaration with āCā linkage
void setup() attribute ((weak));
^
enable_cam_dlink.cpp:4:6: error: previous declaration of āvoid loop()ā with āC++ā linkage
void loop();
^
In file included from ā¦/inc/spark_wiring.h:33:0,
from ā¦/inc/application.h:29,
from enable_cam_dlink.cpp:1:
ā¦/inc/spark_utilities.h:170:34: error: conflicts with new declaration with āCā linkage
void loop() attribute ((weak));
^
enable_cam_dlink.cpp: In function āvoid loop()ā:
enable_cam_dlink.cpp:52:56: error: ācameraControlā was not declared in this scope
}
^
make: *** [enable_cam_dlink.o] Error 1
Error: Could not compile. Please review your code.
Here is the result:
It seems that the request syntax is incorrect (400 Bad Request)
connecting⦠connected to 192.168.0.11
POST /setSystemMotion HTTP/1.1
Host: 192.168.0.11:80
Authorization: Basic Yxxxxxxxxxxxxxxxxxc=
Cache-Control: no-cache
Content-Type: text/plain
Content-Length: 190
Connection: close
ReplySuccessPage=motion.htm&ReplyErrorPage=motion.htm&MotionDetectionEnable=1&MotionDetectionScheduleDay=0&MotionDetectionScheduleMode=0&MotionDetectionSensitivity=90&ConfigSystemMotion=Save
HTTP/1.0 400 Bad Request