resolving "some" errors
LOG_EDBUG and printf don't seem to do anything
This commit is contained in:
@@ -8,6 +8,11 @@
|
|||||||
#ifndef INC_UDP_BROADCAST_H_
|
#ifndef INC_UDP_BROADCAST_H_
|
||||||
#define INC_UDP_BROADCAST_H_
|
#define INC_UDP_BROADCAST_H_
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "lwip/netif.h"
|
||||||
|
#include "lwip.h"
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char* name;
|
char* name;
|
||||||
char* surname;
|
char* surname;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
//|
|
//|
|
||||||
#include "UDP_broadcast.h"
|
#include "UDP_broadcast.h"
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @fn void set_owner_details_mac(owner_details_t*)
|
* @fn void set_owner_details_mac(owner_details_t*)
|
||||||
@@ -16,16 +16,13 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static void set_owner_details_mac(owner_details_t* owner){
|
static void set_owner_details_mac(owner_details_t* owner){
|
||||||
uint32_t uID[3];
|
// Access the MAC address
|
||||||
|
|
||||||
HAL_GetUID(uID); // Read the UID registers
|
|
||||||
|
|
||||||
owner->mac_address[0] = (uID[0] >> 0) & 0xFF;
|
for(int i = 0; i < 6; i++){
|
||||||
owner->mac_address[1] = (uID[0] >> 8) & 0xFF;
|
owner->mac_address[i] = netif_default->hwaddr[i];
|
||||||
owner->mac_address[2] = (uID[0] >> 16) & 0xFF;
|
}
|
||||||
owner->mac_address[3] = (uID[1] >> 0) & 0xFF;
|
|
||||||
owner->mac_address[4] = (uID[1] >> 8) & 0xFF;
|
|
||||||
owner->mac_address[5] = (uID[1] >> 16) & 0xFF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -37,7 +34,7 @@ static void set_owner_details_mac(owner_details_t* owner){
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint8_t set_owner_details_name(owner_details_t* owner, char* name){
|
uint8_t set_owner_details_name(owner_details_t *owner, char *name){
|
||||||
if(name != NULL){
|
if(name != NULL){
|
||||||
if(owner->name == NULL){
|
if(owner->name == NULL){
|
||||||
owner->name = (char*)malloc(strlen(name) + 1);
|
owner->name = (char*)malloc(strlen(name) + 1);
|
||||||
@@ -87,7 +84,7 @@ uint8_t set_owner_details_surname(owner_details_t* owner, char* surname){
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static uint8_t set_owner_details_reply(owner_details_t owner, char * reply){
|
static uint8_t set_owner_details_reply(owner_details_t *owner, char *reply){
|
||||||
if(reply != NULL){
|
if(reply != NULL){
|
||||||
if(owner->reply == NULL){
|
if(owner->reply == NULL){
|
||||||
owner->reply = (char*)malloc(strlen(reply) + 1);
|
owner->reply = (char*)malloc(strlen(reply) + 1);
|
||||||
@@ -123,7 +120,7 @@ static void format_reply(owner_details_t *owner){
|
|||||||
owner->mac_address[0], owner->mac_address[1], owner->mac_address[2],
|
owner->mac_address[0], owner->mac_address[1], owner->mac_address[2],
|
||||||
owner->mac_address[3], owner->mac_address[4], owner->mac_address[5]);
|
owner->mac_address[3], owner->mac_address[4], owner->mac_address[5]);
|
||||||
|
|
||||||
if (replyBuffer != NULL) {
|
if (reply_buf != NULL) {
|
||||||
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, owner->surname, owner->name);
|
mac_addr_str, owner->surname, owner->name);
|
||||||
|
|
||||||
@@ -145,7 +142,8 @@ static void format_reply(owner_details_t *owner){
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
uint8_t set_owner_details(owner_details_t* owner, char* name, char* surname){
|
uint8_t set_owner_details(owner_details_t* owner, char* name, char* surname){
|
||||||
if(set_owner_details_name(owner, name) && set_owner_details_surname(owner, surname) && set_owner_details_mac(owner)){
|
if(set_owner_details_name(owner, name) && set_owner_details_surname(owner, surname)){
|
||||||
|
set_owner_details_mac(owner);
|
||||||
format_reply(owner);
|
format_reply(owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -160,11 +158,11 @@ uint8_t set_owner_details(owner_details_t* owner, char* name, char* surname){
|
|||||||
|
|
||||||
char* get_owner_details_name(owner_details_t owner){
|
char* get_owner_details_name(owner_details_t owner){
|
||||||
char *err_reply = "no name yet";
|
char *err_reply = "no name yet";
|
||||||
if(owner == NULL || owner->name == NULL){
|
if(owner.name == NULL){
|
||||||
owner->name = (char*)malloc(strlen(err_reply));
|
owner.name = (char*)malloc(strlen(err_reply));
|
||||||
strcpy(owner->name,err_reply);
|
strcpy(owner.name,err_reply);
|
||||||
}
|
}
|
||||||
return owner->name;
|
return owner.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -177,11 +175,11 @@ char* get_owner_details_name(owner_details_t owner){
|
|||||||
|
|
||||||
char* get_owner_details_surname(owner_details_t owner){
|
char* get_owner_details_surname(owner_details_t owner){
|
||||||
char *err_reply = "no surname yet";
|
char *err_reply = "no surname yet";
|
||||||
if(owner == NULL || owner->surname == NULL){
|
if(owner.surname == NULL){
|
||||||
owner->surname = (char*)malloc(strlen(err_reply));
|
owner.surname = (char*)malloc(strlen(err_reply));
|
||||||
strcpy(owner->name,err_reply);
|
strcpy(owner.name,err_reply);
|
||||||
}
|
}
|
||||||
return owner->name;
|
return owner.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -192,13 +190,13 @@ char* get_owner_details_surname(owner_details_t owner){
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char* get_owner_details_reply(owner_details_t){
|
char* get_owner_details_reply(owner_details_t owner){
|
||||||
char *err_reply = "no reply yet";
|
char *err_reply = "no reply yet";
|
||||||
if(owner == NULL || owner->reply == NULL){
|
if(owner.reply == NULL){
|
||||||
owner->reply = (char*)malloc(strlen(err_reply));
|
owner.reply = (char*)malloc(strlen(err_reply));
|
||||||
strcpy(owner->name,err_reply);
|
strcpy(owner.name,err_reply);
|
||||||
}
|
}
|
||||||
return owner->name;
|
return owner.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,17 +72,7 @@ static void MX_QUADSPI_Init(void);
|
|||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
int _write(int file, char *ptr, int len) {
|
|
||||||
|
|
||||||
for (int x = 0;x<len;x++){
|
|
||||||
if (ptr[x]=='\n'){
|
|
||||||
HAL_UART_Transmit(&huart1, (uint8_t*)"\r", 1, HAL_MAX_DELAY);
|
|
||||||
}
|
|
||||||
HAL_UART_Transmit(&huart1, (uint8_t*)&ptr[x], 1, HAL_MAX_DELAY);
|
|
||||||
}
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,11 +83,13 @@ int main(void)
|
|||||||
{
|
{
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
owner_details_t owner;
|
owner_details_t owner;
|
||||||
printf("%s",get_owner_details_reply());
|
printf("hello world");
|
||||||
set_owner_details(owner, "joran", "vn");
|
LOG_DEBUG("main","helloworld");
|
||||||
printf("%s",get_owner_details_reply());
|
LOG_DEBUG("main","%s",get_owner_details_reply(owner));
|
||||||
set_owner_details(owner, "joran", "Van Nieuwenhoven");
|
set_owner_details(&owner, "joran", "vn");
|
||||||
printf("%s",get_owner_details_reply());
|
LOG_DEBUG("main","%s",get_owner_details_reply(owner));
|
||||||
|
set_owner_details(&owner, "joran", "Van Nieuwenhoven");
|
||||||
|
LOG_DEBUG("main","%s",get_owner_details_reply(owner));
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user