Click here to Skip to main content
15,881,588 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
C++
hc05.h
#ifndef	_HC05_H_
#define	_HC05_H_ 	1


#include <io.h>;
#include <delay.h>;
#include <usart.h>;

char hc_05_buffer1[25], hc_05_buffer2[50];
char temp;

void hc_05_bluetooth_transmit_byte(char data_byte);
char hc_05_bluetooth_receive_byte(void);
void hc_05_bluetooth_transmit_string(char *transmit_string);
void hc_05_bluetooth_transmit_command(char *transmit_string);
char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character);
unsigned char hc_05_bluetooth_at_command_mode_test(void);
unsigned char hc_05_bluetooth_device_name_change(char *device_name);
unsigned char hc_05_bluetooth_get_version(void);
unsigned  char hc_05_bluetooth_change_baud_rate(long int baud_rate);
unsigned  char hc_05_bluetooth_pin_change(char *new_pin);


void hc_05_bluetooth_transmit_byte(char data_byte)
{
	usart_data_transmit(data_byte);
}
char hc_05_bluetooth_receive_byte(void)
{
	return usart_data_receive();
}
void hc_05_bluetooth_transmit_string(char *transmit_string)
{
	usart_string_transmit(transmit_string);
}
char *hc_05_bluetooth_receive_string(char *receive_string, unsigned char terminating_character)
{
	unsigned char temp=0x00;
	for(unsigned char i=0;;i++)
	{
		*(receive_string+i)=usart_data_receive();
		if(*(receive_string+i)==terminating_character)
			break;
		else
			temp++;
	}
	*(receive_string+temp)=&#39;\0&#39;;
	return receive_string;
}
unsigned char hc_05_bluetooth_at_command_mode_test(void)
{
	UBRRL=12;
	delay_ms(500);
	usart_string_transmit(&quot;AT&quot;);
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	usart_string_receive(hc_05_buffer1,0x0d);
	temp=usart_data_receive();
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

unsigned  char hc_05_bluetooth_change_baud_rate(long int baud_rate)
{
	UBRRL=12;
	delay_ms(500);
	
	if(baud_rate==4800)
	{
		usart_string_transmit(&quot;AT+UART=4800,0,0&quot;);
	}
	else if(baud_rate==9600)
	{
		usart_string_transmit(&quot;AT+UART=9600,0,0&quot;);
	}
	else if(baud_rate==19200)
	{
		usart_string_transmit(&quot;AT+UART=19200,0,0&quot;);
	}
	else if(baud_rate==38400)
	{
		usart_string_transmit(&quot;AT+UART=38400,0,0&quot;);
	}
	else if(baud_rate==57600)
	{
		usart_string_transmit(&quot;AT+UART=57600,0,0&quot;);
	}
	else if(baud_rate==115200)
	{
		usart_string_transmit(&quot;AT+UART=115200,0,0&quot;);
	}
	else if(baud_rate==230400)
	{
		usart_string_transmit(&quot;AT+UART=230400,0,0&quot;);
	}
	else if(baud_rate==460800)
	{
		usart_string_transmit(&quot;AT+UART=460800,0,0&quot;);
	}
	else if(baud_rate==921600)
	{
		usart_string_transmit(&quot;AT+UART=921600,0,0&quot;);
	}
	else if(baud_rate==1382400)
	{
		usart_string_transmit(&quot;AT+UART=1382400,0,0&quot;);
	}
	else
	{
		;
	}
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	usart_string_receive(hc_05_buffer1,13);
	temp=usart_data_receive();
	
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

unsigned char hc_05_bluetooth_device_name_change(char *device_name)
{
	UBRRL=12;
	delay_ms(500);
	
	usart_string_transmit(&quot;AT+NAME=&quot;);
	usart_string_transmit(device_name);
	usart_data_transmit(0x0d);
	usart_data_transmit(0x0a);
	
	usart_string_receive(hc_05_buffer1,13);
	temp=usart_data_receive();
	
	if(!(strcmp(hc_05_buffer1,&quot;OK&quot;)))
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

What I have tried:

Error: C:\cvavr\INC\hc05.h(34): can't open #include file: usart.h
Error: C:\cvavr\INC\hc05.h(53): undefined symbol 'usart_data_transmit'
Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'unsigned'
Error: C:\cvavr\INC\hc05.h(66): undefined symbol 'i'
Error: C:\cvavr\INC\hc05.h(81): undefined symbol 'usart_string_transmit'
Error: C:\cvavr\INC\hc05.h(90): no matching if
Error: C:\cvavr\INC\hc05.h(103): undefined symbol 'usart_string_transmit'
Error: C:\cvavr\INC\hc05.h(145): undefined symbol 'usart_data_transmit'
Error: C:\cvavr\INC\hc05.h(154): no matching if
<pre lang="JavaScript">Error: C:\cvavr\INC\hc05.h(165): undefined symbol 'usart_string_transmit'

Error: C:\cvavr\INC\hc05.h(177): no matching if
Error: C:\cvavr\INC\hc05.h(187): must declare first in block
JavaScript
Error: C:\cvavr\INC\hc05.h(188): undefined symbol 'usart_string_transmit'

JavaScript
Error: C:\cvavr\INC\hc05.h(205): undefined symbol 'strcmp'

Error: C:\cvavr\INC\hc05.h(209): no matching if
JavaScript
Error: C:\cvavr\INC\hc05.h(220): undefined symbol 'usart_string_transmit'

Error: C:\cvavr\INC\hc05.h(232): no matching if
Posted
Updated 27-Jun-16 16:49pm
v3

1 solution

It's telling you the problems ... deal with the main ones first

1.) usart.h is a file it can't be found. The include statement makes it clear it is supposed to be in the default library directories but clearly it isn't. I am guessing usart.h is a serial comms file from wherever you got this code from and you need to find the file and then include it properly. It might be a standard file to an AVR C compiler given where it's trying to be included from but it isn't a C standard file. Whatever the case you need to find the file or make your own matching functions. The code is just sending and receiving characters from a serial port it isn't rocket science to understand.

2.) strcmp is a standard C function in the unit in the standard library file "string.h". It needs to be included as well.
#include <string.h>

will fix that one
C library function - strcmp()[^]

The rest of the errors look to be syntax based on the compiler not being able to get over those two problems. Fix those first and the rest should drop away.
 
Share this answer
 
v7
Comments
shsmszdh 28-Jun-16 16:45pm    
thanks for your suggestions I did them and errors reduced to these:
Error: C:\cvavreval\inc\usart.h(114), #include-d from: hc05.h: undefined symbol 'unsigned'
Error: C:\cvavreval\inc\usart.h(114), #include-d from: hc05.h: undefined symbol 'i'
Error: C:\cvavreval\inc\usart.h(117), #include-d from: hc05.h: undefined symbol 'i'
Error: C:\cvavreval\inc\hc05.h(67), #include-d from: hc1.c: undefined symbol 'unsigned'
Error: C:\cvavreval\inc\hc05.h(67), #include-d from: hc1.c: undefined symbol 'i'
Error: C:\cvavreval\inc\hc05.h(70), #include-d from: hc1.c: undefined symbol 'j'
Error: C:\cvavreval\inc\hc05.h(188), #include-d from: hc1.c: must declare first in block
leon de boer 28-Jun-16 23:25pm    
Same thing the errors are syntax from something earlier ... the keyword "unsigned" is known to every C compiler so the compiler parser has essentially crashed. The first error is at line 67, so the problem is in those first 67 lines. Are there any warnings in the earlier lines???

Don't ignore warnings when you have this sort of error you need to deal with the problems in line order. So our question is what is going wrong in the first 66 lines of USART.H that is causing the problem in line 67. Look at any warnings in those early lines and failing all else post me the first 67 lines of USART.H
shsmszdh 30-Jun-16 7:10am    
I saw those first 66 lines of usart.h but there were no warning for them after I selected build all button !!!!!!!!!!!!!!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900