how to convert byte to const char or string

I have use the sample code from ELECHOUSE and modify myself to make two cc1101 RF module with the help of Arduino uno can communication each other. this is the code part

Transmit part:

 #include <ELECHOUSE_CC1101.h>

#define size 4

byte TX_buffer[4]={'C','H','E','N'};
byte i;

void setup()
{
  Serial.begin(9600);
  ELECHOUSE_cc1101.Init();
}

void loop()
{
  ELECHOUSE_cc1101.SendData(TX_buffer,4);
  delay(2000);
}

Receive part:

 #include <ELECHOUSE_CC1101.h>
 
 

 
 void setup()
{
  Serial.begin(9600);
  ELECHOUSE_cc1101.Init();
  ELECHOUSE_cc1101.SetReceive();
}

byte RX_buffer[4]={0};
byte size,i,flag;


void loop()
{
  if(ELECHOUSE_cc1101.CheckReceiveFlag())
  {
    size=ELECHOUSE_cc1101.ReceiveData(RX_buffer);
    for(i=0;i<size;i++)
    {
      Serial.print(RX_buffer[i]);
    }
    Serial.println("");
    ELECHOUSE_cc1101.SetReceive();
  }
}

But I think it is because of the problem of the library problem, when I send out CHEN, the receive direct convert to ASCII form, how can I convert the byte to the string and make me can receive the words not the number? thanks a lot

Moderator edit:
</mark> <mark>[code]</mark> <mark>

</mark> <mark>[/code]</mark> <mark>
tags added.

Where did you get your library? The one I got on their site would not compile.

http://www.electrodragon.com/w/index.php?title=CC1101
I got the library here. but you must do some modify to make it works, but the way I have solved my problem.. :slight_smile: :slight_smile:

mitchellchen:
Category:CC1101 - ElectroDragon
I got the library here. but you must do some modify to make it works, but the way I have solved my problem.. :slight_smile: :slight_smile:

Care to tell us how? It would be good information for the next victim er... programmer. :roll_eyes:

Do you need to convert it to an Arduino String type object, or a C++ "string' (e.g. an array of char)?

This code compiled for me:

byte b = 128;
char c = b;

void setup()
{
}

void loop()
{
}

So it appears that typecasting between byte and char works, although I can't say for 100% sure whether the conversion will be correct. Maybe you could start by simply creating an array of char and copying your byte array over to it.