nrf_send_data() public method

Send Data Packet
public nrf_send_data ( byte tx_packet, byte device_id, packet_type req_type, bool fullbyte = false ) : void
tx_packet byte 6 byte wide byte packet
device_id byte
req_type packet_type
fullbyte bool
return void
 private void button_Click(object sender, RoutedEventArgs e)
 {
     byte[] bb = new byte[10];
     bb[0] = byte.Parse(b1.Text);
     bb[1] = byte.Parse(b2.Text);
     bb[2] = byte.Parse(b3.Text);
     bb[3] = byte.Parse(b4.Text);
     bb[4] = byte.Parse(b5.Text);
     bb[5] = byte.Parse(b6.Text);
     bb[6] = byte.Parse(b7.Text);
     bb[7] = byte.Parse(b8.Text);
     bb[8] = byte.Parse(b9.Text);
     bb[9] = byte.Parse(b10.Text);
     rootPage.nrf_send_data(bb, 0x00, 0x00, true);
 }
Example #2
0
        /// <summary>
        /// transmit all the commands from this page to respective nRF slave
        /// </summary>
        void transmit()
        {
            //4 DEVICE state bytes to transmit
            byte dev1_checked = Convert.ToByte(device1.IsChecked);
            byte dev2_checked = Convert.ToByte(device2.IsChecked);
            byte dev3_checked = Convert.ToByte(device3.IsChecked);
            byte dev4_checked = Convert.ToByte(device4.IsChecked);

            //Update main page's selected device's states accordingly
            rootPage.lastitem.device1_state = dev1_checked;
            rootPage.lastitem.device2_state = dev2_checked;
            rootPage.lastitem.device3_state = dev3_checked;
            rootPage.lastitem.device4_state = dev4_checked;

            //define bytes array
            byte[] bb = { dev1_checked, dev2_checked, dev3_checked
                          ,             dev4_checked, dev4_checked, dev4_checked };

            //send and update
            rootPage.nrf_send_data(bb, rootPage.lastitem.device_address, MainPage.packet_type.data_packet);
            rootPage.update_devicelist(rootPage.lastitem);
        }
Example #3
0
        /// <summary>
        /// transmit all the commands from this page to respective nRF slave
        /// </summary>
        void transmit()
        {
            try
            {
                byte tchecked       = Convert.ToByte(buzzer.IsOn);
                byte ssrelaychecked = Convert.ToByte(relay_on_off.IsOn);

                rootPage.lastitem.device2_state = tchecked;
                rootPage.lastitem.device3_state = ssrelaychecked;
                rootPage.lastitem.device1_state = (byte)(slider.Value);

                byte[] bb = { (byte)(slider.Value), tchecked,       ssrelaychecked
                              ,                     ssrelaychecked, ssrelaychecked, ssrelaychecked };

                rootPage.nrf_send_data(bb, rootPage.lastitem.device_address, MainPage.packet_type.data_packet);
                rootPage.update_devicelist(rootPage.lastitem);
            }
            catch (Exception ex)
            {
                rootPage.statusbar_string(ex.ToString(), true);
            }
        }
Example #4
0
 void transmit()
 {
     rootPage.nrf_send_data(tx_dat, rootPage.lastitem.device_address,
                            MainPage.packet_type.data_packet);
 }