Simulated the CD changer of a Saab to implement a bluetooth connection to the car stereo. Control of playback device (phone) with steering wheel buttons. Needs a RN52 bluetooth transciever and a CAN transiever. So far only audio playback and control via steering wheel buttons implemented. Hands free calling planned.

Dependencies:   mbed

RN52.h

Committer:
petter
Date:
2016-01-14
Revision:
7:2df2c6e8c0df
Parent:
6:c454f88524d6
Child:
8:beb6c399490a

File content as of revision 7:2df2c6e8c0df:

#ifndef RN52_H
#define RN52_H

typedef enum
{
    RN52_REBOOT,
    RN52_GETSTATUS,
    RN52_ASSISTANT,
    RN52_CALLER_ID,
    RN52_TRACK_METADATA,

    RN52_COMMAND_LAST
  
} RN52_COMMAND;


typedef enum
{
    RN52_LIMBO,
    RN52_CONNECTABLE,
    RN52_CONNECTABLE_DISCOVERABLE,
    RN52_CONNECTED,
    RN52_OUTGOING_CALL,
    RN52_INCOMING_CALL,
    RN52_ACTIVE_CALL,
    RN52_TEST_MODE,
    RN52_THREE_WAY_CALL_WAITING,
    RN52_THREE_WAY_CALL_ON_HOLD,
    RN52_THREE_WAY_CALL_MULTI_CALL,
    RN52_INCOMING_CALL_ON_HOLD,
    RN52_ACTIVE_CALL2,
    RN52_AUDIO_STREAMING,
    RN52_LOW_BATTERY,

    RN52_CONNECTION_LAST
  
} RN52_CONNECTION;


typedef enum
{
    RN52_NO_EVENT,
    RN52_CALLER_ID_EVENT,
    RN52_TRACK_CHANGE_EVENT,
    RN52_OTHER_EVENT,

    RN52_EVENT_LAST
  
} RN52_EVENT;

typedef struct
{
    RN52_EVENT event;
    bool media_connected;
    bool phone_connected;
    RN52_CONNECTION connection;
    char title[255];
    char artist[255];
    char album[255];
    char genre[255];
    int duration;
    int track_number;
    int track_count;
    char response[255];
    
} RN52_RESULT;




//----------------------------------------------------------------------------
// CLASS
//----------------------------------------------------------------------------

class RN52
{
public:
    void init();
    bool check_event(RN52_RESULT * rn52_result);
    bool connect();
    bool disconnect();
    bool next_track();
    bool prev_track();
    bool toggle_play();
    bool maxvolume();
    bool get(RN52_COMMAND cmd, RN52_RESULT * rn52_result);  
    bool capture_response(char * str);
    void clear_serial();
    void copy_response(char * source, char * destination, char offset);      
    void clear_result(RN52_RESULT * result);
};

#endif