1 /* 2 * Author: Stefan Andritoiu <stefan.andritoiu (at) intel.com> 3 * Copyright (c) 2015 Intel Corporation. 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining 6 * a copy of this software and associated documentation files (the 7 * "Software"), to deal in the Software without restriction, including 8 * without limitation the rights to use, copy, modify, merge, publish, 9 * distribute, sublicense, and/or sell copies of the Software, and to 10 * permit persons to whom the Software is furnished to do so, subject to 11 * the following conditions: 12 * 13 * The above copyright notice and this permission notice shall be 14 * included in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 */ 24 25 import upm_nrf24l01.Callback; 26 27 //NOT TESTED!!! 28 public class NRF24L01_transmitterSample { 29 30 static private final byte[] destAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; 31 static private final byte[] srcAddress = {0x01, 0x01, 0x01, 0x01, 0x01}; 32 static private byte[] tx_buffer = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 33 0x00}; 34 35 static { 36 try { 37 System.loadLibrary("javaupm_nrf24l01"); 38 } catch (UnsatisfiedLinkError e) { 39 System.err.println("error in loading native library"); 40 System.exit(-1); 41 } 42 } 43 44 public static void main(String[] args) throws InterruptedException { 45 // ! [Interesting] 46 upm_nrf24l01.NRF24L01 comm = new upm_nrf24l01.NRF24L01((short) 7, (short) 8); 47 48 Callback callback = new TransmitterCallback(); 49 50 comm.setSourceAddress(srcAddress); 51 comm.setDestinationAddress(destAddress); 52 comm.setPayload((short) upm_nrf24l01.javaupm_nrf24l01Constants.MAX_BUFFER); 53 comm.setChannel((short) 99); 54 comm.configure(); 55 comm.setDataReceivedHandler(callback); 56 57 while (true) { 58 comm.send(tx_buffer); 59 System.out.println("devi2 :: sending data ...."); 60 for (int i = 0; i < tx_buffer.length; i++) 61 System.out.print(tx_buffer[i]); 62 System.out.println(); 63 Thread.sleep(3000); 64 } 65 // ! [Interesting] 66 } 67 } 68 69 class TransmitterCallback extends Callback { 70 public TransmitterCallback() { 71 super(); 72 } 73 public void run() { 74 } 75 }