private void startScanBtn_Click(object sender, EventArgs e) { foundDevicesListView.Items.Clear(); ushort responseTime = 0; try { responseTime = Convert.ToUInt16(responseTimeTb.Text); } catch (Exception eee) { MessageBox.Show("Yanıt süresinin değerini kontrol ediniz.."); return; } RadioMessageType messageType = RadioMessageType.DISCOVER_NEIGHBOUR_REQUEST; RadioServiceType serviceType = RadioServiceType.BROADCAST_SERVICE; byte[] messagePayload = new byte[10]; DateTime dateTime = DateTime.Now; if (syncClocksCb.Checked) { messagePayload[0] = 0x01; // sync clock } else { messagePayload[0] = 0x00; // dont sync clock } messagePayload[1] = 12; // DeviceType -> GATEWAY messagePayload[2] = (byte)(responseTime >> 8); messagePayload[3] = (byte)(responseTime & 0xFF); messagePayload[4] = (byte)dateTime.Hour; /* Cihaz Saati */ //kaanbak : burada gateway'in saatini de kontrol etmemiz gerekiyor.. messagePayload[5] = (byte)dateTime.Minute; messagePayload[6] = (byte)dateTime.Second; messagePayload[7] = (byte)dateTime.Day; messagePayload[8] = (byte)dateTime.Month; messagePayload[9] = (byte)(dateTime.Year - 2000); LoRaManager.Instance.SendLoRaPackageToRemoteDevice(255, messageType, serviceType, messagePayload, 10, responseTime, 0); try { ProgressBarTimerTickCount = (ushort)(responseTime / progressBarTimer.Interval); CurrentProgressBarTimerTickCount = ProgressBarTimerTickCount; scanningProgresBar.Maximum = responseTime; scanningProgresBar.Minimum = 0; scanningProgresBar.Value = 0; progressBarTimer.Start(); startScanBtn.Enabled = false; label2.Text = "Tarama Devam ediyor.."; } catch (Exception ee) { MessageBox.Show(ee.Message); } }
public void SendLoRaMessageToPage(byte sourceUnit, RadioMessageType messageType, byte[] data, int rssi) { switch (messageType) { case RadioMessageType.DATA_CHANNEL_RESPONSE: parseDataChannelResponse(data, rssi); break; default: break; } }
public void SendLoRaPackageToRemoteDevice(byte destinationIdParam, RadioMessageType messageTypeParam, RadioServiceType serviceTypeParam, byte[] dataParam, UInt16 lengthParam, ushort timeoutParam, byte retryCountParam) { byte[] packageData = new byte[lengthParam + 7]; packageData[0] = (byte)(destinationIdParam); packageData[1] = (byte)messageTypeParam; packageData[2] = (byte)serviceTypeParam; packageData[3] = (byte)(timeoutParam >> 8); packageData[4] = (byte)(timeoutParam & 0xFF); packageData[5] = retryCountParam; packageData[6] = (byte)lengthParam; Array.Copy(dataParam, 0, packageData, 7, lengthParam); EthernetManager.Instance.SendRemoteDeviceCmd(Ethernet_MessageIDs_t.INCOMING_CMD_LORA_SEND_PACKAGE_REQUEST, (ushort)(lengthParam + 7), packageData); }
// public void SendLoRaMessageToPage(byte sourceUnit, RadioMessageType messageType, byte[] data, int rssi) { switch (messageType) { case RadioMessageType.DISCOVER_NEIGHBOUR_RESPONSE: Parse_DiscoverNeighbourResponse(sourceUnit, data, rssi); break; default: // independent with current page.. break; } }
public void SendLoRaPackageToResponsiblePage(byte[] data, UInt16 length) { RadioMessageType messageIdTemp = (RadioMessageType)((data[5] & 0xF8) >> 3); RadioRoutingHeaderType routingHeaderTypeTemp = (RadioRoutingHeaderType)(data[5] & 0x03); byte sourceUnit = 0; byte routingHeaderLength = 0; Int16 signalRssiValue = 0; signalRssiValue = (Int16)((data[length - 5] << 8) | (data[length - 4])); //kaanbak burada generic parsing yapilmali... sonra interface'e param olarak verilmeli if (routingHeaderTypeTemp == RadioRoutingHeaderType.UNICAST_DIRECT_HEADER) { sourceUnit = data[6]; routingHeaderLength = 3; /* 1 byte main + 2 byte routing header */ } else if (routingHeaderTypeTemp == RadioRoutingHeaderType.UNICAST_ROUTED_HEADER) { sourceUnit = data[6]; routingHeaderLength = 6; /* 1 byte main + 5 byte routing header */ } else { // not implemented yet... return; } byte[] loraMessageData = new byte[length - 5 - routingHeaderLength]; Array.Copy(data, (5 + routingHeaderLength), loraMessageData, 0, length - 5 - routingHeaderLength); switch (messageIdTemp) { case RadioMessageType.DATA_CHANNEL_REQUEST: break; case RadioMessageType.DATA_CHANNEL_RESPONSE: veriKanaliOkumaPageInterface.SendLoRaMessageToPage(sourceUnit, messageIdTemp, loraMessageData, signalRssiValue); break; case RadioMessageType.DEVICE_INFORMATION_REQUEST: break; case RadioMessageType.DEVICE_INFORMATION_RESPONSE: break; case RadioMessageType.DISCOVER_NEIGHBOUR_REQUEST: break; case RadioMessageType.DISCOVER_NEIGHBOUR_RESPONSE: cihazTaramaPageInterface.SendLoRaMessageToPage(sourceUnit, messageIdTemp, loraMessageData, signalRssiValue); break; case RadioMessageType.ECHO_MESSAGE_REQUEST: break; case RadioMessageType.ECHO_MESSAGE_RESPONSE: break; case RadioMessageType.OPERATIONAL_REQUEST: break; case RadioMessageType.OPERATIONAL_RESPONSE: cihazConfigPageInterface.SendLoRaMessageToPage(sourceUnit, messageIdTemp, loraMessageData, signalRssiValue); break; case RadioMessageType.PING_MESSAGE: break; case RadioMessageType.PONG_MESSAGE: break; case RadioMessageType.UNCATEGORIZED_REL_MSG_REQUEST: break; case RadioMessageType.UNCATEGORIZED_REL_MSG_RESPONSE: break; case RadioMessageType.FILE_OPERATIONS_REQUEST: break; case RadioMessageType.FILE_OPERATIONS_RESPONSE: dosyaIslemleriPageInterface.SendLoRaMessageToPage(sourceUnit, messageIdTemp, loraMessageData, signalRssiValue); break; } }
public void SendLoRaPackageToResponsiblePage(byte[] data, UInt16 length) { RadioMessageType messageIdTemp = (RadioMessageType)((data[5] & 0xF8) >> 3); RadioRoutingHeaderType routingHeaderTypeTemp = (RadioRoutingHeaderType)(data[5] & 0x03); byte routingHeaderLength = 0; Int16 signalRssiValue = 0; signalRssiValue = (Int16)((data[length - 5] << 8) | (data[length - 4])); if (routingHeaderTypeTemp == RadioRoutingHeaderType.UNICAST_DIRECT_HEADER) { routingHeaderLength = 3; /* 1 byte main + 2 byte routing header */ } else if (routingHeaderTypeTemp == RadioRoutingHeaderType.UNICAST_ROUTED_HEADER) { routingHeaderLength = 6; /* 1 byte main + 5 byte routing header */ } else { // not implemented yet... return; } byte[] loraMessageData = new byte[length - 5 - routingHeaderLength]; Array.Copy(data, (5 + routingHeaderLength), loraMessageData, 0, length - 5 - routingHeaderLength); switch (messageIdTemp) { case RadioMessageType.DATA_CHANNEL_REQUEST: break; case RadioMessageType.DATA_CHANNEL_RESPONSE: //veriKanaliOkumaPageInterface.SendLoRaMessageToPage(messageIdTemp, loraMessageData, signalRssiValue); break; case RadioMessageType.DEVICE_INFORMATION_REQUEST: break; case RadioMessageType.DEVICE_INFORMATION_RESPONSE: break; case RadioMessageType.DISCOVER_NEIGHBOUR_REQUEST: break; case RadioMessageType.DISCOVER_NEIGHBOUR_RESPONSE: break; case RadioMessageType.ECHO_MESSAGE_REQUEST: break; case RadioMessageType.ECHO_MESSAGE_RESPONSE: break; case RadioMessageType.OPERATIONAL_REQUEST: break; case RadioMessageType.OPERATIONAL_RESPONSE: break; case RadioMessageType.PING_MESSAGE: break; case RadioMessageType.PONG_MESSAGE: break; case RadioMessageType.UNCATEGORIZED_REL_MSG_REQUEST: break; case RadioMessageType.UNCATEGORIZED_REL_MSG_RESPONSE: break; } }