i bought a DIY project an it has this coding can somebody explain that waht does this code do. i have knowledge of C and C++ just haven't worked on MatlaB before. the project is to read an sms using AT commands and then processing it through an avr kit since i am unaware of matlab programming i need to understand what does this particular code do and how to implement it in matlab as i am getting a error saying(undefined bluetooth)
while(1)
flag1=0;
flag2=0;
i=0;
j=1;
count=0;
fwrite(bluetooth,65)
fwrite(bluetooth,84)
fwrite(bluetooth,43)
fwrite(bluetooth,67)
fwrite(bluetooth,77)
fwrite(bluetooth,71)
fwrite(bluetooth,76)
fwrite(bluetooth,61)
fwrite(bluetooth,34)
fwrite(bluetooth,82)
fwrite(bluetooth,69)
fwrite(bluetooth,67)
fwrite(bluetooth,32)
fwrite(bluetooth,85)
fwrite(bluetooth,78)
fwrite(bluetooth,82)
fwrite(bluetooth,69)
fwrite(bluetooth,65)
fwrite(bluetooth,68)
fwrite(bluetooth,34)
fwrite(bluetooth,13)
a=fread(bluetooth,1)
if(a==13)
a=fread(bluetooth,1)
if(a==10)
28
while(flag1==0)
a=fread(bluetooth,1)
if(a==79)
count=count+1
end
if(a==75)
count=count+1
end
if(a==10)
flag1=1
end
end
end
end
if(count~=2)
while(flag2==0)
a=fread(bluetooth,1)
i=i+1;
if(j>0)
fopen(pc_uc)
j=j-1;
end
fwrite(pc_uc,a)
if(a==13)
flag2=1
end
end
for i=1:7
a=fread(bluetooth,1)
end
fclose(bluetooth)
fclose(pc_uc)
fopen(bluetooth)
end
end
It's not very pretty code, but here's what it does, as far as I can tell:
Send the SMS command :
AT+CMGL="REC UNREAD"
Check for carriage return, <CR>
(ASCII code 13)
<LF>
(ASCII code 10) OK
or a <LF>
. OK
, copy data to pc_us
(no idea what that is) until it hits a <CR>
in bluetooth
, read a few extra bytes from bluetooth
(clearing a buffer?), then close and r-open bluetooth
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.