pev_cm_mnbc_sound.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*====================================================================*
  2. *
  3. * Copyright (c) 2013 Qualcomm Atheros, Inc.
  4. *
  5. * All rights reserved.
  6. *
  7. *====================================================================*/
  8. /*====================================================================*
  9. *
  10. * signed pev_cm_mnbc_sound (struct session * session, struct channel * channel, struct message * message);
  11. *
  12. * slac.h
  13. *
  14. * As HLE-PEV send cm_mnbc_sound indications unicast to the
  15. * MSOUND_TARGET address recorded in the session variable;
  16. *
  17. * a brief delay of a few milliseconds is needed between msounds
  18. * so that EVSE-PLC has time to forward CM_MNBC_SOUND.IND and
  19. * CM_ATTEN_PROFILE.IND to EVSE-HLE; session.timer controls this
  20. * delay;
  21. *
  22. *--------------------------------------------------------------------*/
  23. #ifndef PEV_CM_MNBC_SOUND_SOURCE
  24. #define PEV_CM_MNBC_SOUND_SOURCE
  25. #include <string.h>
  26. #include <errno.h>
  27. #include "../ether/channel.h"
  28. #include "../tools/memory.h"
  29. #include "../tools/error.h"
  30. #include "../tools/timer.h"
  31. #include "../slac/slac.h"
  32. signed pev_cm_mnbc_sound (struct session * session, struct channel * channel, struct message * message)
  33. {
  34. struct cm_mnbc_sound_indicate * indicate = (struct cm_mnbc_sound_indicate *) (message);
  35. signed sound = session->NUM_SOUNDS;
  36. while (sound--)
  37. {
  38. debug (0, __func__, "--> CM_MNBC_SOUND.IND");
  39. memset (message, 0, sizeof (* message));
  40. EthernetHeader (& indicate->ethernet, session->MSOUND_TARGET, channel->host, channel->type);
  41. HomePlugHeader1 (& indicate->homeplug, HOMEPLUG_MMV, (CM_MNBC_SOUND | MMTYPE_IND));
  42. indicate->APPLICATION_TYPE = session->APPLICATION_TYPE;
  43. indicate->SECURITY_TYPE = session->SECURITY_TYPE;
  44. memcpy (indicate->MSVarField.SenderID, session->PEV_ID, sizeof (indicate->MSVarField.SenderID));
  45. indicate->MSVarField.CNT = sound;
  46. memcpy (indicate->MSVarField.RunID, session->RunID, sizeof (indicate->MSVarField.RunID));
  47. memset (indicate->MSVarField.RND, 0, sizeof (indicate->MSVarField.RND));
  48. if (sendmessage (channel, message, sizeof (* indicate)) <= 0)
  49. {
  50. return (debug (1, __func__, CHANNEL_CANTSEND));
  51. }
  52. SLEEP (session->pause);
  53. }
  54. return (0);
  55. }
  56. #endif