Ejemplo n.º 1
0
/*! Handle the messages routed to the background task */
static void BackgroundMessageHandler(tHostMsg* pMsg)
{
  tHostMsg* pOutgoingMsg;

  eMessageType Type = (eMessageType)pMsg->Type;

  switch(Type)
  {
  case GetDeviceType:
    BPL_AllocMessageBuffer(&pOutgoingMsg);

    pOutgoingMsg->pPayload[0] = 2; /* DIGITAL_BOARD_TYPE */

    UTL_BuildHstMsg(pOutgoingMsg, GetDeviceTypeResponse, NO_MSG_OPTIONS,
                    pOutgoingMsg->pPayload, sizeof(unsigned char));

    RouteMsg(&pOutgoingMsg);
    break;

  case SetVibrateMode:
    SetVibrateModeHandler(pMsg);
    break;

  case SetRealTimeClock:
    halRtcSet((tRtcHostMsgPayload*)pMsg->pPayload);

    BPL_AllocMessageBuffer(&pOutgoingMsg);
    pOutgoingMsg->Type = IdleUpdate;
    pOutgoingMsg->Options = NO_MSG_OPTIONS;
    RouteMsg(&pOutgoingMsg);

    break;

  default:
    PrintStringAndHex("<<Unhandled Message>> in Background Task: Type 0x", Type);
    break;
  }

}
Ejemplo n.º 2
0
/*! Handle the messages routed to the display queue */
static void DisplayQueueMessageHandler(tMessage* pMsg)
{
  tMessage Msg;
  unsigned char i = 0;

  switch (pMsg->Type)
  {
  case WriteBufferMsg:
    WriteBufferHandler(pMsg);
    break;

  case SetWidgetListMsg:
    SetWidgetList(pMsg);
    break;
  
  case UpdateDisplayMsg:
    UpdateDisplayHandler(pMsg);
    break;
    
  case UpdateClockMsg:
    UpdateClock();
    break;
    
  case DrawClockWidgetMsg:
    DrawClockWidget(pMsg->Options);
    break;

  case MonitorBatteryMsg:
    MonitorBattery();
    break;

  case BluetoothStateChangeMsg:
    BluetoothStateChangeHandler(pMsg);
    break;

  case IdleUpdateMsg:
    IdleUpdateHandler();
    break;

  case ButtonStateMsg:
    ButtonStateHandler();
    break;

  case CallerIdMsg:
//    PrintStringAndDecimal("LcdDisp:CallerId Len:", pMsg->Length);
    pMsg->pBuffer[pMsg->Length] = NULL;
    ShowCall((char *)pMsg->pBuffer, pMsg->Options);
    break;
    
  case CallerNameMsg:
    if (pMsg->Length)
    {
      pMsg->pBuffer[pMsg->Length] = NULL;
      ShowCall((char *)pMsg->pBuffer, SHOW_NOTIF_CALLER_NAME);
    }
    else ShowCall("", pMsg->Options);
    break;

  case MusicPlayStateMsg:
    HandleMusicPlayStateChange(pMsg->Options);
    break;
    
  case ChangeModeMsg:
    ChangeModeHandler(pMsg->Options);
    break;
  
  case ConfigureIdleBufferSize:
    SetProperty(PROP_PHONE_DRAW_TOP, *pMsg->pBuffer ? PROP_PHONE_DRAW_TOP : 0);
    break;

  case ModifyTimeMsg:
    ModifyTimeHandler(pMsg);
    break;

  case MenuModeMsg:
    MenuModeHandler(pMsg->Options);
    break;

  case MenuButtonMsg:
    MenuButtonHandler(pMsg->Options);
    break;

  case EnableButtonMsg:
    EnableButtonMsgHandler(pMsg);
    break;

  case DevTypeMsg:
    SetupMessageAndAllocateBuffer(&Msg, DevTypeRespMsg, MSG_OPT_NONE);
    Msg.Options = BOARD_TYPE; //default G2
    Msg.pBuffer[0] = BOARD_TYPE; // backward compatible

#ifdef WATCH
    if (GetMsp430HardwareRevision() < 'F')
    {
      Msg.Options = DIGITAL_WATCH_TYPE_G1;
      Msg.pBuffer[0] = DIGITAL_WATCH_TYPE_G1; // backward compatible
    }
#endif

    Msg.Length = 1;
    RouteMsg(&Msg);
    PrintStringAndDecimal("- DevTypeResp:", Msg.pBuffer[0]);
    break;

  case VerInfoMsg:
    SetupMessageAndAllocateBuffer(&Msg, VerInfoRespMsg, MSG_OPT_NONE);

    /* exclude middle '.' */
    strncpy((char *)Msg.pBuffer, BUILD, 3);
    strncpy((char *)Msg.pBuffer + 3, BUILD + 4, 3);
    Msg.Length += strlen(BUILD) - 1;
      
    *(Msg.pBuffer + Msg.Length++) = (unsigned char)atoi(VERSION);
    
    while (VERSION[i++] != '.');
    *(Msg.pBuffer + Msg.Length++) = atoi(VERSION + i);
    *(Msg.pBuffer + Msg.Length++) = NULL;
    
    RouteMsg(&Msg);
    
    PrintString("-Ver:"); for (i = 6; i < Msg.Length; ++i) PrintHex(Msg.pBuffer[i]);
    break;
    
  case SetVibrateMode:
    SetVibrateModeHandler(pMsg);
    break;

  case SetRtcMsg:
    halRtcSet((tRtcHostMsgPayload*)pMsg->pBuffer);

#ifdef DIGITAL
    UpdateClock();
#endif
    break;

  case GetRtcMsg:
    SetupMessageAndAllocateBuffer(&Msg, RtcRespMsg, MSG_OPT_NONE);
    halRtcGet((tRtcHostMsgPayload*)Msg.pBuffer);
    Msg.Length = sizeof(tRtcHostMsgPayload);
    RouteMsg(&Msg);
    break;

  case ServiceMenuMsg:
    ServiceMenuHandler();
    break;
    
  case DisableButtonMsg:
    DisableButtonMsgHandler(pMsg);
    break;

  case ReadButtonConfigMsg:
    ReadButtonConfigHandler(pMsg);
    break;

  case LedChange:
    LedChangeHandler(pMsg);
    break;

  case BatteryConfigMsg:
    SetBatteryLevels(pMsg->pBuffer);
    break;

  case ReadBatteryVoltageMsg:
    ReadBatteryVoltageHandler();
    break;

  case ResetMsg:
    SoftwareResetHandler(pMsg);
    break;

  case NvalOperationMsg:
    NvalOperationHandler(pMsg);
    break;

  case SecInvertMsg:
    HandleSecInvert(pMsg->Options);
    break;

  case LoadTemplateMsg:
    LoadTemplateHandler(pMsg);
    break;

  case LinkAlarmMsg:
    if (!GetProperty(PROP_DISABLE_LINK_ALARM))
    {
      SetupMessageAndAllocateBuffer(&Msg, SetVibrateMode, MSG_OPT_NONE);
      tSetVibrateModePayload* pMsgData;
      pMsgData = (tSetVibrateModePayload *)Msg.pBuffer;
      
      pMsgData->Enable = 1;
      pMsgData->OnDurationLsb = 0xC8;
      pMsgData->OnDurationMsb = 0x00;
      pMsgData->OffDurationLsb = 0xF4;
      pMsgData->OffDurationMsb = 0x01;
      pMsgData->NumberOfCycles = 1; //3
      
      RouteMsg(&Msg);
    }
    break;

  case ModeTimeoutMsg:
    ModeTimeoutHandler();
    break;

  case WatchStatusMsg:
    PageType = PAGE_TYPE_INFO;
    CurrentPage[PageType] = StatusPage;
    DrawWatchStatusScreen();
    break;

//  case ListPairedDevicesMsg:
//    ListPairedDevicesHandler();
//    break;

  case WatchDrawnScreenTimeout:
    IdleUpdateHandler();
    break;

  case TermModeMsg:
    TermModeHandler();
    break;
    
  case LowBatteryWarningMsg:
    break;
    
  case LowBatteryBtOffMsg:
    UpdateClock();
    break;

#if __IAR_SYSTEMS_ICC__
  case EraseTemplateMsg:
    EraseTemplateHandler(pMsg);
    break;
    
  case WriteToTemplateMsg:
    WriteToTemplateHandler(pMsg);
    break;
#endif

  case EnableAccelerometerMsg:
  case DisableAccelerometerMsg:
  case AccelerometerSendDataMsg:
  case AccelerometerAccessMsg:
  case AccelerometerSetupMsg:

    HandleAccelerometer(pMsg);
    break;

  case ReadLightSensorMsg:
    ReadLightSensorHandler();
    break;

  case RateTestMsg:
    SetupMessageAndAllocateBuffer(&Msg, DiagnosticLoopback, MSG_OPT_NONE);
    /* don't care what data is */
    Msg.Length = 10;
    RouteMsg(&Msg);
    break;
    
  case RamTestMsg:
    RamTestHandler(pMsg);
    break;
    
  default:
    PrintStringAndHexByte("# Disp Msg: 0x", pMsg->Type);
    break;
  }
}
Ejemplo n.º 3
0
/*! Handle the messages routed to the background task */
static void BackgroundMessageHandler(tMessage* pMsg)
{
  tMessage OutgoingMsg;

  switch(pMsg->Type)
  {
  case SetCallbackTimerMsg:
    SetCallbackTimerHandler(pMsg);
    break;

  case GetDeviceType:
    SetupMessageAndAllocateBuffer(&OutgoingMsg,
                                  GetDeviceTypeResponse,
                                  NO_MSG_OPTIONS);

    OutgoingMsg.pBuffer[0] = BOARD_TYPE;
    OutgoingMsg.Length = 1;
    RouteMsg(&OutgoingMsg);
    break;

  case AdvanceWatchHandsMsg:
    AdvanceWatchHandsHandler(pMsg);
    break;

  case SetVibrateMode:
    SetVibrateModeHandler(pMsg);
    break;

  case SetRealTimeClock:
    halRtcSet((tRtcHostMsgPayload*)pMsg->pBuffer);

#ifdef DIGITAL
    SetupMessage(&OutgoingMsg,IdleUpdate,NO_MSG_OPTIONS);
    RouteMsg(&OutgoingMsg);
#endif
    break;

  case GetRealTimeClock:
    SetupMessageAndAllocateBuffer(&OutgoingMsg,
                                  GetRealTimeClockResponse,
                                  NO_MSG_OPTIONS);

    halRtcGet((tRtcHostMsgPayload*)OutgoingMsg.pBuffer);
    OutgoingMsg.Length = sizeof(tRtcHostMsgPayload);
    RouteMsg(&OutgoingMsg);
    break;

  case EnableButtonMsg:
    EnableButtonMsgHandler(pMsg);
    break;

  case DisableButtonMsg:
    DisableButtonMsgHandler(pMsg);
    break;

  case ReadButtonConfigMsg:
    ReadButtonConfigHandler(pMsg);
    break;

  case BatteryChargeControl:

#ifdef DIGITAL
    /* update the screen if there has been a change in charging status */
    if ( BatteryChargingControl() )
    {
      SetupMessage(&OutgoingMsg, IdleUpdate, NO_MSG_OPTIONS);
      RouteMsg(&OutgoingMsg);
    }
#endif

    BatterySenseCycle();
    LowBatteryMonitor();

#ifdef TASK_DEBUG
    UTL_FreeRtosTaskStackCheck();
#endif

#if 0
    LightSenseCycle();
#endif

    break;

  case LedChange:
    LedChangeHandler(pMsg);
    break;

  case BatteryConfigMsg:
    SetBatteryLevels(pMsg->pBuffer);
    break;

  case ReadBatteryVoltageMsg:
    ReadBatteryVoltageHandler();
    break;

  case ReadLightSensorMsg:
    ReadLightSensorHandler();
    break;

  case SoftwareResetMsg:
    SoftwareResetHandler(pMsg);
    break;

  case NvalOperationMsg:
    NvalOperationHandler(pMsg);
    break;

  case GeneralPurposeWatchMsg:
    /* insert handler here */
    break;

  case ButtonStateMsg:
    ButtonStateHandler();
    break;

  /*
   * Accelerometer Messages
   */
  case AccelerometerEnableMsg:
    AccelerometerEnable();
    break;

  case AccelerometerDisableMsg:
    AccelerometerDisable();
    break;

  case AccelerometerSendDataMsg:
    AccelerometerSendDataHandler();
    break;

  case AccelerometerAccessMsg:
    AccelerometerAccessHandler(pMsg);
    break;

  case AccelerometerSetupMsg:
    AccelerometerSetupHandler(pMsg);
    break;

  /*
   *
   */
  case RateTestMsg:
    SetupMessageAndAllocateBuffer(&OutgoingMsg,DiagnosticLoopback,NO_MSG_OPTIONS);
    /* don't care what data is */
    OutgoingMsg.Length = 10;
    RouteMsg(&OutgoingMsg);
    break;

  /*
   *
   */
  default:
    PrintStringAndHex("<<Unhandled Message>> in Background Task: Type 0x", pMsg->Type);
    break;
  }

}