本文整理汇总了C++中SMPL_Ioctl函数的典型用法代码示例。如果您正苦于以下问题:C++ SMPL_Ioctl函数的具体用法?C++ SMPL_Ioctl怎么用?C++ SMPL_Ioctl使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SMPL_Ioctl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: broadcast_channel_change
/******************************************************************************
* @fn broadcast_channel_change
*
* @brief For Access Point only: broadcast a channel change frame.
*
* input parameters
* @param idx - index into channel table of new (logical) channel
*
* @return none.
*/
#ifdef ACCESS_POINT
#define CC_REDUNDANCY 1 /* Change-channel redundancy count */
static void broadcast_channel_change(uint8_t idx)
{
ioctlRawSend_t send;
uint8_t msg[FREQ_REQ_MOVE_FRAME_SIZE];
uint8_t repeat = CC_REDUNDANCY;
if (idx >= NWK_FREQ_TBL_SIZE)
{
return;
}
msg[FB_APP_INFO_OS] = FREQ_REQ_MOVE;
msg[F_CHAN_OS] = idx;
send.addr = (addr_t *)nwk_getBCastAddress();
send.msg = msg;
send.len = sizeof(msg);
send.port = SMPL_PORT_FREQ;
SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &send);
/* Redundancy addresses the fact that an RE (or any always-listening
* device) might miss the command
*/
while (repeat--)
{
NWK_DELAY(250);
SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &send);
}
}
示例2: channelHandle
/* channel handle
* if appInFrame->msg[0] == 0x00, then get current channel
* if is 0x01, then set current channel
*/
void channelHandle(struct AppFrame* appInFrame, struct AppFrame* appOutFrame)
{
if(appInFrame->len == 0) return;
if(appInFrame->msg[0] == GET)
{
SMPL_Ioctl(IOCTL_OBJ_FREQ, IOCTL_ACT_GET, &channel);
appOutFrame->msg[0] = (channel.logicalChan);
appOutFrame->len = 1;
logTemp[0] = 2;/* the length of logTemp*/
logTemp[1] = SEND_CHANNEL;
log(INFO_OTHER, logTemp);
//log(INFO, "Send channel");
}
else
{
if(appInFrame->msg[0] == SET && appInFrame->len >= 2)
{
channel.logicalChan = appInFrame->msg[1];
SMPL_Ioctl( IOCTL_OBJ_FREQ, IOCTL_ACT_SET, &channel);
appOutFrame->len = 0;
logTemp[0] = 2;/* the length of logTemp*/
logTemp[1] = SET_CHANNEL;
log(INFO_OTHER, logTemp);
//log(INFO, "Set channel");
}
}
return;
}
示例3: main
void main(void)
{
BSP_Init(); // Initialisation de la librairie BSP
NWK_DELAY(500);
SMPL_Init(&RxCallBack); // Initialisation de la librairie simpliciTI
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0); // Activation de la radio pour permettre la réception des messages
COM_Init(); // Initialisation du port COM
while (1)
{
if(broadSem)
{
memset(msg, 0, sizeof(msg));
if ((SMPL_Receive(SMPL_LINKID_USER_UUD, msg, &msgLen)) == SMPL_SUCCESS) // Cette fonction permet de stocker les messages reçu par un périphérique en spécifiant son linkID
{
sigInfo.lid = SMPL_LINKID_USER_UUD; // Permet d'indiquer les informations de quel périphérique sont demandées
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SIGINFO, &sigInfo); // On récupère les informations sur la force de connexion dans la structure sigInfo
msg[5] = 'S';
msg[6] = sigInfo.sigInfo.rssi+128;
msg[7] = 'L';
msg[8] = sigInfo.sigInfo.lqi;
msg[9] = 0xFF;
broadSem--;
TXString(msg, sizeof(msg));
}
}
}
}
示例4: simpliciti_main_tx_only
// *************************************************************************************************
// @fn simpliciti_main_tx_only
// @brief Get data through callback. Transfer data when external trigger is set.
// @param none
// @return none
// *************************************************************************************************
void simpliciti_main_tx_only(void)
{
while (1)
{
// Get end device data from callback function
simpliciti_get_ed_data_callback();
// Send data when flag bit SIMPLICITI_TRIGGER_SEND_DATA is set
if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA))
{
// Get radio ready. Wakes up in IDLE state.
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
// Acceleration / button events packets are 4 bytes long
SMPL_SendOpt(sLinkID1, simpliciti_data, 4, SMPL_TXOPTION_NONE);
// Put radio back to SLEEP state
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);
clearFlag(simpliciti_flag, SIMPLICITI_TRIGGER_SEND_DATA);
}
// Exit when flag bit SIMPLICITI_TRIGGER_STOP is set
if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_STOP))
{
// Clean up SimpliciTI stack to enable restarting
sInit_done = 0;
break;
}
}
}
示例5: simpliciti_main_sync
// *************************************************************************************************
// @fn simpliciti_main_sync
// @brief Send ready-to-receive packets in regular intervals. Listen shortly for host reply.
// Decode received host command and trigger action.
// @param none
// @return none
// *************************************************************************************************
void simpliciti_main_sync(void)
{
uint8_t len, i;
uint8_t ed_data[2];
while (1)
{
// Sleep 0.5sec between ready-to-receive packets
// SimpliciTI has no low power delay function, so we have to use ours
Timer0_A4_Delay(CONV_MS_TO_TICKS(500));
// Get radio ready. Radio wakes up in IDLE state.
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
// Send 2 byte long ready-to-receive packet to stimulate host reply
ed_data[0] = SYNC_ED_TYPE_R2R;
ed_data[1] = 0xCB;
SMPL_SendOpt(sLinkID1, ed_data, 2, SMPL_TXOPTION_NONE);
// Wait shortly for host reply
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
NWK_DELAY(10);
// Check if a command packet was received
while (SMPL_Receive(sLinkID1, simpliciti_data, &len) == SMPL_SUCCESS)
{
// Decode received data
if (len > 0)
{
// Use callback function in application to decode data and react
simpliciti_sync_decode_ap_cmd_callback();
// Get reply data and send out reply packet burst (19 bytes each)
for (i = 0; i < simpliciti_reply_count; i++)
{
NWK_DELAY(10);
simpliciti_sync_get_data_callback(i);
SMPL_SendOpt(sLinkID1, simpliciti_data, BM_SYNC_DATA_LENGTH, SMPL_TXOPTION_NONE);
}
}
}
// Put radio back to sleep
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SLEEP, 0);
// Service watchdog
WDTCTL = WDTPW + WDTIS__512K + WDTSSEL__ACLK + WDTCNTCL;
// Exit when flag bit SIMPLICITI_TRIGGER_STOP is set
if (getFlag(simpliciti_flag, SIMPLICITI_TRIGGER_STOP))
{
// Clean up SimpliciTI stack to enable restarting
sInit_done = 0;
break;
}
}
}
示例6: nwk_poll
/******************************************************************************
* @fn nwk_poll
*
* @brief Poll S&F server for any waiting frames.
*
* input parameters
* @param port - Port on peer.
* @param addr - SimpliciTI address of peer.
*
* output parameters
*
* @return SMPL_SUCCESS
* SMPL_NO_AP_ADDRESS - We don't know Access Point's address
* SMPL_NOMEM - no room in output frame queue
* SMPL_TX_CCA_FAIL - CCA failure
*/
smplStatus_t nwk_poll(uint8_t port, uint8_t *addr)
{
uint8_t msg[MGMT_POLL_FRAME_SIZE];
ioctlRawSend_t send;
msg[MB_APP_INFO_OS] = MGMT_REQ_POLL;
msg[MB_TID_OS] = sTid;
msg[M_POLL_PORT_OS] = port;
memcpy(msg+M_POLL_ADDR_OS, addr, NET_ADDR_SIZE);
/* it's OK to increment the TID here because the reply will not be
* matched based on this number. The reply to the poll comes back
* to the client port, not the Management port.
*/
sTid++;
if (!sAPAddr)
{
sAPAddr = nwk_getAPAddress();
if (!sAPAddr)
{
return SMPL_NO_AP_ADDRESS;
}
}
send.addr = (addr_t *)sAPAddr;
send.msg = msg;
send.len = sizeof(msg);
send.port = SMPL_PORT_MGMT;
return SMPL_Ioctl(IOCTL_OBJ_RAW_IO, IOCTL_ACT_WRITE, &send);
}
示例7: start2Babble
static void start2Babble()
{
uint8_t msg[1];
/* frequency hopping doesn't support sleeping just yet */
#ifndef FREQUENCY_HOPPING
/* wake up radio. */
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_AWAKE, 0);
#endif
/* Send the bad news message. To prevent confusion with different "networks"
* such as neighboring smoke alarm arrays send a token controlled by a DIP
* switch, for example, and filter in this token.
*/
msg[0] = BAD_NEWS;
while (1)
{
FHSS_ACTIVE( nwk_pllBackgrounder( false ) ); /* manage FHSS */
/*wait "a while" */
NWK_DELAY(100);
/* babble... */
SMPL_Send(SMPL_LINKID_USER_UUD, msg, sizeof(msg));
toggleLED(2);
}
}
示例8: Connect
static void Connect(void)
{
Task_t tasks[2];
/* listen for link forever... */
while (1)
{
if (SMPL_SUCCESS == SMPL_LinkListen(&sLinkID2))
{
break;
}
/* Implement fail-to-link policy here. otherwise, listen again. */
}
LedOff(&led_red);
LedOff(&led_green);
/* turn on RX. default is RX off. */
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
TaskLoopCtor(&tasks[0], PingCheckStep);
TaskLoopCtor(&tasks[1], MotorStep);
TaskMasterRun(&tasks, 2); //begin our scheduler.. not coming back
}
示例9: ChangeChannel
//*****************************************************************************
//
// Change to a different SimpliciTI channel number (frequency).
//
//*****************************************************************************
static void ChangeChannel(void)
{
#ifdef FREQUENCY_AGILITY
freqEntry_t sFreq;
//
// Cycle to the next channel, wrapping from the top of the table back
// to the bottom if necessary.
//
if (++g_ucChannel >= NWK_FREQ_TBL_SIZE)
{
g_ucChannel = 0;
}
//
// Set the radio frequency.
//
sFreq.logicalChan = g_ucChannel;
SMPL_Ioctl(IOCTL_OBJ_FREQ, IOCTL_ACT_SET, &sFreq);
//
// Turn both of the "LEDs" off and set the flag we use to tell the main
// loop that it should blink the LEDs until a new message is received from
// an end device.
//
SetLED(1, false);
SetLED(2, false);
g_ulBlinky = 1;
#endif
return;
}
示例10: checkChangeChannel
/* implement auto-channel-change policy here... */
static void checkChangeChannel(void)
{
#ifdef FREQUENCY_AGILITY
int8_t dbm, inARow = 0;
uint8_t i;
memset(sSample, 0x0, SSIZE);
for (i=0; i<SSIZE; ++i)
{
/* quit if we need to service an app frame */
if (sPeerFrameSem || sJoinSem)
{
return;
}
NWK_DELAY(1);
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RSSI, (void *)&dbm);
sSample[i] = dbm;
if (dbm > INTERFERNCE_THRESHOLD_DBM)
{
if (++inARow == IN_A_ROW)
{
changeChannel();
break;
}
}
else
{
inARow = 0;
}
}
#endif
return;
}
示例11: main
void main (void)
{
BSP_Init( );
SET_MAIN_CLOCK_SOURCE(CRYSTAL);
initUART();
printf( "Start iwsn system...\n" );
InitRFIO(); /* set io as normal io, not uart */
//P0DIR &= ~0x03; /* Set button as input */
EnableRecv();
SMPL_Init( NULL );
/* turn on the radio so we are always able to receive data asynchronously */
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, NULL );
/* turn on LED. */
BSP_TURN_ON_LED1( );
BSP_TURN_ON_LED2( );
/* never coming back... */
framework_entry();
/* but in case we do... */
while (1) ;
}
示例12: SMPL_Init
/***********************************************************************************
* @fn SMPL_Init
*
* @brief Initialize the SimpliciTI stack.
*
* input parameters
* @param f - Pointer to call back function. Function called by NWK when
* user application frame received. The callback is done in the
* ISR thread. Argument is Link ID associated with frame. Function
* returns 0 if frame is to be kept by NWK, otherwise 1. Frame
* should be kept if application will do a SMPL_Receive() in the
* user thread (recommended). Pointer may be NULL.
*
* output parameters
*
* @return Status of operation:
* SMPL_SUCCESS
* SMPL_NO_JOIN No Join reply. AP possibly not yet up.
* SMPL_NO_CHANNEL Only if Frequency Agility enabled. Channel scan
* failed. AP possibly not yet up.
*/
smplStatus_t SMPL_Init(uint8_t (*f)(linkID_t))
{
smplStatus_t rc;
if (!sInit_done)
{
/* set up radio. */
MRFI_Init();
/* initialize network */
if ((rc=nwk_nwkInit(f)) != SMPL_SUCCESS)
{
return rc;
}
MRFI_WakeUp();
#if defined( FREQUENCY_AGILITY )
{
freqEntry_t chan;
chan.logicalChan = 0;
/* ok to set default channel explicitly now that MRFI initialized. */
nwk_setChannel(&chan);
}
#endif
/* don't turn Rx on if we're an end device that isn't always on. */
/* but do turn the radio on for PLL operations */
#if !defined( END_DEVICE ) || defined( NWK_PLL )
MRFI_RxOn();
#endif
#if defined( END_DEVICE )
/* All except End Devices are in promiscuous mode */
MRFI_SetRxAddrFilter((uint8_t *)nwk_getMyAddress());
MRFI_EnableRxAddrFilter();
#endif
}
sInit_done = 1;
#ifdef NWK_PLL
/* If the PLL is enabled then it must get running before the join
* request or the system may lock up in the join request becuase
* PLL is not locked in.
*/
// turn on the PLL
SMPL_Ioctl(IOCTL_OBJ_PLL, IOCTL_ACT_ON, NULL);
// reference clocks are by definition always locked.
#ifndef NWK_PLL_REFERENCE_CLOCK
// wait for a 5ms failure rate to be achieved
while( nwk_pllIsLocked( 0 ) == false )
nwk_pllBackgrounder( false );
#endif
#endif
/* Join. if no AP or Join fails that status is returned. */
rc = nwk_join();
return rc;
}
示例13: linkTo
static void linkTo()
{
uint8_t msg[10], delay = 0;
memset(msg, 0, 10);
while (SMPL_SUCCESS != SMPL_Link(&sLinkID1))
{
/* blink LEDs until we link successfully */
toggleLED(1);
toggleLED(2);
SPIN_ABOUT_A_SECOND;
}
/* we're linked. turn off red LED. received messages will toggle the green LED. */
if (BSP_LED2_IS_ON())
{
toggleLED(2);
}
/* turn on RX. default is RX off. */
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
/* put LED to toggle in the message */
msg[0] = 2; /* toggle red */
while (1)
{
__bis_SR_register(LPM4_bits + GIE); // Enter LPM4 w/interrupt
SPIN_ABOUT_A_SECOND;
if (delay > 0x00)
{
SPIN_ABOUT_A_SECOND;
}
if (delay > 0x01)
{
SPIN_ABOUT_A_SECOND;
}
if (delay > 0x02)
{
SPIN_ABOUT_A_SECOND;
}
/* delay longer and longer -- then start over */
delay = (delay+1) & 0x03;
/* put the sequence ID in the message */
msg[9] = ++sTxTid;
ReadRTCCTimeDate(&Rtcctimedate);
/* put data into packet */
msg[1] = Rtcctimedate.Sec;
msg[2] = Rtcctimedate.Min;
msg[3] = Rtcctimedate.Hour;
msg[4] = Rtcctimedate.Day;
msg[5] = Rtcctimedate.Date;
msg[6] = Rtcctimedate.Month;
msg[7] = Rtcctimedate.Year;
SMPL_Send(sLinkID1, msg, sizeof(msg));
}
}
示例14: LinkFrom
//*****************************************************************************
//
// This function listens for a link request from another SimpliciTI device.
//
//*****************************************************************************
tBoolean
LinkFrom(void)
{
smplStatus_t eRetcode;
unsigned long ulCount;
//
// Tell SimpliciTI to try to link to an access point.
//
for(ulCount = 1; ulCount <= 10; ulCount++)
{
//
// Update the displayed count. Note that we must process the widget
// message queue here to ensure that the change makes it onto the
// display.
//
UpdateStatus(false, "Listening %d (%s)", ulCount,
(ulCount > 1) ? MapSMPLStatus(eRetcode) : "Waiting");
WidgetMessageQueueProcess();
//
// Try to link to the access point.
//
eRetcode = SMPL_LinkListen(&sLinkID);
if(eRetcode == SMPL_SUCCESS)
{
break;
}
}
//
// Did we manage to link to the access point?
//
if(eRetcode == SMPL_SUCCESS)
{
UpdateStatus(false, "Listen successful.");
//
// Turn on RX. Default is off.
//
SMPL_Ioctl( IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
//
// Tell the main loop that we established communication successfully.
//
return(true);
}
else
{
UpdateStatus(false, "No link request received.");
//
// Tell the main loop that we failed to establish communication.
//
return(false);
}
}
示例15: linkToRep
void linkToRep() {
// listen for link forever...
while (SMPL_SUCCESS != SMPL_LinkListen(&myLinkID)) {
/* Implement fail-to-link policy here. otherwise, listen again. */
toggleLED(2); // red led
}
/* turn on RX. default is RX off. */
SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_RXON, 0);
}