Dinstar DWG2000 SMS API stable release

I’ve finished the first stable release of the DWG2000 messaging API. I tested it dozens of times and appears stable after 24 hours of constant running. I’m aware of the memory leaks but I’ll fix this issue as soon as I can.

The code is pretty straightforward and self explanatory. By now this is just for personal use but if any of you are working with the same family of products, I can definitely help you. It is not ready for production, but it works.

[c]
/*
* main.c
*
* Created on: Mar 28, 2012
* Author: caruizdiaz
*/

#include “util.h”
#include “dwg/dwg.h”
#include “networking/ip_socket.h”

void new_sms_handler(dwg_sms_received_t *sms)
{
LOG(L_DEBUG, “new sms from %s. Len: %d, Text: %sn”, sms->number, sms->message.len, sms->message.s);
}

void status_handler(dwg_ports_status_t *status)
{
int index = 0;

LOG(L_DEBUG, “tNumber of ports: %dn”, status->size);

for (index = 0; index < status->size; index++)
{
LOG(L_DEBUG, “tPort%d: %dn”, index, status->status_array[index].status);
}
}

void msg_response_handler(dwg_sms_response_t *response)
{
LOG(L_DEBUG, “tResponse from %sn”, response->number);
}

int main(int argc, char** argv)
{

dwg_message_callback_t callbacks = {
.status_callback = status_handler,
.msg_response_callback = msg_response_handler,
.msg_sms_recv_callback = new_sms_handler
};

dwg_start_server(7008, &callbacks);

str_t des = { “0981146623”, 10 };
str_t msg = { “hola”, 4 };

for(;;)
{
getchar();
dwg_send_sms(&des, &msg);
}

}
[/c]