Fix style guide issues by auto formatting
This commit is contained in:
@@ -10,11 +10,11 @@
|
|||||||
#define INC_UDP_BROADCAST_H_
|
#define INC_UDP_BROADCAST_H_
|
||||||
|
|
||||||
// includes
|
// includes
|
||||||
#include <string.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "lwip/netif.h"
|
#include <string.h>
|
||||||
#include "lwip.h"
|
#include "lwip.h"
|
||||||
|
#include "lwip/netif.h"
|
||||||
#define LOGGER_LEVEL_INFO
|
#define LOGGER_LEVEL_INFO
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "udp.h"
|
#include "udp.h"
|
||||||
|
|||||||
@@ -23,7 +23,11 @@ static uint8_t udp_broadcast_set_owner_details_name(const char* name);
|
|||||||
static uint8_t udp_broadcast_set_owner_details_surname(const char* surname);
|
static uint8_t udp_broadcast_set_owner_details_surname(const char* surname);
|
||||||
static uint8_t udp_broadcast_set_owner_details_reply(const char* reply);
|
static uint8_t udp_broadcast_set_owner_details_reply(const char* reply);
|
||||||
static void udp_broadcast_format_reply();
|
static void udp_broadcast_format_reply();
|
||||||
static void udp_receive_callback(void* arg, struct udp_pcb* connection, struct pbuf* p, const ip_addr_t* addr, u16_t port);
|
static void udp_receive_callback(void* arg,
|
||||||
|
struct udp_pcb* connection,
|
||||||
|
struct pbuf* p,
|
||||||
|
const ip_addr_t* addr,
|
||||||
|
u16_t port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn uint8_t udp_broadcast_set_owner_details_mac(owner_details_t*)
|
* @fn uint8_t udp_broadcast_set_owner_details_mac(owner_details_t*)
|
||||||
@@ -116,16 +120,15 @@ static void udp_broadcast_format_reply(){
|
|||||||
|
|
||||||
reply_len = 27 + sizeof(mac_addr_str) + sizeof(udp_owner.surname) + sizeof(udp_owner.name);
|
reply_len = 27 + sizeof(mac_addr_str) + sizeof(udp_owner.surname) + sizeof(udp_owner.name);
|
||||||
|
|
||||||
snprintf(mac_addr_str, sizeof(mac_addr_str), "%02X:%02X:%02X:%02X:%02X:%02X",
|
snprintf(mac_addr_str, sizeof(mac_addr_str), "%02X:%02X:%02X:%02X:%02X:%02X", udp_owner.mac_address[0],
|
||||||
udp_owner.mac_address[0], udp_owner.mac_address[1], udp_owner.mac_address[2],
|
udp_owner.mac_address[1], udp_owner.mac_address[2], udp_owner.mac_address[3], udp_owner.mac_address[4],
|
||||||
udp_owner.mac_address[3], udp_owner.mac_address[4], udp_owner.mac_address[5]);
|
udp_owner.mac_address[5]);
|
||||||
|
|
||||||
snprintf(reply_buf, reply_len, "%s is present and my owner is %s %s",
|
snprintf(reply_buf, reply_len, "%s is present and my owner is %s %s", mac_addr_str, udp_owner.surname,
|
||||||
mac_addr_str, udp_owner.surname, udp_owner.name);
|
udp_owner.name);
|
||||||
|
|
||||||
LOG_DEBUG(TAG, "reply_buf: %s", reply_buf);
|
LOG_DEBUG(TAG, "reply_buf: %s", reply_buf);
|
||||||
udp_broadcast_set_owner_details_reply(reply_buf);
|
udp_broadcast_set_owner_details_reply(reply_buf);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -147,7 +150,6 @@ uint8_t udp_broadcast_set_owner_details(const char* name, const char* surname){
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -212,8 +214,10 @@ static void udp_broadcast_check_function(const char data[MAX_DATA_SIZE]){
|
|||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG_DEBUG(TAG,"%d-%d=%d, %d-%d=%d",enders[2],enders[1],enders[2] - enders[1],strlen(data),enders[3],strlen(data) - enders[3]);
|
LOG_DEBUG(TAG, "%d-%d=%d, %d-%d=%d", enders[2], enders[1], enders[2] - enders[1], strlen(data), enders[3],
|
||||||
if(enders[2] - enders[1] < 22 && strlen(data) - enders[3] < 22 && strncmp(data+enders[0],":name",5) == 0 && strncmp(data+enders[2],", surname",9) == 0 ){
|
strlen(data) - enders[3]);
|
||||||
|
if (enders[2] - enders[1] < 22 && strlen(data) - enders[3] < 22 && strncmp(data + enders[0], ":name", 5) == 0
|
||||||
|
&& strncmp(data + enders[2], ", surname", 9) == 0) {
|
||||||
counter = 0;
|
counter = 0;
|
||||||
for (uint8_t i = enders[1] + 2; i < enders[2] && data[i] != '\0'; i++) {
|
for (uint8_t i = enders[1] + 2; i < enders[2] && data[i] != '\0'; i++) {
|
||||||
buffer[counter] = data[i];
|
buffer[counter] = data[i];
|
||||||
@@ -255,7 +259,11 @@ static void udp_broadcast_check_function(const char data[MAX_DATA_SIZE]){
|
|||||||
* @param[in] port the source port number of the sender's UDP packet
|
* @param[in] port the source port number of the sender's UDP packet
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void udp_receive_callback(void* arg, struct udp_pcb* connection, struct pbuf* p, const ip_addr_t* addr, u16_t port){
|
static void udp_receive_callback(void* arg,
|
||||||
|
struct udp_pcb* connection,
|
||||||
|
struct pbuf* p,
|
||||||
|
const ip_addr_t* addr,
|
||||||
|
u16_t port) {
|
||||||
struct pbuf* p_data;
|
struct pbuf* p_data;
|
||||||
size_t len;
|
size_t len;
|
||||||
char* pc;
|
char* pc;
|
||||||
|
|||||||
Reference in New Issue
Block a user