473,396 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

data transmission from a bluetooth module to computer, need C code help.

hello,

i am trying to write a code in C to transfer my signals from bluetooth to the compuer. I have four signals coming from a sensor unit. 2 AC and 2 DC. In my code I have already read those signals and sampled with AD converter , now when i am sending the data I do not know what should i define in the code. like how to assign values to bytes and pack the data, since im not a prgrammer :( this is my code, i would begrateful if you could give me some hints:
Expand|Select|Wrap|Line Numbers
  1. */
  2.  
  3. //#include <macros.h>
  4. #include <iom32v.h>
  5. #include <mymacros.h>
  6. #include <AdcADS8341Layout.h>
  7. #include <AdcADS8341.h>
  8. #include <Delay.h>
  9. //#include <Uart.h>
  10.  
  11. int main(void)
  12. {
  13.         unsigned int PPG_IR_AC;
  14.         unsigned int PPG_IR_DC;
  15.         unsigned int PPG_R_AC;
  16.         unsigned int PPG_R_DC;
  17.  
  18.     // Insert code
  19.  
  20.     do
  21.     {
  22.  
  23.     // init the port
  24.     // Ex
  25.     DDRD = OUT7 | OUT6 | IN5 | IN4 | IN3 | IN2 | IN1 | IN0;
  26.     SetBitMask(PORTD, BIT6);
  27.  
  28.     //Power On
  29.     SetBit(PORTD,7);
  30.  
  31.  
  32.     while(TRUE)
  33.     {
  34.         PPG_IR_AC = GetAdcADS8341(ADS8344_CH5);
  35.         PPG_IR_DC = GetAdcADS8341(ADS8344_CH6);
  36.         PPG_R_AC = GetAdcADS8341(ADS8344_CH7);
  37.         PPG_R_DC = GetAdcADS8341(ADS8344_CH2);
  38.  
  39.        UartSendByteUB(PPG_IR_AC>>8); // How to send measured data to bluetooth transmitter
  40.        UartSendByteUB(PPG_IR_AC); // How to send measured data to bluetooth transmitter
  41.  
  42.        UartSendByteUB(PPG_IR_DC>>8);
  43.        UartSendByteUB(PPG_IR_DC);
  44.  
  45.        UartSendByteUB(PPG_R_AC>>8);
  46.        UartSendByteUB(PPG_R_AC);
  47.  
  48.        UartSendByteUB(PPG_R_DC>>8);
  49.        UartSendByteUB(PPG_R_DC);
  50.  
  51.  
  52.    Delay(1024, 0.013); // delay
  53.  
  54.  
  55.     }
  56.  
  57.     }while(0);
  58.  
  59.     return 0;
  60. }
Dec 17 '10 #1
3 3756
mac11
256 100+
There's a device discovery procedure that must be done to get the communication channel established. So, your PC needs to have a bluetooth dongle. Is your PC able to see your device? Are you past that initialization part already?

If the PC isn't seeing your embedded device yet you'll have to go to your datasheet/userguide and figure out how to set up bluetooth and make sure both sides work.

#include <iom32v.h> says you've got some AVR chip, does it have bluetooth support embedded in it? (I'm unfamiliar with AVR details).

Once you get bluetooth communication going and the PC can see the embedded device just throw any data at it and make sure you can see it on the PC side. Simple text works well.

Then you're at the point where you need to format your data to be useable on the PC side. Maybe you're there already. You have to decide if you want to send binary data or text based data. There's a good FAQ on the subject at http://www.parashift.com/c++-faq-lit....html#faq-36.2 It's focused on C++, but the basic concept is all you need.

What's the device you're programming and how does the PC side use data it's receiving?

I guess I'm a bit scrambled in my response because I can't tell if you have any communications established already or not.
Dec 17 '10 #2
the pc recognize the bluetooth, and we use labview to recieve the data, but the thing is that i dont know how to send the data , so when it gets into the labview , it will be clear which signal is it. like how to distinguish the signals over there. since its asynchronous data, and 4 signals go in a line of 64 bits (16 each). so i wanna know how can i use a flag or something in my c code for bluetooth while sampling, so when it gets to the computer we can easily speerate them.
Dec 18 '10 #3
mac11
256 100+
Well, as the FAQ states, you have to decide if you want to send data in binary format (as your code does currently), or text format.

I've never used lab view so I can't tell you how to make it recognize your numbers. Is there a certain format that it expects that you need to have your input conform to?
Dec 21 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: G520 | last post by:
GD module – need basic info... Hi All Some stupid questions from a newbe :-) I want to create graphs from int arrays. I'm told I can use the GD module... I have RedHat 9, PHP4 and...
3
by: Mads Petersen | last post by:
I'm stuck in this code. Hope you can and will help me. I launch it from excel. I have made the following code work, but not as i whant. I need the ranges to be working with something like xlDown....
1
by: Aaron | last post by:
I have an asp.net application where I am sucessfully filling a dataset. The DS contains 1 column and multiple rows. I would like to add all of the rows to an array. How is this done? Thanks,...
16
by: pamelafluente | last post by:
I am still working with no success on that client/server problem. I need your help. I will submit simplified versions of my problem so we can see clearly what is going on. My model: A client...
4
by: sara | last post by:
i am studying a computer engineering and i started taking programming using C++ since month i have question i think it`s easy for you all *prof.programmer* but it`s bit diffecult for me plzz i...
6
by: JonathanOrlev | last post by:
Hello everyone, I have a newbe question: In Access (2003) VBA, what is the difference between a Module and a Class Module in the VBA development environment? If I remember correctly, new...
0
by: vennela | last post by:
hi, I am trying to test the serial ports. First i tested using hyper terminals and came to know that hardware is through.While testing through the program in vb.net2005,modem is responding for the...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
0
by: basyarie | last post by:
Dear VB specialist, I need your help for my problem. I wanna get data from our measurement tool called Data Transmission Analyzer from Anritsu company. The model is MD6420A. I want to retrieve it...
1
by: hemanth727 | last post by:
Hi all, In grave trouble. I have to develop an console app which takes the data from the bluetooth dongle and stores it in a text.. now prob is .. i donno how to receive data from bluetooth ( USB...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.