DolphinV4 API  1.6.1.0
REMAN Device

REMAN Device application example files

REMAN Device Application file - main.c

/************************************************************************-
EVA Board:
EVA320-3
Input PIN:
ADIO_4 Reseting the REMAN code to default code 0x00000001
Output PIN:
ADIO_7 Reaction on REMAN action command
Description:
This example demonstrates how to integrate Remote Management in a device application.
The following Remote Management Controll Commands (RMCC) are implemented:
- Lock, Unlock, SetCode, QueryID, Action, QueryStatus, Ping, QueryFunction
The following Remote Procedure Calls (RPC) are implemented:
- RemoteRead, RemoteWrite
Pressing the ADIO_4 button resets the REMAN code manualy
-************************************************************************/
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
#include <string.h>
// Application version string
code uint8 VERSION_APP[] = {0xE0,'V','E','R','S','I','O','N',1,0,3,1,'A','R','E','M','A','N','D','E','V','I','C','E',0x00,0xE0};
// RPC list definition
code uint16 reman_rpc[] = {
};
#define REMAN_DEFAULT_CODE (0x01)
void main()
{
uint16 u16FnNumber;
uint16 u16DataSize;
uint32 u32Code;
// REMOTE_READ variables
uint16 u16NumBytes = 0;
uint16 u16FlashAddr = 0;
uint8 u8Val;
mainInit();
// Initialize RPC list
reman_setRPC(reman_rpc, sizeof(reman_rpc)>>2);
while (1)
{
//Make sure to have a backdoor to reset the code through pressing a key on the module, otherwise if the REMAN code is lost, the module stays locked forewer
//Reman cannot be unlocked, if code is not set. So at least once you have to press ADIO_4 to initialize it with the default code. Usually you shall do it
//outside of the loop in your cold start initialisation.
io_getDigital(ADIO_4, &u8Val);
if (u8Val == 0)
{
u32Code = REMAN_DEFAULT_CODE;
mem_writeFlash((uint8*)(&u32Code), RM_CODE_ADDR, sizeof(u32Code));
reman_init(reman_param, SET_ALL_PARAM);
io_togDigital(ADIO_7);
time_wait(300);
io_togDigital(ADIO_7);
time_wait(2000);
}
{
// Telegram was actually send through radio. We could do some debug LED blinking here
}
// Receive radio telegram
if (radio_getTelegram(&rTel, &pTel) != OK)
continue;
// Remote management module process received telegram
if (reman_receiveTelegram(&rTel, &pTel, &u16FnNumber, &u16DataSize) == OK)
{
switch(u16FnNumber)
{
// The aplication has to save the code to flash at RM_ADDR_CODE address. You can do it here or perhaps later.
reman_getCode(&u32Code);
mem_writeFlash((uint16)(&u32Code), RM_CODE_ADDR, sizeof(u32Code));
break;
{
io_togDigital(ADIO_7);
time_wait(500);
io_togDigital(ADIO_7);
}
break;
// We don't reply to broadcast, so we check the destination ID
{
u16FlashAddr = u8gRmDataBuffer[0]<<8 | u8gRmDataBuffer[1];
u16NumBytes = u8gRmDataBuffer[2]<<8 | u8gRmDataBuffer[3];
if (u16FlashAddr<0x7D00 || u16FlashAddr>0x7EFF)
{
break;
}
if (reman_sendMessage((uint8 code *)u16FlashAddr, u16NumBytes, RM_FN_REMOTE_READ_ANS, FALSE)!=OK)
{
}
}
break;
// We react on both broadcast and addressed telegrams so no ID checking is needed
u16FlashAddr = u8gRmDataBuffer[0]<<8 | u8gRmDataBuffer[1];
u16NumBytes = u8gRmDataBuffer[2]<<8 | u8gRmDataBuffer[3];
if (u16FlashAddr<0x7D00 || u16FlashAddr>0x7EFF)
{
break;
}
if (u16NumBytes>256)
{
break;
}
if(mem_writeFlash(&u8gRmDataBuffer[4], u16FlashAddr, u16NumBytes)==OK)
else
break;
// Do something useful
break;
} // switch
} //reman_receiveTelegram
} // application loop
}



Config file - EO3100I_CFG.h

// Generated on 2013-06-07 14:22:16 by DolphinAPIConfigurator 1.1.0.20
#ifndef _EO3100I_CFG_H_INCLUDED
#define _EO3100I_CFG_H_INCLUDED
void startupInit();
void mainInit();
//*********************REMAN PARAM***************************
#define EEP_ORG 0xFF
#define EEP_FUNC 0x3F
#define EEP_TYPE 0x7F
#define MANUFACTURER_ID 0x7FF
#define RM_BUFF_SIZE 0x14
#define RM_CODE_ADDR 0x7E00
extern uint8 xdata u8gRmDataBuffer[RM_BUFF_SIZE];
extern uint16 code reman_param[];
//*********************RADIO PARAM***************************
#define RADIO_BUFF_NUM 10
#define RADIO_MATURITY_TIME 100
extern volatile RADIO_BUFFER_TYPE xdata gRadioBuff[RADIO_BUFF_NUM];
//*********************FILTER PARAM***************************
#define FILTER_NUM 1
extern volatile uint32 xdata u32gFilterValue[FILTER_NUM];
extern volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
//*********************IO PARAM******************************
extern uint8 code io_param[];
#endif //_EO3100I_CFG_H_INCLUDED



Config file - EO3100I_CFG.c

// Generated on 2013-06-07 14:22:24 by DolphinAPIConfigurator 1.1.0.20
#include "EO3100I_API.h"
#include "EO3100I_CFG.h"
//*********************API INIT***************************
//Note: Function is called from startup.a51. Global variables are not yet initialized!
void startupInit()
{
io_init(io_param);
}
void mainInit()
{
radio_init(RADIO_BUFF_NUM, RADIO_MATURITY_TIME);
reman_init(reman_param, SET_ALL_PARAM);
}
//*********************REMAN PARAM***************************
uint8 xdata u8gRmDataBuffer[RM_BUFF_SIZE];
uint16 code reman_param[] = {
(EEP_ORG<<8) | (EEP_FUNC<<2) | (EEP_TYPE>>5), // IDX_EEP_BYTE0_BYTE1
(EEP_TYPE<<11), // IDX_EEP_BYTE2
MANUFACTURER_ID, // IDX_MANUFACTURERID
RM_BUFF_SIZE, // IDX_BUFF_SIZE
RM_CODE_ADDR, // IDX_CODE_ADDR
50 // IDX_TEL_DELAY
};
//*********************RADIO PARAM***************************
volatile RADIO_BUFFER_TYPE xdata gRadioBuff[RADIO_BUFF_NUM];
//*********************FILTER PARAM***************************
volatile uint32 xdata u32gFilterValue[FILTER_NUM];
volatile uint8 xdata u8gFilterCfg[FILTER_NUM];
//*********************IO PARAM******************************
uint8 code io_param[] = {
0x07, //IDX_GPIO_CONF
0x00, //IDX_GPIO0_CONF
0x0F, //IDX_GPIO0_PULL_CONF
0x00, //IDX_GPIO0_DIR
0x00, //IDX_GPIO1_AN
0x00, //IDX_GPIO1_CONF0
0x00, //IDX_GPIO1_CONF1
0x03, //IDX_GPIO1_DIG_CONF
0x80, //IDX_GPIO1_DIR
0x7F, //IDX_GPIO1_PULL
0x0C, //IDX_GPIO2_CONF
0x00, //IDX_GPIO2_DIR
0x00, //IDX_GPIO0
0x00, //IDX_GPIO1
0x00, //IDX_GPIO2
};
// I/O Configuration overview
//
// Pin : Interface Direction Pull InitValue Interrupt
// SCSEDIO0 : Digital I/O In Up 0 No
// SCLKDIO1 : Digital I/O In Up 0 No
// WSDADIO2 : Digital I/O In Up 0 No
// RSDADIO3 : Digital I/O In Up 0 No
// ADIO0 : Digital I/O In Up 0 No
// ADIO1 : Digital I/O In Up 0 No
// ADIO2 : Digital I/O In Up 0 No
// ADIO3 : Digital I/O In Up 0 No
// ADIO4 : Digital I/O In Up 0 No
// ADIO5 : Digital I/O In Up 0 No
// ADIO6 : Digital I/O In Up 0 No
// ADIO7 : Digital I/O Out None 0 No
// WXIDIO : Digital I/O In Up 0 No
// WXODIO : Digital I/O In Up 0 No
// WAKE0 : Digital I/O In None 0 No
// WAKE1 : Digital I/O In None 0 No