private void onReceive(object sender, EventArgMessage msg) { Message recMsg; try { recMsg = new SerialMessage(msg.getMsg()); EventArgSerialMessage eventArgSerialMessage = new EventArgSerialMessage(); eventArgSerialMessage.msg = (SerialMessage)recMsg; EventHandler<EventArgSerialMessage> handler = onMessageArrived; if (handler != null) { handler(this, eventArgSerialMessage); } } catch (Exception e) { throw e; } }
public Object SendOne(SerialMessage msg) { if (mote==null) return null; mote.Send(msg); prompt.WriteLine("Packet sent", prompt.successTextColor); if (listen) { return new Listener(mote, prompt); } mote.Close(); return null; }
private void onReceive(object sender, EventArgMessage msg) { Message recMsg; try { recMsg = new SerialMessage(msg.getMsg()); EventArgSerialMessage eventArgSerialMessage = new EventArgSerialMessage(); eventArgSerialMessage.msg = (SerialMessage)recMsg; EventHandler <EventArgSerialMessage> handler = onMessageArrived; if (handler != null) { handler(this, eventArgSerialMessage); } } catch (Exception e) { throw e; } }
static void Send() { int counter = 0; byte AM_ID = 0x89; //int dest = 1; TestSerialMessage testSerialMsg = new TestSerialMessage(counter); SerialMessage serialMsg = new SerialMessage(testSerialMsg.GetMessageBytes(), AM_ID); //serialMsg[(int)SerialMessage.H.DEST] = dest; while (true) { Console.WriteLine("Sending packet " + counter); mote.Send(serialMsg); testSerialMsg[TestSerialMessage.COUNTER] = (uint)++counter; serialMsg.SetPayload(testSerialMsg.GetMessageBytes()); Thread.Sleep(1000); } }
public Object SendOne(uint dest, uint src, uint group, uint amtype) { if (mote==null) return null; byte[] bpayload = SerialMessage.HexStringToByteArray(payload); SerialMessage msg = new SerialMessage(bpayload, (byte)amtype); msg[SerialMessage.DEST] = dest; msg[SerialMessage.SRC] = src; msg[SerialMessage.GROUP] = group; mote.Send(msg); prompt.WriteLine("Packet sent", prompt.successTextColor); if (listen) { return new Listener(mote, prompt); } mote.Close(); return null; }