|
MySensors Library & Examples
2.3.2-62-ge298769
|
62 LOG(F(
"\n%sReady.\n"), nodeTypeAsCharRepresentation(
getNodeId()));
71 if (Serial.available()) {
72 byte inChar = Serial.read();
76 if (inChar ==
'T' || inChar ==
't') {
77 LOG(F(
"T received - starting test...\n"));
79 msg.
sender = (node == YING ? YANG : YING);
80 sendPingOrPongResponse( msg );
81 }
else if (inChar ==
'0' or inChar ==
'1') {
82 byte nodeID = 200 + (inChar -
'0');
85 LOG(
"Invalid input\n");
93 LOG(F(
"Received %s from %s\n"), msgTypeAsCharRepresentation((mysensors_data_t)message.
getType()),
94 nodeTypeAsCharRepresentation(message.
sender));
97 sendPingOrPongResponse( message );
100 void sendPingOrPongResponse(
MyMessage msg )
105 LOG(F(
"Sending %s to %s\n"), msgTypeAsCharRepresentation( (mysensors_data_t)response.
getType() ),
106 nodeTypeAsCharRepresentation(msg.
sender));
109 response.
set( (uint32_t)millis() );
114 void setNodeId(
byte nodeID)
116 LOG(F(
"Setting node id to: %i.\n***Please restart the node for changes to take effect.\n"), nodeID);
120 const char * msgTypeAsCharRepresentation( mysensors_data_t mType )
122 return mType == V_VAR1 ?
"Ping" :
"Pong";
125 const char * nodeTypeAsCharRepresentation( uint8_t node )
127 return node == YING ?
"Ying Node" :
"Yang Node";
uint8_t sender
8 bit - Id of sender node (origin)
bool sendSketchInfo(const char *name, const char *version, const bool requestEcho=false)
void receive(const MyMessage &message)
Callback for incoming messages.
void presentation()
Node presentation.
MyMessage & set(const void *payload, const size_t length)
Set entire payload.
bool send(MyMessage &msg, const bool requestEcho=false)
uint8_t getType(void) const
Get message type.
bool present(const uint8_t sensorId, const mysensors_sensor_t sensorType, const char *description="", const bool requestEcho=false)
void setup()
Called after node initialises but before main loop.
MyMessage & setDestination(const uint8_t destinationId)
Set final destination node id for this message.
#define EEPROM_NODE_ID_ADDRESS
Address node ID.
API declaration for MySensors.
MyMessage is used to create, manipulate, send and read MySensors messages.