📄 network.c
字号:
{
/* Note new poll period */
u16PollPeriod = u16Period;
/* Is polling being turned off ? */
if (u16PollPeriod == 0)
{
/* Stop the running timer */
u16PollTimer = 0;
}
else
{
/* Set the timer to a small value to poll soon */
u16PollTimer = 5;
}
/* Network debugging */
#if NETWORK_DEBUG
if (bUartUp)
{
vPrintf("eNetwork_PollPeriod(%d)\n",
u16PollPeriod);
}
#endif
}
}
/****************************************************************************/
/*** Public network data access functions ***/
/****************************************************************************/
PUBLIC uint16 u16Network_PollPeriod (void) { return u16PollPeriod; }
PUBLIC bool_t bNetwork_Up (void) { return bNetworkUp; }
PUBLIC bool_t bNetwork_UartUp (void) { return bUartUp; }
PUBLIC teJenieDeviceType eNetwork_DeviceType (void) { return eDeviceType; }
PUBLIC uint64 u64Network_LastRxAddress (void) { return u64LastRxAddress; }
/****************************************************************************/
/*** Public service functions ***/
/****************************************************************************/
/****************************************************************************
*
* NAME vNetwork_Service_Mask
*/
/*!
*\DESCRIPTION Calculate bitmask for a service.
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC uint32 u32Network_Service_Mask (uint8 u8Service) /**< Service to calculate bitmask for */
{
uint32 u32Service = 0;
if (u8Service >= 1 && u8Service <= 32)
{
u32Service = ((uint32) 1 << (u8Service - 1));
}
return u32Service; /**< \return Bitmask for service. */
}
/****************************************************************************
*
* NAME bNetwork_Source_Bound
*/
/*!
*\DESCRIPTION Get source service is bound flag
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC bool_t bNetwork_Source_Bound (
uint8 u8Source) /**< Source service to get bound flag for. */
{
bool_t bReturn = FALSE;
/* Valid source ? */
if (u8Source > 0)
{
/* Have we bound to any destination services ? */
if (asServices[u8Source].u32Ready != 0)
{
/* Set bound */
bReturn = TRUE;
}
}
return bReturn; /**! \return TRUE when source service is bound from. */
}
/****************************************************************************
*
* NAME eNetwork_Sources_Enabled
*/
/*!
*\DESCRIPTION Set binding enabled for source services
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Sources_Enabled (
uint8 u8Source, /**< Source service to set bind enabled for. */
uint32 u32Destinations, /**< Destination services to set bind enabled for. */
bool_t bEnabled) /**< Binding enabled for source services */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Valid source ? */
if (u8Source > 0)
{
/* Set enable */
eReturn = eNetwork_Services_Enabled(u8Source, u32Destinations, bEnabled);
}
return eReturn; /**! \return E_JENIE_SUCCESS when valid services specified. */
}
/****************************************************************************
*
* NAME eNetwork_Source_Enabled
*/
/*!
*\DESCRIPTION Set binding enabled for source service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Source_Enabled (
uint8 u8Source, /**< Source service to set bind enable for. */
uint8 u8Destination, /**< Destination services to set bind enable for. */
bool_t bEnabled) /**< Binding anable for source service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Valid source ? */
if (u8Source > 0)
{
/* Set enable */
eReturn = eNetwork_Services_Enabled(u8Source, u32Network_Service_Mask(u8Destination), bEnabled);
}
return eReturn; /**! \return E_JENIE_SUCCESS when valid services specified. */
}
/****************************************************************************
*
* NAME bNetwork_Source_Enabled
*/
/*!
*\DESCRIPTION Get binding enabled for source service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC bool_t bNetwork_Source_Enabled (
uint8 u8Source, /**< Source service to get bind enable for. */
uint8 u8Destination) /**< Destination services to get bind enable for. */
{
bool_t bReturn = FALSE;
/* Valid source ? */
if (u8Source > 0)
{
/* Set enable */
bReturn = bNetwork_Service_Enabled(u8Source, u8Destination);
}
return bReturn; /**! \return TRUE when valid source service is enabled. */
}
/****************************************************************************
*
* NAME eNetwork_Sources_Limit
*/
/*!
*\DESCRIPTION Set maximum bindings for source services
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Sources_Limit (
uint8 u8Source, /**< Source service to set bind limit for. */
uint32 u32Destinations, /**< Destination services to set bind limit for. */
uint8 u8Limit) /**< Maximum bindings for service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Valid source ? */
if (u8Source > 0)
{
/* Set limit */
eReturn = eNetwork_Services_Limit(u8Source, u32Destinations, u8Limit);
}
return eReturn; /**! \return E_JENIE_SUCCESS when valid services specified. */
}
/****************************************************************************
*
* NAME eNetwork_Source_Limit
*/
/*!
*\DESCRIPTION Set maximum bindings for a source service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Source_Limit (
uint8 u8Source, /**< Source service to set bind limit for. */
uint8 u8Destination, /**< Destination service to set bind limit for. */
uint8 u8Limit) /**< Maximum bindings for service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Valid source ? */
if (u8Source > 0)
{
/* Set limit */
eReturn = eNetwork_Service_Limit(u8Source, u8Destination, u8Limit);
}
return eReturn; /**! \return E_JENIE_SUCCESS when valid service specified. */
}
/****************************************************************************
*
* NAME u8Network_Source_Limit
*/
/*!
*\DESCRIPTION Get maximum bindings for a source service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC uint8 u8Network_Source_Limit (
uint8 u8Source, /**< Source service to get bind limit for. */
uint8 u8Destination) /**< Destination service to get bind limit for. */
{
uint8 u8Return = 0;
/* Valid source ? */
if (u8Source > 0)
{
/* Get limit */
u8Return = u8Network_Service_Limit(u8Source, u8Destination);
}
return u8Return; /**! \return Current binding limit for service. */
}
/****************************************************************************
*
* NAME u8Network_Source_Count
*/
/*!
*\DESCRIPTION Get current bindings for a source service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC uint8 u8Network_Source_Count (
uint8 u8Source, /**< Source service to get bind count for. */
uint8 u8Destination) /**< Destination service to get bind count for. */
{
uint8 u8Return = 0;
/* Valid source ? */
if (u8Source > 0)
{
/* Get count */
u8Return = u8Network_Service_Count(u8Source, u8Destination);
}
return u8Return; /**! \return Current binding count for service. */
}
/****************************************************************************
*
* NAME bNetwork_Destination_Bound
*/
/*!
*\DESCRIPTION Get destination service is bound flag
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC bool_t bNetwork_Destination_Bound (
uint8 u8Destination) /**< Destination service to get bound flag for. */
{
bool_t bReturn = FALSE;
/* Valid destinaiton ? */
if (u8Destination >= 1 && u8Destination <= 32)
{
/* Have any source services bound to us ? */
if (asServices[0].au8Count[u8Destination-1] > 0)
{
/* Set bound */
bReturn = TRUE;
}
}
return bReturn; /**! \return TRUE when destinaiton service is bound to. */
}
/****************************************************************************
*
* NAME eNetwork_Destinations_Enabled
*/
/*!
*\DESCRIPTION Set binding enabled for destination services
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Destinations_Enabled (
uint32 u32Destinations, /**< Destination services to set bind enable for. */
bool_t bEnabled) /**< Bindings enabled for destination services */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Set enable */
eReturn = eNetwork_Services_Enabled(0, u32Destinations, bEnabled);
return eReturn; /**! \return E_JENIE_SUCCESS when valid services specified. */
}
/****************************************************************************
*
* NAME bNetwork_Destination_Enabled
*/
/*!
*\DESCRIPTION Get binding enabled for destination service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC bool_t bNetwork_Destination_Enabled (
uint8 u8Destination) /**< Destination services to get bind enable for. */
{
bool_t bReturn = FALSE;
/* Get enable */
bReturn = bNetwork_Service_Enabled(0, u8Destination);
return bReturn; /**! \return TRUE when valid destination service is enabled. */
}
/****************************************************************************
*
* NAME eNetwork_Destination_Enabled
*/
/*!
*\DESCRIPTION Set binding enabled for destination service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Destination_Enabled (
uint8 u8Destination, /**< Destination services to set bind enable for. */
bool_t bEnabled) /**< Maximum bindings for destination service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Set enable */
eReturn = eNetwork_Services_Enabled(0, u32Network_Service_Mask(u8Destination), bEnabled);
return eReturn; /**! \return E_JENIE_SUCCESS when valid service specified. */
}
/****************************************************************************
*
* NAME eNetwork_Destinations_Limit
*/
/*!
*\DESCRIPTION Set maximum bindings for destination services
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Destinations_Limit (
uint32 u32Destinations, /**< Destination services to set bind limit for. */
uint8 u8Limit) /**< Maximum bindings for service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Set limit */
eReturn = eNetwork_Services_Limit(0, u32Destinations, u8Limit);
return eReturn; /**! \return E_JENIE_SUCCESS when valid services specified. */
}
/****************************************************************************
*
* NAME eNetwork_Destination_Limit
*/
/*!
*\DESCRIPTION Set maximum bindings for a destination service
*/
/* RETURNS:
* None
*
****************************************************************************/
PUBLIC teJenieStatusCode eNetwork_Destination_Limit (
uint8 u8Destination, /**< Destination service to set bind limit for. */
uint8 u8Limit) /**< Maximum bindings for service */
{
teJenieStatusCode eReturn = E_JENIE_ERR_INVLD_PARAM;
/* Set limit */
eReturn = eNetwork_Service_Limit(0, u8Destination, u8Limit);
return eReturn; /**! \return E_JENIE_SUCCESS when valid service specified. */
}
/****************************************************************************
*
* NAME u8Network_Destination_Limit
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -