//***************************************************************************** // // Send a request to the RNP to enable receive. // // \param ui32Duration the length of time in milliseconds to enable the // receiver. Must be between 1 and 0xFFFE or \b RTI_RX_ENABLE_OFF or // \b RTI_RX_ENABLE_ON. // // This function sends a request to the RNP to turn on the receiver for the // specified duration of time. // // \note This is an asynchronous request. // // \sa RTI_RxEnableCnf() // // \return None. // //***************************************************************************** void RTI_RxEnableReq(uint32_t ui32Duration) { tRemoTIMsg sMsg; uint8_t* pui8Tmp; // // Case the duration value to a byte pointer to enable endian swapping. // pui8Tmp = (uint8_t *) &ui32Duration; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_RX_ENABLE_REQ; sMsg.ui8Length = 4; sMsg.pui8Data[0] = pui8Tmp[3]; sMsg.pui8Data[1] = pui8Tmp[2]; sMsg.pui8Data[2] = pui8Tmp[1]; sMsg.pui8Data[3] = pui8Tmp[0]; // // Send the Message. // NPI_SendAsynchData(&sMsg); }
/************************************************************************************************** * * @fn RTI_InitReq * * @brief This API is used to initialize the RemoTI stack and begin * network operation. A RemoTI confirmation callback is generated * and handled by the client. * * The first thing this function does is take a snapshot of the * Configuration Parameters (CP) table stored in NV memory, and * only the snapshot will be used by RTI until another call is made * to this function (presumably due to a reset). Therefore, any * changes to the CP table must be made prior to calling this * function. Once the RTI is started, subsequent changes by the * client to the CP table can be made, but they will have no affect * on RTI operation. The CP table is stored in NV memory and will * persist across a device reset. The client can restore the * the CP table to its default settings by setting the Startup * Option parameter accordingly. * * The client's confirm callback will provide a status, which can * be one of the following: * * RTI_SUCCESS * RTI_ERROR_INVALID_PARAMTER * RTI_ERROR_UNSUPPORTED_ATTRIBUTE * RTI_ERROR_INVALID_INDEX * * input parameters * * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_InitReq( void ) { npiMsgData_t pMsg; // prep Init request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_INIT_REQ; pMsg.len = 0; // send Init request to NP RTIS asynchronously as a confirm is due back NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_AllowPairAbortReq * * @brief This API is used to attempt to abort an on-going allow-pairing process. * * It is possible that allow pair is at a state of no return (no aborting). * There is no callback associated to this function call. * * input parameters * * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_AllowPairAbortReq( void ) { npiMsgData_t pMsg; // prep Pair request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_ALLOW_PAIR_ABORT_REQ; pMsg.len = 0; // send Pair request to NP RTIS asynchronously as a confirm is due back NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_EnableSleepReq * * @brief This API is used to enable sleep on the target. * * input parameters * * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_EnableSleepReq( void ) { npiMsgData_t pMsg; // prep Enable Sleep request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_ENABLE_SLEEP_REQ; pMsg.len = 0; // send Enable Sleep request to NP RTIS asynchronously NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_UnpairReq * * @brief This API is used to trigger un-pairing of a pair entry * * input parameters * * @param dstIndex - destination index * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_UnpairReq( uint8 dstIndex ) { npiMsgData_t pMsg; // prep Pair request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_UNPAIR_REQ; pMsg.len = 1; pMsg.pData[0] = dstIndex; // send Pair request to NP RTIS asynchronously as a confirm is due back NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_StandbyReq * * @brief This API is used by the Target client to place this node into * standby mode. Th properties of the standby consist of the active * period and the duty cycle. These values are set in the * Configuration Parameters table using the RTI_WriteItemReq API, * and go into effect when standby is enabled for this node. * * input parameters * * @param mode - RTI_STANDBY_ON, RTI_STANDBY_OFF * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_StandbyReq( uint8 mode ) { npiMsgData_t pMsg; // prep Standby request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_STANDBY_REQ; pMsg.len = 1; pMsg.pData[0] = mode; // send Standby request to NP RTIS asynchronously as a confirm is due back NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_RxEnableReq * * @brief This API is used to enable the radio receiver, enable the radio * receiver for a specified amount of time, or disable the radio * receiver. * * input parameters * * @param duration - RTI_RX_ENABLE_ON, RTI_RX_ENABLE_OFF, 1..0xFFFE * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_RxEnableReq( uint16 duration ) { npiMsgData_t pMsg; // prep Rx Enable request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_RX_ENABLE_REQ; pMsg.len = 4; RTI_SET_ITEM_WORD( &pMsg.pData[0], (duration & 0x00FFFFFF) ); // max duration is 0x00FF_FFFF // send Rx Enable request to NP RTIS asynchronously as a confirm is due back NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_GetValidationStatusRsp * * @brief This function is used to return the current status of the MSO validation process. * * input parameters * * @param resetFlag - whether or not to reset the counter after reading the value * * output parameters * * None. * * @return counter value * **************************************************************************************************/ RTILIB_API void RTI_GetValidationStatusRsp(uint8 index, uint8 flag) { npiMsgData_t pMsg; // serialize the request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_GET_VALIDATION_STATUS_RSP; pMsg.len = 2; pMsg.pData[0] = index; pMsg.pData[1] = flag; // send serialized request to NP RTIS synchronously NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_DisableSleepReq * * @brief This API is used to disable sleep on the target. * * Note: When used from the RTIS, no actual message is sent to the * RTI, but wakeup bytes are sent instead. The RTI will * disable sleep as a result. * * input parameters * * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_DisableSleepReq( void ) { npiMsgData_t pMsg; RTI_PingReq(); // Then send real message that will be received and confirmed pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_DISABLE_SLEEP_REQ; //RTIS_CMD_ID_RTI_DISABLE_SLEEP_REQ; pMsg.len = 0; // send command to slave NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_SwResetReq * * @brief This function resets the radio processor CPU by way of software triggering. * Implementation of this function is target (CPU) dependent. * Note that in production platform, the reset could be done by chip reset signal * (halResetSlave) and hence use of this function should be restricted to development * phase. * * input parameters * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_SwResetReq( void ) { npiMsgData_t pMsg; pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_SW_RESET_REQ; pMsg.len = 0; // send command to slave NPI_SendAsynchData( &pMsg ); // wait for 200ms. // halDelay(200, 1); }
/************************************************************************************************** * * @fn RTI_TestModeReq * * @brief This function is used to place the radio in test modes. * Note that implementation is chip dependent. HAL is not used to reduce code * size overhead. * * input parameters * * @param mode - test mode: RTI_TEST_MODE_TX_RAW_CARRIER, RTI_TEST_MODE_TX_RANDOM_DATA * or RTI_TEST_MODE_RX_AT_FREQ * @param txPower - transmit power as negative dBm value. That is, 20 implies -20dBm. * @param channel - MAC channel number * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_TestModeReq( uint8 mode, int8 txPower, uint8 channel ) { npiMsgData_t pMsg; pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_TEST_MODE_REQ; pMsg.len = 3; pMsg.pData[0] = mode; pMsg.pData[1] = (uint8) txPower; pMsg.pData[2] = channel; // send command to slave NPI_SendAsynchData( &pMsg ); }
/************************************************************************************************** * * @fn RTI_PingReq * * @brief This function is used to take a UART based RNP out of sleep * * input parameters * None. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_PingReq( void ) { npiMsgData_t pMsg; // ping NP; request will be discarded pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_TEST_PING_REQ; //RTIS_CMD_ID_TEST_PING_REQ; pMsg.len = 2; pMsg.pData[0] = 0xAA; // Generate pulse train pMsg.pData[1] = 0xCC; // Generate pulse train // send command to slave to wake it up NPI_SendAsynchData( &pMsg ); }
int SBL_Execute() { int retVal = NPI_LNX_SUCCESS; LOG_INFO("[SBL] Executing Serial Bootloader\n"); if (!sblImageBuf || (sblImageLen <= 0)) { LOG_ERROR("[SBL] No binary file found\n"); retVal = NPI_LNX_FAILURE; } else { int sbResult = 0; sblState = SBL_STATE_SERIAL_BOOT; sbResult = sbExec(sblImageBuf, sblImageLen); if (sbResult != 0) { npiMsgData_t pMsg; LOG_WARN("[SBL] Serial boot loader failed. Attempting hard reset\n"); // Trying again after a hard reset pMsg.len = 0; pMsg.subSys = RPC_SYS_SRV_CTRL | RPC_CMD_AREQ; pMsg.cmdId = NPI_LNX_CMD_ID_RESET_DEVICE; // Send command NPI_SendAsynchData( &pMsg ); // After a very short delay attempt again LOG_INFO("[SBL] Send Handshake command\n"); retVal = BOOT_HandshakeReq(); if (retVal != NPI_LNX_SUCCESS) { LOG_FATAL("[SBL] Serial boot loader failed. Please restart application.\n"); } else { // Try again retVal = sbExec(sblImageBuf, sblImageLen); } } } return retVal; }
/************************************************************************************************** * * @fn RTI_SetBindingParamsReq * * @brief This function is used to respond to RTI_BindingParamsInd. * * input parameters * * @param bindingParams - 4 bytes binding parameters * * output parameters * * None. * * @return counter value * **************************************************************************************************/ RTILIB_API void RTI_SetBindingParamsReq(uint32 bindingParams) { npiMsgData_t pMsg; // serialize the request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_BIND_PARAMS_RSP; pMsg.len = 4; pMsg.pData[0] = ((uint8 *)&bindingParams)[0]; pMsg.pData[1] = ((uint8 *)&bindingParams)[1]; pMsg.pData[2] = ((uint8 *)&bindingParams)[2]; pMsg.pData[3] = ((uint8 *)&bindingParams)[3]; // send serialized request to NP RTIS synchronously NPI_SendAsynchData( &pMsg ); }
//***************************************************************************** // // Request that the RNP allow other to pair to this node. // // This function will build and send a tRemoTIMsg that will start an allow // pairing session. // // \note This is an asynchronous request. // // \sa RTI_AllowPairCnf() // // \return None. // //***************************************************************************** void RTI_AllowPairReq(void) { tRemoTIMsg sMsg; // // Populate the allow pair request message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_ALLOW_PAIR_REQ; sMsg.ui8Length = 0; // // Send the allow pair request message to the RNP RTIS asynchronously. // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Send a initialize request to the RNP. // // Creates and sends a tRemoTIMsg which contains a request to initialize the // the RNP using the parameters previously provided. // // \note This is an asynchronous request. // // \sa RTI_InitCnf() // // \return None. // //***************************************************************************** void RTI_InitReq( void ) { tRemoTIMsg sMsg; // // Load the tRemoTIMsg with appropriate parameters. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_INIT_REQ; sMsg.ui8Length = 0; // // Send init request to RNP RTIS asynchronously. // NPI_SendAsynchData( &sMsg ); }
//***************************************************************************** // // Send a message to the RNP to disable sleep mode. // // This function will build and send a message to the RNP to disable sleep // mode. // // \note This is an asynchronous request. // // \sa RTI_DisableSleepCnf() // // \return None. // //***************************************************************************** void RTI_DisableSleepReq( void ) { tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_DISABLE_SLEEP_REQ; sMsg.ui8Length = 0; // // Send the Message. // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Request that the RNP abort an ongoing allow pair session // // This function will build and send a tRemoTIMsg that will cancel the current // pairing operation. // // \note This is an asynchronous request. // // \sa RTI_AllowPairAbortCnf() // // \return None. // //***************************************************************************** void RTI_AllowPairAbortReq(void) { tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_ALLOW_PAIR_ABORT_REQ; sMsg.ui8Length = 0; // // Send the Message. // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Request that the RNP abort an ongoing pair request. // // This function will build and send a tRemoTIMsg that will cancel the current // pairing operation. // // \note This is an asynchronous request. // // \sa RTI_PairAbortCnf() // // \return None. // //***************************************************************************** void RTI_PairAbortReq( void ) { tRemoTIMsg sMsg; // // Populate the pair abort request message // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_PAIR_ABORT_REQ; sMsg.ui8Length = 0; // // Send pair abort request to RNP RTIS asynchronously // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Request to un-pair from a particular destination index. // // \param ui8DestIndex the destination index that caller wishes to unpair from. // // This function will build and send a unpair request message to the RNP. // // \note This is an asynchronous request. // // \sa RTI_UnpairCnf() // // \returns None. // //***************************************************************************** void RTI_UnpairReq(uint8_t ui8DestIndex) { tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_UNPAIR_REQ; sMsg.ui8Length = 1; sMsg.pui8Data[0] = ui8DestIndex; // // Send the Message. // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Sends a standby request to the RNP. // // Generate and send a tRemoTIMsg to request the RNP enter standby mode. // // \note This is an asynchronous message. // // \sa RTI_StandbyCnf() // // \return None. // //***************************************************************************** void RTI_StandbyReq(uint8_t ui8Mode) { tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_STANDBY_REQ; sMsg.ui8Length = 1; sMsg.pui8Data[0] = ui8Mode; // // Send the Message. // NPI_SendAsynchData(&sMsg); }
/************************************************************************************************** * * @fn RTI_SendDataReq * * @brief This function sends data to the destination specified by the * pairing table index. * * input parameters * * @param dstIndex - Pairing table index. * @param profileId - Profile identifier. * @param vendorId - Vendor identifier. * @param txOptions - Transmission options, as specified in Table 2 of the * RF4CE specification. * @param len - Number of bytes to send. * @param *pData - Pointer to buffer of data to be sent. * * output parameters * * None. * * @return None. * **************************************************************************************************/ RTILIB_API void RTI_SendDataReq( uint8 dstIndex, uint8 profileId, uint16 vendorId, uint8 txOptions, uint8 len, uint8 *pData ) { npiMsgData_t pMsg; // prep Send Data request pMsg.subSys = RPC_SYS_RCAF; pMsg.cmdId = RTIS_CMD_ID_RTI_SEND_DATA_REQ; pMsg.len = 6+len; pMsg.pData[0] = dstIndex; pMsg.pData[1] = profileId; RTI_SET_ITEM_HALFWORD( &pMsg.pData[2], vendorId ); pMsg.pData[4] = txOptions; pMsg.pData[5] = len; // copy the client's data to be sent msg_memcpy( &pMsg.pData[6], pData, len ); // send Send Data request to NP RTIS synchronously NPI_SendAsynchData( &pMsg ); }
//***************************************************************************** // // Send a Data Packet to the RNP. // // \param ui8DestIndex the destination index of the pairing partner that will // receive this data packet. // \param ui8ProfileId the profile identifier used for this transaction. // \param ui16VendorID the vendor identifier for this transaction. // \param ui8TXOptions Transmit options such as \b RTI_TX_OPTION_BROADCAST or // \b RTI_TX_OPTION_ACKNOWLEDGED. This is an OR'd combination of bit flags. // \param ui8Length the length of the data to be sent. // \param pui8Data a pointer to the data in caller provided storage. // // This function builds and sends a data request to the RNP. This request // builds the message format on top of the tRemoTIMsg base structure elements. // // \note This is an asynchronous request. // // \sa RTI_SendDataCnf() // // \return None. // //***************************************************************************** void RTI_SendDataReq(uint8_t ui8DestIndex, uint8_t ui8ProfileID, uint16_t ui16VendorID, uint8_t ui8TXOptions, uint8_t ui8Length, uint8_t *pui8Data) { tRemoTIMsg sMsg; uint32_t ui32Index; uint8_t *pui8Tmp; // // Cast the vendor identifier to a byte pointer to allow endian swapping. // pui8Tmp = (uint8_t*) &ui16VendorID; // // Populate the message header bytes. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_SEND_DATA_REQ; sMsg.ui8Length = ui8Length + 6; sMsg.pui8Data[0] = ui8DestIndex; sMsg.pui8Data[1] = ui8ProfileID; sMsg.pui8Data[2] = pui8Tmp[1]; sMsg.pui8Data[3] = pui8Tmp[0]; sMsg.pui8Data[4] = ui8TXOptions; sMsg.pui8Data[5] = ui8Length; // // Populate the payload section of the message. // for(ui32Index = 0; ui32Index < ui8Length; ui32Index++) { sMsg.pui8Data[ui32Index + 6] = pui8Data[ui32Index]; } // // Send the Message. // NPI_SendAsynchData(&sMsg); }
//***************************************************************************** // // Send a request to the RNP to perform a software reset. // // This function will build and send a message over the UART to the RNP to // request that the RNP perform a software reset on itself. This function // will generate a spin delay of 200 milliseconds to allow the RNP time to // complete the reset operation. // // \note This is an asynchronous request without a corresponding confirmation. // // \return None. //***************************************************************************** void RTI_SwResetReq(void) { tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_SW_RESET_REQ; sMsg.ui8Length = 0; // // Send the Software Reset Request // NPI_SendAsynchData(&sMsg); // // Stall for 200 milliseconds to give the RNP time to do its reset. // SysCtlDelay(SysCtlClockGet() / (3 * 5)); }
//***************************************************************************** // // Send a message to the RNP to enable sleep mode. // // Builds and sends a tRemoTIMsg to the RNP that enables sleep mode. // // \note This is an asynchronous request. // // \sa RTI_EnableSleepCnf() // // \return None. // //***************************************************************************** void RTI_EnableSleepReq( void ) { // // Compile time switch is used to determine if the power saving modes are // compiled into the library. These settings must be the same on the // application processor and the RNP. // #if (defined RNP_POWER_SAVING) && (RNP_POWER_SAVING == TRUE) tRemoTIMsg sMsg; // // Populate the message. // sMsg.ui8SubSystem = RPC_SYS_RCAF; sMsg.ui8CommandID = RTIS_CMD_ID_RTI_ENABLE_SLEEP_REQ; sMsg.ui8Length = 0; // // Send the Message. // NPI_SendAsynchData(&sMsg); #endif }