* IPAddress issue fixed
This commit is contained in:
parent
a10a8ac253
commit
abd91e60f5
@ -102,11 +102,8 @@ int connection_send(connection_t *connP,
|
|||||||
uint8_t * buffer,
|
uint8_t * buffer,
|
||||||
size_t length)
|
size_t length)
|
||||||
{
|
{
|
||||||
SerialUSB.println("connection_send() start");
|
SerialUSB.println(F("connection_send() start"));
|
||||||
// connP->remoteIp->printTo(SerialUSB);
|
connP->udpConnection->beginPacket(*(connP->remoteIp), connP->port);
|
||||||
IPAddress srv(192,168,14,14);
|
|
||||||
// connP->udpConnection->beginPacket(*(connP->remoteIp), connP->port);
|
|
||||||
connP->udpConnection->beginPacket(srv, connP->port);
|
|
||||||
connP->udpConnection->write(buffer, length);
|
connP->udpConnection->write(buffer, length);
|
||||||
connP->udpConnection->endPacket();
|
connP->udpConnection->endPacket();
|
||||||
return 0;
|
return 0;
|
||||||
@ -126,8 +123,6 @@ uint8_t lwm2m_buffer_send(void * sessionH,
|
|||||||
return COAP_500_INTERNAL_SERVER_ERROR ;
|
return COAP_500_INTERNAL_SERVER_ERROR ;
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialUSB.println("before send");
|
|
||||||
SerialUSB.println((uint32_t)connP->remoteIp);
|
|
||||||
if (-1 == connection_send(connP, buffer, length))
|
if (-1 == connection_send(connP, buffer, length))
|
||||||
{
|
{
|
||||||
// fprintf(stderr, "#> failed sending %lu bytes\r\n", length);
|
// fprintf(stderr, "#> failed sending %lu bytes\r\n", length);
|
||||||
|
|||||||
@ -25,12 +25,6 @@ void ArduinoClient::init() {
|
|||||||
data.udp = new EthernetUDP();
|
data.udp = new EthernetUDP();
|
||||||
data.udp->begin(localPort);
|
data.udp->begin(localPort);
|
||||||
|
|
||||||
// debug phase
|
|
||||||
IPAddress srv(192,168,14,14);
|
|
||||||
data.udp->beginPacket(srv, 5683);
|
|
||||||
data.udp->write("HereBeDragons");
|
|
||||||
data.udp->endPacket();
|
|
||||||
|
|
||||||
// init objects
|
// init objects
|
||||||
SerialUSB.println(F("*object:security"));
|
SerialUSB.println(F("*object:security"));
|
||||||
objArray[0] = get_security_object(uri);
|
objArray[0] = get_security_object(uri);
|
||||||
@ -103,11 +97,9 @@ void ArduinoClient::doWorkStep() {
|
|||||||
*/
|
*/
|
||||||
SerialUSB.println(F("lwm2m_step()"));
|
SerialUSB.println(F("lwm2m_step()"));
|
||||||
result = lwm2m_step(lwm2mH, &step_delay);
|
result = lwm2m_step(lwm2mH, &step_delay);
|
||||||
SerialUSB.println(result, DEC);
|
|
||||||
if (result != 0)
|
if (result != 0)
|
||||||
{
|
{
|
||||||
SerialUSB.print(F("lwm2m_step() failed"));
|
SerialUSB.print(F("lwm2m_step() failed"));
|
||||||
SerialUSB.println(result, HEX);
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,9 +122,10 @@ void ArduinoClient::doWorkStep() {
|
|||||||
SerialUSB.println(F("doWorkStep():done"));
|
SerialUSB.println(F("doWorkStep():done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Destructor, actually this won't ever run on arduino...
|
||||||
|
*/
|
||||||
ArduinoClient::~ArduinoClient() {
|
ArduinoClient::~ArduinoClient() {
|
||||||
SerialUSB.println("teardown():start");
|
|
||||||
lwm2m_close(lwm2mH);
|
lwm2m_close(lwm2mH);
|
||||||
data.udp->stop();
|
data.udp->stop();
|
||||||
connection_free(data.connList);
|
connection_free(data.connList);
|
||||||
@ -141,10 +134,15 @@ ArduinoClient::~ArduinoClient() {
|
|||||||
free_server_object(objArray[1]);
|
free_server_object(objArray[1]);
|
||||||
free_object_device(objArray[2]);
|
free_object_device(objArray[2]);
|
||||||
free_test_object(objArray[3]);
|
free_test_object(objArray[3]);
|
||||||
SerialUSB.println("teardown():done");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called from registration.c prv_register()
|
||||||
|
*
|
||||||
|
* @param secObjInstID
|
||||||
|
* @param userData
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
void * lwm2m_connect_server(uint16_t secObjInstID, void *userData) {
|
void * lwm2m_connect_server(uint16_t secObjInstID, void *userData) {
|
||||||
client_data_t * dataP;
|
client_data_t * dataP;
|
||||||
char * uri;
|
char * uri;
|
||||||
@ -197,16 +195,16 @@ void * lwm2m_connect_server(uint16_t secObjInstID, void *userData) {
|
|||||||
*port = 0;
|
*port = 0;
|
||||||
port++;
|
port++;
|
||||||
|
|
||||||
IPAddress remoteIp;
|
IPAddress * remoteIp = new IPAddress();
|
||||||
if(!remoteIp.fromString(host)) {
|
if(!remoteIp->fromString(host)) {
|
||||||
DNSClient dns;
|
DNSClient dns;
|
||||||
dns.begin(Ethernet.dnsServerIP());
|
dns.begin(Ethernet.dnsServerIP());
|
||||||
dns.getHostByName(host, remoteIp);
|
dns.getHostByName(host, *remoteIp);
|
||||||
}
|
}
|
||||||
|
|
||||||
String portStr = port;
|
String portStr = port;
|
||||||
|
|
||||||
newConnP = connection_create(dataP->connList, dataP->udp, &remoteIp, portStr.toInt());
|
newConnP = connection_create(dataP->connList, dataP->udp, remoteIp, portStr.toInt());
|
||||||
if (newConnP == nullptr) {
|
if (newConnP == nullptr) {
|
||||||
SerialUSB.println(F("Connection creation failed"));
|
SerialUSB.println(F("Connection creation failed"));
|
||||||
}
|
}
|
||||||
@ -219,7 +217,12 @@ void * lwm2m_connect_server(uint16_t secObjInstID, void *userData) {
|
|||||||
return (void *)newConnP;
|
return (void *)newConnP;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* called from
|
||||||
|
*
|
||||||
|
* @param sessionH
|
||||||
|
* @param userData
|
||||||
|
*/
|
||||||
void lwm2m_close_connection(void *sessionH, void *userData) {
|
void lwm2m_close_connection(void *sessionH, void *userData) {
|
||||||
client_data_t * app_data;
|
client_data_t * app_data;
|
||||||
connection_t * targetP;
|
connection_t * targetP;
|
||||||
|
|||||||
@ -411,7 +411,6 @@ int transaction_send(lwm2m_context_t * contextP,
|
|||||||
maxRetriesReached = true;
|
maxRetriesReached = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lwm2m_printf("max");
|
|
||||||
|
|
||||||
if (transacP->ack_received || maxRetriesReached)
|
if (transacP->ack_received || maxRetriesReached)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user