Skip to content

Variables set based on module state

Tomáš Kováčik edited this page Dec 2, 2018 · 3 revisions

Main code should periodically check buffer of serial port communicating with module to catch any event sent from module which define module state(by calling BT.getNextEventFromBT()), here is list of variables and available values and that they mean.

Avalaible variables

  • BTState
  • CallState
  • MusicState
  • PowerState
  • InputSelected
  • MusicMode
  • currentVolume
  • NumberOfSongs
  • CurrentlyPlayingSong
  • CurrentFrequency
  • CurrentPreset

Getting variable value

All of these variables are accessible from main code, check code in example folder:

 if (BTState != BT.BTState) {
    printBTstate();
    BTState = BT.BTState;
  }

  if (CallState != BT.CallState) {
    printCallState();
    CallState = BT.CallState;
  }

  if (MusicState != BT.MusicState) {
    printMusicState();
    MusicState = BT.MusicState;
  }

  if (PowerState != BT.PowerState) {
    printPowerState();
    PowerState = BT.PowerState;
  }

  if (InputSelected != BT.InputSelected) {
    printInputSelected();
    InputSelected = BT.InputSelected;
  }

  if (MusicMode != BT.MusicMode) {
    printMusicMode();
    MusicMode = BT.MusicMode;
  }

  if (CurrentFrequency != BT.CurrentFrequency) {
    printCurrentFreqency();
    CurrentFrequency = BT.CurrentFrequency;
  }

  if (CurrentPreset != BT.CurrentPreset) {
    printCurrentPreset();
    CurrentPreset = BT.CurrentPreset;
  }

  if (currentVolume != BT.currentVolume) {
    printCurrentVolume();
    currentVolume = BT.currentVolume;
}

State of bluetooth

State of bluetooth is indicated by variable BTState (uint16_t) which can be one of these:

  • CallInProgress
  • Connected
  • Connecting
  • Disconnected
  • IncomingCall
  • OutgoingCall
  • Pairing

State of call

State of call is indicated by variable CallState (uint16_t) which can be one of these:

  • Busy
  • Idle
  • IncomingCall
  • OutgoingCall

State of music

State of music is indicated by variable MusicState (uint16_t) which can be one of these:

  • Idle
  • Playing

power state

If module is on or off is indicated by variable PowerState (uint16_t) which can be one of these:

  • PowerState
  • PowerState

selected input

Selected input is indicated by variable InputSelected (uint16_t) which can be one of these:

  • AUX
  • BT
  • FM
  • SD
  • USB

Play mode

Current play mode is indicated by variable ModeOfPlay (uint16_t) which can be one of these:

  • RepeatAll
  • RepeatNone
  • RepeatOne

Current volume level

Current volume is hold in variale currentVolume (uint16_t), values are from 0 to 15;

Number of songs

In mp3(USB) or TF (sdcard) mode number of songs on driver/card is in variable NumberOfSongs (uint16_t).

Number of played song

In mp3(USB) or TF (sdcard) mode number of song currently played is stored in variable CurrentlyPlayingSong (uint16_t).

Current frequency

In FM mode current tuned freq is stored in variable CurrentFrequency (uint16_t).

Current Preset

In FM mode, if preset is used to tune radio, this used preset is stored in variable CurrentPreset (uint8_t).

Caller number

(where did I get this? it's not in datasheet!)

Caller number is stored in CallerID variable (String), automaticaly stored when call is in progress, module sent event over serial(which one???) with number and variable is set based on data sent over serial

Bluetooth address

If requested (by calling function getAddress()) module send data to MCU (AD:191919191919\r\n) this contain blue-tooth address '191919191919' which is parsed by calling function getNextEventFromBT() which parse this data and store address in variable BT_ADDR as string.

Bluetooth name

If requested (by calling function getName()) module send data to MCU (NA:BK3254\r\n) this contain blue-tooth name 'BK3254' which is parsed by calling function getNextEventFromBT() which parse this data and store blue-tooth name in variable BT_NAME as string.

Pin

If requested (by calling function getPinCode()) module send data to MCU (PN:0000\r\n) this contain pin code '0000' which is parsed by calling function getNextEventFromBT() which parse this data and store pin code in variable BT_PIN as string.