fix UDP
This commit is contained in:
parent
840160250c
commit
4638041cd7
@ -41,6 +41,8 @@ typedef struct {
|
||||
extern void MQTTPublish(char * topic, char * payload);
|
||||
extern void MQTTSubscribe(char* topic, void *cb(char* topic, char* payload));
|
||||
|
||||
extern void UDPSend (char msg[128], int len);
|
||||
|
||||
void MQTTCB_reply(char* topic, char* payload){
|
||||
char msg[50];
|
||||
|
||||
|
||||
@ -92,8 +92,6 @@ int main(void)
|
||||
pthread_t GSensorThread;
|
||||
retc = pthread_create(&GSensorThread, &attrs, GSensorTask, NULL);
|
||||
if (retc != 0) {
|
||||
/* pthread_create() failed */
|
||||
// LOG_CRITICAL("main(): failed to create tread for G-sensor");
|
||||
while(1);
|
||||
}
|
||||
|
||||
@ -105,8 +103,6 @@ int main(void)
|
||||
pthread_t MQTTThread;
|
||||
retc = pthread_create(&MQTTThread, &attrs, MQTTTask, NULL);
|
||||
if (retc != 0) {
|
||||
/* pthread_create() failed */
|
||||
// LOG_CRITICAL("main(): failed to create tread for MQTT");
|
||||
while(1);
|
||||
}
|
||||
|
||||
@ -118,8 +114,6 @@ int main(void)
|
||||
pthread_t HandshakeThread;
|
||||
retc = pthread_create(&HandshakeThread, &attrs, handshakeTask, NULL);
|
||||
if (retc != 0) {
|
||||
/* pthread_create() failed */
|
||||
// LOG_CRITICAL("main(): failed to create tread for MQTT");
|
||||
while(1);
|
||||
}
|
||||
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
Display_Handle lookielookie;
|
||||
mqd_t UDPQueue;
|
||||
|
||||
#define UDP_PORT sl_Htons(12345) // Port gedefineerd in de UDP server
|
||||
#define UDP_IP SL_IPV4_VAL(192, 168, 0, 0) // IP gedefineerd in de UDP server
|
||||
#define UDP_PORT sl_Htons(12345) // Port gedefineerd in de UDP server
|
||||
#define UDP_IP sl_Htonl(SL_IPV4_VAL(10, 2, 0, 2)) // IP gedefineerd in de UDP server
|
||||
|
||||
typedef struct {
|
||||
_u8 buffboi[128];
|
||||
@ -31,6 +31,8 @@ void UDPSend (char msg[128], int len) {
|
||||
}
|
||||
|
||||
void* UDPClientTask(void *args) {
|
||||
sleep(2);
|
||||
|
||||
_i16 sokken = sl_Socket(SL_AF_INET, SL_SOCK_DGRAM, SL_IPPROTO_UDP);
|
||||
if (sokken < 0) {
|
||||
while(1);
|
||||
@ -39,17 +41,17 @@ void* UDPClientTask(void *args) {
|
||||
SlSockAddrIn_t clientAddress = {SL_AF_INET, UDP_PORT, sl_Htonl(SL_INADDR_ANY)};
|
||||
SlSockAddrIn_t serverAddress = {SL_AF_INET, UDP_PORT, UDP_IP};
|
||||
|
||||
_i16 error = sl_Connect(sokken, (SlSockAddr_t *)&serverAddress, sizeof(clientAddress));
|
||||
_i16 error = sl_Connect(sokken, (SlSockAddr_t *)&serverAddress, sizeof(serverAddress));
|
||||
if (error < 0) {
|
||||
while(1);
|
||||
}
|
||||
|
||||
_u8 buffering[100];
|
||||
|
||||
_i16 sokkenAan = sl_Recv(sokken, &buffering, 100, 0);
|
||||
if (error < 0) {
|
||||
while(1);
|
||||
}
|
||||
// _i16 sokkenAan = sl_Recv(sokken, &buffering, 100, 0);
|
||||
// if (error < 0) {
|
||||
// while(1);
|
||||
// }
|
||||
Display_printf(lookielookie, 0, 0, "Ontvangen van server: %s", buffering);
|
||||
|
||||
mq_attr attr;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user