├── bglib-protocol-1.1.0-55Beta ├── README.md ├── src │ └── main │ │ └── java │ │ └── org │ │ └── thingml │ │ └── bglib │ │ ├── BGAPITransportListener.java │ │ ├── BGAPIPacketLogger.java │ │ ├── BDAddr.java │ │ ├── BGAPIPacketReader.java │ │ ├── BGAPIPacket.java │ │ ├── BGAPITransport.java │ │ ├── BGAPIListener.java │ │ └── BGAPIDefaultListener.java └── pom.xml ├── .gitignore ├── bglib-generator ├── src │ ├── main │ │ ├── resources │ │ │ ├── BGAPIListener.javat │ │ │ ├── BGAPIDefaultListener.javat │ │ │ ├── BGAPIImpl.javat │ │ │ ├── apitypes.h │ │ │ ├── output.thingml │ │ │ └── commands.c │ │ └── scala │ │ │ └── BGLibGen │ │ │ ├── SimpleCopyTemplate.scala │ │ │ ├── BluegigaJavaGenerator.scala │ │ │ └── BluegigaGenerator.scala │ └── test │ │ └── scala │ │ └── BGLibGen │ │ └── AppTest.scala └── pom.xml ├── HEADER ├── bglib-protocol-1.0.3-43 ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── thingml │ │ │ └── bglib │ │ │ ├── BGAPITransportListener.java │ │ │ ├── BDAddr.java │ │ │ ├── BGAPIPacketLogger.java │ │ │ ├── BGAPIPacketReader.java │ │ │ ├── BGAPIPacket.java │ │ │ ├── BGAPITransport.java │ │ │ ├── BGAPIListener.java │ │ │ └── BGAPIDefaultListener.java │ └── test │ │ └── java │ │ └── org │ │ └── thingml │ │ └── bglib │ │ └── AppTest.java └── pom.xml ├── bglib-gui ├── src │ ├── main │ │ └── java │ │ │ └── org │ │ │ └── thingml │ │ │ └── bglib │ │ │ └── gui │ │ │ ├── BLEServiceValueListener.java │ │ │ ├── ByteUtils.java │ │ │ ├── BLEAttribute.java │ │ │ ├── NativeLibUtil.java │ │ │ ├── BLEDeviceList.java │ │ │ ├── BLEService.java │ │ │ ├── BLEDevice.java │ │ │ ├── BLEServiceInstance.java │ │ │ ├── AttributeFrame.form │ │ │ ├── AttributeFrame.java │ │ │ ├── BLED112.java │ │ │ └── BLEExplorerFrame.form │ └── test │ │ └── java │ │ └── org │ │ └── thingml │ │ └── bglib │ │ └── gui │ │ └── AppTest.java └── pom.xml ├── bglib-samples ├── pom.xml └── src │ ├── main │ └── java │ │ └── org │ │ └── thingml │ │ └── bglib │ │ └── samples │ │ ├── ByteUtils.java │ │ ├── NativeLibUtil.java │ │ ├── CheckBGAPIVersion.java │ │ ├── SimpleDiscovery.java │ │ └── BLED112.java │ └── test │ └── java │ └── org │ └── thingml │ └── bglib │ └── samples │ └── AppTest.java ├── README.md └── pom.xml /bglib-protocol-1.1.0-55Beta/README.md: -------------------------------------------------------------------------------- 1 | IMPORTANT WARNING!!! 2 | ==================== 3 | 4 | This project contains a version of the 1.1.0-55 Beta2 API which has NOT BEEN TESTED. 5 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | */.svn/* 2 | **/.svn/* 3 | **/bin/* 4 | /.svn/ 5 | target/ 6 | .DS_Store 7 | .settings/ 8 | *.iml 9 | *.ipr 10 | *.iws 11 | keystore 12 | /.idea/ 13 | /.idea/* 14 | .idea/ 15 | .idea/* 16 | .directory 17 | *~ -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/BGAPIListener.javat: -------------------------------------------------------------------------------- 1 | package org.thingml.bgapi; 2 | /** 3 | * @author Franck FLEUREY (SINTEF) 4 | */ 5 | public interface BGAPIListener { 6 | 7 | /*METHODS*/ 8 | 9 | } 10 | -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/BGAPIDefaultListener.javat: -------------------------------------------------------------------------------- 1 | package org.thingml.bgapi; 2 | /** 3 | * @author Franck FLEUREY (SINTEF) 4 | */ 5 | public class BGAPIDefaultListener implements BGAPIListener { 6 | 7 | /*METHODS*/ 8 | 9 | } 10 | -------------------------------------------------------------------------------- /HEADER: -------------------------------------------------------------------------------- 1 | Copyright (C) ${year} ${owner} <${email}> 2 | 3 | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.gnu.org/licenses/lgpl-3.0.txt 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/BGAPIImpl.javat: -------------------------------------------------------------------------------- 1 | package org.thingml.bgapi; 2 | 3 | import java.util.ArrayList; 4 | 5 | /** 6 | * 7 | * @author Franck FLEUREY (SINTEF) 8 | */ 9 | public class BGAPIImpl implements BGAPIPacketListener { 10 | 11 | protected BGAPI bgapi; 12 | 13 | public BGAPIImpl(BGAPI bgapi) { 14 | this.bgapi = bgapi; 15 | bgapi.addListener(this); 16 | } 17 | 18 | public ArrayList listeners = new ArrayList(); 19 | public void addListener(BGAPIListener l) { 20 | listeners.add(l); 21 | } 22 | public void removeListener(BGAPIListener l) { 23 | listeners.remove(l); 24 | } 25 | 26 | public void packetSent(BGAPIPacket packet) {} 27 | 28 | // General packet handler 29 | public void packetReceived(BGAPIPacket packet) { 30 | /*SWITCH*/ 31 | } 32 | 33 | /*SWITCHOPS*/ 34 | 35 | /*RECEIVES*/ 36 | 37 | /*SENDS*/ 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPITransportListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public interface BGAPITransportListener { 23 | void packetSent(BGAPIPacket packet); 24 | void packetReceived(BGAPIPacket packet); 25 | } 26 | -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/src/main/java/org/thingml/bglib/BGAPITransportListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public interface BGAPITransportListener { 23 | void packetSent(BGAPIPacket packet); 24 | void packetReceived(BGAPIPacket packet); 25 | } 26 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.thingml 5 | bglib-protocol-1.0.3-43 6 | 1.2.1-SNAPSHOT 7 | jar 8 | 9 | BGLib :: Protocol 1.0.3-43 10 | 11 | 12 | org.thingml 13 | bglib 14 | 1.2.1-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | junit 25 | junit 26 | 3.8.1 27 | test 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /bglib-generator/src/main/scala/BGLibGen/SimpleCopyTemplate.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package BGLibGen 17 | 18 | import xml.XML 19 | import java.util.Hashtable 20 | import io.Source 21 | 22 | object SimpleCopyTemplate { 23 | 24 | def copyFromClassPath(path : String) : String = { 25 | Source.fromInputStream(this.getClass.getClassLoader.getResourceAsStream(path),"utf-8").getLines().mkString("\n") 26 | } 27 | } 28 | 29 | 30 | -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/apitypes.h: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2000-2012 Bluegiga Technologies Inc. All rights reserved. All 3 | * unauthorized copying and distribution prohibited. 4 | ****************************************************************************/ 5 | 6 | #ifndef APITYPES_H_ 7 | #define APITYPES_H_ 8 | 9 | #ifdef __GNUC__ 10 | #define PACKED __attribute__((packed)) 11 | #define ALIGNED __attribute__((aligned(0x4))) 12 | #else 13 | #define PACKED 14 | #define ALIGNED 15 | #endif 16 | typedef unsigned char uint8; 17 | typedef unsigned short uint16; 18 | typedef signed short int16; 19 | typedef unsigned long uint32; 20 | typedef signed char int8; 21 | 22 | typedef struct bd_addr_t 23 | { 24 | uint8 addr[6]; 25 | 26 | }bd_addr; 27 | 28 | typedef bd_addr hwaddr; 29 | typedef struct 30 | { 31 | uint8 len; 32 | uint8 data[]; 33 | }uint8array; 34 | 35 | typedef struct 36 | { 37 | uint8 len; 38 | int8 data[]; 39 | }string; 40 | 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | org.thingml 6 | bglib-protocol-1.1.0-55Beta 7 | 1.0.3-SNAPSHOT 8 | jar 9 | 10 | BGLib :: Protocol 1.1.0-55 Beta 11 | 12 | 13 | org.thingml 14 | bglib 15 | 1.0.3-SNAPSHOT 16 | ../pom.xml 17 | 18 | 19 | 20 | UTF-8 21 | 22 | 23 | 24 | 25 | junit 26 | junit 27 | 3.8.1 28 | test 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEServiceValueListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | 23 | /** 24 | * 25 | * @author ffl 26 | */ 27 | public interface BLEServiceValueListener { 28 | 29 | public void receivedValue(BLEServiceInstance srv, byte[] value); 30 | public void receivedInterval(BLEServiceInstance srv, int value); 31 | 32 | } 33 | -------------------------------------------------------------------------------- /bglib-generator/src/test/scala/BGLibGen/AppTest.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package BGLibGen; 17 | 18 | import junit.framework._; 19 | import Assert._; 20 | 21 | object AppTest { 22 | def suite: Test = { 23 | val suite = new TestSuite(classOf[AppTest]); 24 | suite 25 | } 26 | 27 | def main(args : Array[String]) { 28 | junit.textui.TestRunner.run(suite); 29 | } 30 | } 31 | 32 | /** 33 | * Unit test for simple BluegigaGenerator. 34 | */ 35 | class AppTest extends TestCase("app") { 36 | 37 | /** 38 | * Rigourous Tests :-) 39 | */ 40 | def testOK() = assertTrue(true); 41 | //def testKO() = assertTrue(false); 42 | 43 | 44 | } 45 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/ByteUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.gui; 17 | 18 | /** 19 | * 20 | * @author ffl 21 | */ 22 | public class ByteUtils { 23 | 24 | public static byte[] bytesFromString(String bytes) { 25 | String[] bs = bytes.split(" "); 26 | byte[] result = new byte[bs.length]; 27 | for (int i = 0; i 2 | 4.0.0 3 | 4 | org.thingml 5 | bglib-samples 6 | 1.2.1-SNAPSHOT 7 | jar 8 | 9 | BGLib :: Samples 10 | 11 | 12 | org.thingml 13 | bglib 14 | 1.2.1-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | 25 | org.thingml 26 | bglib-protocol-1.0.3-43 27 | 1.2.1-SNAPSHOT 28 | 29 | 30 | 31 | 32 | 33 | org.kevoree.extra 34 | org.kevoree.extra.osgi.rxtx 35 | 2.2.0 36 | 37 | 38 | 39 | junit 40 | junit 41 | 3.8.1 42 | test 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/src/main/java/org/thingml/bglib/BGAPIPacketLogger.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib; 21 | 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | /** 26 | * 27 | * @author Franck FLEUREY (SINTEF) 28 | */ 29 | public class BGAPIPacketLogger implements BGAPITransportListener { 30 | 31 | public void packetSent(BGAPIPacket packet) { 32 | Logger.getLogger(BGAPIPacketLogger.class.getName()).log(Level.INFO, "SND " + packet.toString()); 33 | } 34 | 35 | public void packetReceived(BGAPIPacket packet) { 36 | Logger.getLogger(BGAPIPacketLogger.class.getName()).log(Level.INFO, "RCV " + packet.toString()); 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /bglib-samples/src/main/java/org/thingml/bglib/samples/ByteUtils.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | /** 19 | * 20 | * @author ffl 21 | */ 22 | public class ByteUtils { 23 | 24 | public static byte[] bytesFromString(String bytes) { 25 | String[] bs = bytes.split(" "); 26 | byte[] result = new byte[bs.length]; 27 | for (int i = 0; i 29 | org.thingml 30 | bglib-protocol 31 | 1.0.3-SNAPSHOT 32 | 33 | 34 | [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/SINTEF-9012/bglib/trend.png)](https://bitdeli.com/free "Bitdeli Badge") 35 | 36 | -------------------------------------------------------------------------------- /bglib-gui/src/test/java/org/thingml/bglib/gui/AppTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.gui; 17 | 18 | import junit.framework.Test; 19 | import junit.framework.TestCase; 20 | import junit.framework.TestSuite; 21 | 22 | /** 23 | * Unit test for simple App. 24 | */ 25 | public class AppTest 26 | extends TestCase 27 | { 28 | /** 29 | * Create the test case 30 | * 31 | * @param testName name of the test case 32 | */ 33 | public AppTest( String testName ) 34 | { 35 | super( testName ); 36 | } 37 | 38 | /** 39 | * @return the suite of tests being tested 40 | */ 41 | public static Test suite() 42 | { 43 | return new TestSuite( AppTest.class ); 44 | } 45 | 46 | /** 47 | * Rigourous Test :-) 48 | */ 49 | public void testApp() 50 | { 51 | assertTrue( true ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/test/java/org/thingml/bglib/AppTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | import junit.framework.Test; 19 | import junit.framework.TestCase; 20 | import junit.framework.TestSuite; 21 | 22 | /** 23 | * Unit test for simple App. 24 | */ 25 | public class AppTest 26 | extends TestCase 27 | { 28 | /** 29 | * Create the test case 30 | * 31 | * @param testName name of the test case 32 | */ 33 | public AppTest( String testName ) 34 | { 35 | super( testName ); 36 | } 37 | 38 | /** 39 | * @return the suite of tests being tested 40 | */ 41 | public static Test suite() 42 | { 43 | return new TestSuite( AppTest.class ); 44 | } 45 | 46 | /** 47 | * Rigourous Test :-) 48 | */ 49 | public void testApp() 50 | { 51 | assertTrue( true ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bglib-samples/src/test/java/org/thingml/bglib/samples/AppTest.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | import junit.framework.Test; 19 | import junit.framework.TestCase; 20 | import junit.framework.TestSuite; 21 | 22 | /** 23 | * Unit test for simple App. 24 | */ 25 | public class AppTest 26 | extends TestCase 27 | { 28 | /** 29 | * Create the test case 30 | * 31 | * @param testName name of the test case 32 | */ 33 | public AppTest( String testName ) 34 | { 35 | super( testName ); 36 | } 37 | 38 | /** 39 | * @return the suite of tests being tested 40 | */ 41 | public static Test suite() 42 | { 43 | return new TestSuite( AppTest.class ); 44 | } 45 | 46 | /** 47 | * Rigourous Test :-) 48 | */ 49 | public void testApp() 50 | { 51 | assertTrue( true ); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEAttribute.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | /** 23 | * 24 | * @author franck 25 | */ 26 | public class BLEAttribute { 27 | protected byte[] uuid; 28 | protected int handle; 29 | 30 | public BLEAttribute(byte[] uuid, int handle) { 31 | this.uuid = uuid; 32 | this.handle = handle; 33 | } 34 | 35 | public byte[] getUuid() { 36 | return uuid; 37 | } 38 | 39 | public String getUuidString() { 40 | String result = ""; 41 | for(int i = 0; i 0x" + Integer.toHexString(handle).toUpperCase(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/output.thingml: -------------------------------------------------------------------------------- 1 | /*TYPES*/ 2 | 3 | 4 | thing fragment BLED112Msgs { 5 | message bled112_connect(); 6 | message bled112_ready(); 7 | message bled112_error(); 8 | } 9 | 10 | thing fragment BLED112Ports includes BLED112Msgs { 11 | provided port bled112 { 12 | receives bled112_connect 13 | sends bled112_ready, bled112_error 14 | } 15 | } 16 | 17 | thing fragment BLED112ClientPorts includes BLED112Msgs { 18 | required port bled112 { 19 | sends bled112_connect 20 | receives bled112_ready, bled112_error 21 | } 22 | } 23 | 24 | /*MESSAGES*/ 25 | 26 | /*LIB_PORTS*/ 27 | 28 | /*CLIENT_PORTS*/ 29 | 30 | // Implemnatation of the API 31 | thing BGLibImpl includes BGLibPorts 32 | @c_header " 33 | #include \"cmd_def.h\" 34 | #include \"BLED112.h\" 35 | #include 36 | " 37 | @c_global " 38 | struct BGLibImpl_Instance *_bgapi_instance; 39 | 40 | void ble_default(const void*v){} 41 | 42 | 43 | void exit_program(int sig) { 44 | printf(\"Catched signal %d\\n\", sig); 45 | printf(\"Reseting and closing BLED112 Dongle...\\n\"); 46 | bled_close(); 47 | printf(\"Bye.\\n\"); 48 | exit(0); 49 | } 50 | 51 | " 52 | { 53 | // Fork a thread to process incoming data 54 | function start_receiver_process() 55 | @fork_linux_thread "true" 56 | do 57 | '// Open the device 58 | _bgapi_instance = _instance; 59 | int n = bled_open(); 60 | if (n < 0) {' 61 | bled112!bled112_error() 62 | 'exit(-1); 63 | } 64 | // To catch Ctrl-C signal and close the dongle properly 65 | (void) signal(SIGINT, exit_program); 66 | // Link bglib to the device 67 | bglib_output = bled_send;' 68 | bled112!bled112_ready() 69 | 'bled_process_incoming_messages();' 70 | end 71 | 72 | 73 | 74 | 75 | /*CALLBACKS*/ 76 | 77 | /*IMPL_SM*/ 78 | 79 | } -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BDAddr.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public class BDAddr { 23 | 24 | public static BDAddr fromString(String addr) { 25 | String[] bytes = addr.split(":"); 26 | if (bytes.length != 6) { 27 | throw new Error ("Invalid Bluetooth address format."); 28 | } 29 | byte[] byte_addr = new byte[6]; 30 | for (int i=0; i<6; i++) { 31 | byte_addr[5-i] = (byte)Integer.parseInt(bytes[i], 16); 32 | } 33 | return new BDAddr(byte_addr); 34 | } 35 | 36 | protected byte[] byte_addr; 37 | 38 | public byte[] getByteAddr() { 39 | return byte_addr; 40 | } 41 | 42 | public BDAddr(byte[] addr) { 43 | byte_addr = addr; 44 | } 45 | 46 | public String toString() { 47 | StringBuffer result = new StringBuffer(); 48 | for (int i=0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public class BDAddr { 23 | 24 | public static BDAddr fromString(String addr) { 25 | String[] bytes = addr.split(":"); 26 | if (bytes.length != 6) { 27 | throw new Error ("Invalid Bluetooth address format."); 28 | } 29 | byte[] byte_addr = new byte[6]; 30 | for (int i=0; i<6; i++) { 31 | byte_addr[5-i] = (byte)Integer.parseInt(bytes[i], 16); 32 | } 33 | return new BDAddr(byte_addr); 34 | } 35 | 36 | protected byte[] byte_addr; 37 | 38 | public byte[] getByteAddr() { 39 | return byte_addr; 40 | } 41 | 42 | public BDAddr(byte[] addr) { 43 | byte_addr = addr; 44 | } 45 | 46 | public String toString() { 47 | StringBuffer result = new StringBuffer(); 48 | for (int i=0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib; 21 | 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | /** 26 | * 27 | * @author Franck FLEUREY (SINTEF) 28 | */ 29 | public class BGAPIPacketLogger implements BGAPITransportListener { 30 | 31 | private long start; 32 | 33 | public BGAPIPacketLogger() { 34 | start = System.currentTimeMillis(); 35 | } 36 | 37 | private String time() { 38 | int millis_since_start = (int)(System.currentTimeMillis() - start); 39 | String ret = String.format("%d.%03d ", millis_since_start / 1000, millis_since_start % 1000); 40 | 41 | return ret; 42 | } 43 | 44 | public void packetSent(BGAPIPacket packet) { 45 | Logger.getLogger(BGAPIPacketLogger.class.getName()).log(Level.INFO, time() + "SND " + packet.toString()); 46 | } 47 | 48 | public void packetReceived(BGAPIPacket packet) { 49 | Logger.getLogger(BGAPIPacketLogger.class.getName()).log(Level.INFO, time() + "RCV " + packet.toString()); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/NativeLibUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.gui; 17 | 18 | import java.io.FileOutputStream; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | /** 26 | * 27 | * @author Francois Fouquet 28 | */ 29 | public class NativeLibUtil { 30 | 31 | 32 | 33 | public static void copyFile(InputStream in, String to) { 34 | OutputStream out = null; 35 | try { 36 | out = new FileOutputStream(to); 37 | while (true) { 38 | int data = in.read(); 39 | if (data == -1) { 40 | break; 41 | } 42 | out.write(data); 43 | } 44 | in.close(); 45 | out.close(); 46 | } catch (IOException ex) { 47 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 48 | } finally { 49 | if (in != null) { 50 | try { 51 | in.close(); 52 | } catch (IOException ex) { 53 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 54 | } 55 | } 56 | if (out != null) { 57 | try { 58 | out.close(); 59 | } catch (IOException ex) { 60 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 61 | } 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /bglib-samples/src/main/java/org/thingml/bglib/samples/NativeLibUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | import java.io.FileOutputStream; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | import java.util.logging.Level; 23 | import java.util.logging.Logger; 24 | 25 | /** 26 | * 27 | * @author Francois Fouquet 28 | */ 29 | public class NativeLibUtil { 30 | 31 | 32 | 33 | public static void copyFile(InputStream in, String to) { 34 | OutputStream out = null; 35 | try { 36 | out = new FileOutputStream(to); 37 | while (true) { 38 | int data = in.read(); 39 | if (data == -1) { 40 | break; 41 | } 42 | out.write(data); 43 | } 44 | in.close(); 45 | out.close(); 46 | } catch (IOException ex) { 47 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 48 | } finally { 49 | if (in != null) { 50 | try { 51 | in.close(); 52 | } catch (IOException ex) { 53 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 54 | } 55 | } 56 | if (out != null) { 57 | try { 58 | out.close(); 59 | } catch (IOException ex) { 60 | Logger.getLogger(NativeLibUtil.class.getName()).log(Level.SEVERE, null, ex); 61 | } 62 | } 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEDeviceList.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | import java.util.ArrayList; 23 | import java.util.EventListener; 24 | import java.util.Hashtable; 25 | import javax.swing.AbstractListModel; 26 | import javax.swing.ListModel; 27 | import javax.swing.event.ListDataListener; 28 | 29 | /** 30 | * 31 | * @author ffl 32 | */ 33 | public class BLEDeviceList extends AbstractListModel { 34 | 35 | protected ArrayList devices = new ArrayList(); 36 | /* 37 | public ArrayList getDevices() { 38 | return devices; 39 | } 40 | */ 41 | 42 | public void clear() { 43 | int idx = devices.size() - 1; 44 | if (idx < 0) return; 45 | devices.clear(); 46 | fireIntervalRemoved(this, 0, idx); 47 | } 48 | 49 | public void add(BLEDevice d) { 50 | devices.add(d); 51 | fireIntervalAdded(this, 0, devices.size()-1); 52 | } 53 | 54 | public void changed(BLEDevice d) { 55 | if (devices.isEmpty()) return; 56 | fireContentsChanged(this, 0, getSize()-1); 57 | } 58 | 59 | public BLEDevice getFromAddress(String address) { 60 | for (BLEDevice d : devices) { 61 | if (d.address.equals(address)) return d; 62 | } 63 | return null; 64 | } 65 | 66 | public int getSize() { 67 | return devices.size(); 68 | } 69 | 70 | public Object getElementAt(int index) { 71 | return devices.get(index); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEService.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | import java.util.ArrayList; 23 | import java.util.Hashtable; 24 | 25 | /** 26 | * 27 | * @author franck 28 | */ 29 | public class BLEService { 30 | 31 | public static Hashtable profiles = new Hashtable(); 32 | static { 33 | profiles.put("0x180A", ""); 34 | } 35 | 36 | 37 | protected int start, end; 38 | protected byte[] uuid; 39 | 40 | protected ArrayList attributes = new ArrayList(); 41 | 42 | public BLEService(byte[] uuid, int start, int end) { 43 | this.uuid = uuid; 44 | this.start = start; 45 | this.end = end; 46 | } 47 | 48 | public int getStart() { 49 | return start; 50 | } 51 | 52 | public int getEnd() { 53 | return end; 54 | } 55 | 56 | public byte[] getUuid() { 57 | return uuid; 58 | } 59 | 60 | public ArrayList getAttributes() { 61 | return attributes; 62 | } 63 | 64 | public String getUuidString() { 65 | String result = ""; 66 | for(int i = 0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | import java.util.Hashtable; 23 | import org.thingml.bglib.BGAPI; 24 | 25 | /** 26 | * 27 | * @author franck 28 | */ 29 | public class BLEDevice { 30 | 31 | protected String address; 32 | protected String name; 33 | protected int rssi; 34 | 35 | protected Hashtable services = new Hashtable(); 36 | 37 | public Hashtable getServices() { 38 | return services; 39 | } 40 | 41 | public String getGATTDescription() { 42 | String result = toString(); 43 | for (BLEService s : services.values()) { 44 | result += "\n" + s.getDescription(); 45 | } 46 | return result; 47 | } 48 | 49 | public BLEDevice(String address) { 50 | this.address = address; 51 | name = ""; 52 | } 53 | 54 | public String getAddress() { 55 | return address; 56 | } 57 | 58 | public String getName() { 59 | return name; 60 | } 61 | 62 | public int getRssi() { 63 | return rssi; 64 | } 65 | 66 | public void setName(String name) { 67 | this.name = name; 68 | } 69 | 70 | public void setRssi(int rssi) { 71 | this.rssi = rssi; 72 | } 73 | 74 | public String toString() { 75 | return name + " [" + address + "] (" + rssi + " dBm)"; 76 | } 77 | 78 | public String bytesToString(byte[] bytes) { 79 | StringBuffer result = new StringBuffer(); 80 | result.append("[ "); 81 | for(byte b : bytes) result.append( Integer.toHexString(b & 0xFF) + " "); 82 | result.append("]"); 83 | return result.toString(); 84 | } 85 | 86 | } 87 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPIPacketReader.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public class BGAPIPacketReader { 23 | 24 | private byte[] data; 25 | private int index; 26 | 27 | public BGAPIPacketReader(byte[] data) { 28 | this.data = data; 29 | } 30 | 31 | public void reset() { 32 | index = 0; 33 | } 34 | 35 | public int length() { 36 | return data.length; 37 | } 38 | 39 | public int bytesLeft() { 40 | return data.length - index; 41 | } 42 | 43 | private Integer next_uint() { 44 | return data[index++] & 0xFF; 45 | } 46 | 47 | public int r_int8() { 48 | return (int)data[index++]; 49 | } 50 | 51 | public int r_uint8() { 52 | return (int)next_uint(); 53 | } 54 | 55 | public int r_uint16() { 56 | int result = (int)next_uint(); 57 | result += (int)(next_uint()<<8); 58 | return result; 59 | } 60 | public int r_int16() { 61 | int result = (int)next_uint(); 62 | result += (int)(next_uint()<<8); 63 | return result; 64 | } 65 | 66 | 67 | public int r_uint32() { 68 | int result = (int)next_uint(); 69 | result += (int)(next_uint()<<8); 70 | result += (int)(next_uint()<<16); 71 | result += (int)(next_uint()<<24); 72 | return result; 73 | } 74 | 75 | public byte[] r_uint8array() { 76 | byte[] result = new byte[next_uint()]; 77 | for (int i=0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | /** 19 | * 20 | * @author Franck FLEUREY (SINTEF) 21 | */ 22 | public class BGAPIPacketReader { 23 | 24 | private byte[] data; 25 | private int index; 26 | 27 | public BGAPIPacketReader(byte[] data) { 28 | this.data = data; 29 | } 30 | 31 | public void reset() { 32 | index = 0; 33 | } 34 | 35 | public int length() { 36 | return data.length; 37 | } 38 | 39 | public int bytesLeft() { 40 | return data.length - index; 41 | } 42 | 43 | private Integer next_uint() { 44 | return data[index++] & 0xFF; 45 | } 46 | 47 | public int r_int8() { 48 | return (int)data[index++]; 49 | } 50 | 51 | public int r_uint8() { 52 | return (int)next_uint(); 53 | } 54 | 55 | public int r_uint16() { 56 | int result = (int)next_uint(); 57 | result += (int)(next_uint()<<8); 58 | return result; 59 | } 60 | public int r_int16() { 61 | int result = (int)next_uint(); 62 | result += (int)(next_uint()<<8); 63 | return result; 64 | } 65 | 66 | 67 | public int r_uint32() { 68 | int result = (int)next_uint(); 69 | result += (int)(next_uint()<<8); 70 | result += (int)(next_uint()<<16); 71 | result += (int)(next_uint()<<24); 72 | return result; 73 | } 74 | 75 | public byte[] r_uint8array() { 76 | byte[] result = new byte[next_uint()]; 77 | for (int i=0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | import java.util.logging.Level; 19 | import java.util.logging.Logger; 20 | import org.thingml.bglib.BGAPIPacket; 21 | import org.thingml.bglib.BGAPIPacketReader; 22 | import org.thingml.bglib.BGAPITransport; 23 | import org.thingml.bglib.BGAPITransportListener; 24 | 25 | public class CheckBGAPIVersion implements BGAPITransportListener 26 | { 27 | 28 | 29 | public static void main( String[] args ) 30 | { 31 | System.out.println( "Connecting BLED112 Dongle..." ); 32 | BGAPITransport bgapi = BLED112.connectBLED112(); 33 | bgapi.addListener(new CheckBGAPIVersion()); 34 | //bgapi.addListener(new BGAPIPacketLogger()); 35 | try { 36 | Thread.sleep(500); 37 | } catch (InterruptedException ex) { 38 | Logger.getLogger(CheckBGAPIVersion.class.getName()).log(Level.SEVERE, null, ex); 39 | } 40 | System.out.println( "Requesting Version Number..." ); 41 | BGAPIPacket p = new BGAPIPacket(0, 0, 8); // Get Info Packet 42 | bgapi.sendPacket(p); 43 | 44 | } 45 | 46 | public void packetSent(BGAPIPacket packet) {} 47 | 48 | public void packetReceived(BGAPIPacket packet) { 49 | System.out.println("Received: " + packet.toString()); 50 | if (packet.getClassID() == 0 && packet.getCommandID() == 8) { 51 | BGAPIPacketReader r = packet.getPayloadReader(); 52 | Integer major = r.r_uint16(); 53 | Integer minor = r.r_uint16(); 54 | Integer patch = r.r_uint16(); 55 | Integer build = r.r_uint16(); 56 | Integer ll_version = r.r_uint16(); 57 | Integer protocol_version = r.r_uint8(); 58 | Integer hw = r.r_uint8(); 59 | System.out.println("get_info_rsp :" + major + "." + minor + "." + patch + " (" + build + ") " + "ll=" + ll_version + " hw=" + hw); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /bglib-samples/src/main/java/org/thingml/bglib/samples/SimpleDiscovery.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | import java.util.logging.Level; 19 | import java.util.logging.Logger; 20 | import org.thingml.bglib.BDAddr; 21 | import org.thingml.bglib.BGAPI; 22 | import org.thingml.bglib.BGAPIDefaultListener; 23 | import org.thingml.bglib.BGAPIPacketLogger; 24 | import org.thingml.bglib.BGAPITransport; 25 | 26 | public class SimpleDiscovery extends BGAPIDefaultListener 27 | { 28 | 29 | 30 | public static void main( String[] args ) 31 | { 32 | System.out.println( "Connecting BLED112 Dongle..." ); 33 | BGAPITransport bgapi = BLED112.connectBLED112(); 34 | bgapi.addListener(new BGAPIPacketLogger()); 35 | BGAPI impl = new BGAPI(bgapi); 36 | impl.addListener(new SimpleDiscovery()); 37 | 38 | try { 39 | Thread.sleep(500); 40 | } catch (InterruptedException ex) { 41 | Logger.getLogger(SimpleDiscovery.class.getName()).log(Level.SEVERE, null, ex); 42 | } 43 | System.out.println( "Requesting Version Number..." ); 44 | impl.send_system_get_info(); 45 | impl.send_system_hello(); 46 | impl.send_gap_set_scan_parameters(10, 250, 1); 47 | impl.send_gap_discover(1); 48 | 49 | } 50 | 51 | public void receive_system_get_info(Integer major, Integer minor, Integer patch, Integer build, Integer ll_version, Integer protocol_version, Integer hw) { 52 | System.out.println("get_info_rsp :" + major + "." + minor + "." + patch + " (" + build + ") " + "ll=" + ll_version + " hw=" + hw); 53 | } 54 | 55 | public void receive_gap_scan_response(Integer rssi, Integer packet_type, BDAddr sender, Integer address_type, Integer bond, byte[] data) { 56 | System.out.println("FOUND: " + sender.toString() + "["+ new String(data).trim() + "] (rssi = " + rssi + ", packet type= " + packet_type + ")"); 57 | } 58 | 59 | @Override 60 | public void receive_system_hello() { 61 | System.out.println("GOT HELLO!"); 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /bglib-generator/pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | BGLibGen 5 | BGLibGen 6 | 1.0 7 | 2008 8 | 9 | 2.9.1 10 | 11 | 12 | 13 | 14 | scala-tools.org 15 | Scala-Tools Maven2 Repository 16 | http://scala-tools.org/repo-releases 17 | 18 | 19 | 20 | 21 | 22 | scala-tools.org 23 | Scala-Tools Maven2 Repository 24 | http://scala-tools.org/repo-releases 25 | 26 | 27 | 28 | 29 | 30 | org.scala-lang 31 | scala-library 32 | ${scala.version} 33 | 34 | 35 | junit 36 | junit 37 | 3.8.1 38 | test 39 | 40 | 41 | 42 | 43 | src/main/scala 44 | src/test/scala 45 | 46 | 47 | org.scala-tools 48 | maven-scala-plugin 49 | 50 | 51 | 52 | compile 53 | testCompile 54 | 55 | 56 | 57 | 58 | ${scala.version} 59 | 60 | 61 | 62 | org.apache.maven.plugins 63 | maven-eclipse-plugin 64 | 65 | true 66 | 67 | ch.epfl.lamp.sdt.core.scalabuilder 68 | 69 | 70 | ch.epfl.lamp.sdt.core.scalanature 71 | 72 | 73 | org.eclipse.jdt.launching.JRE_CONTAINER 74 | ch.epfl.lamp.sdt.launching.SCALA_CONTAINER 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | org.scala-tools 84 | maven-scala-plugin 85 | 86 | ${scala.version} 87 | 88 | 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEServiceInstance.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | import java.util.ArrayList; 23 | import org.thingml.bglib.BGAPIDefaultListener; 24 | import org.thingml.bglib.BGAPI; 25 | 26 | /** 27 | * 28 | * @author ffl 29 | */ 30 | public class BLEServiceInstance extends BGAPIDefaultListener { 31 | 32 | public ArrayList listeners = new ArrayList(); 33 | 34 | public void addBLEServiceValueListener(BLEServiceValueListener l) { 35 | listeners.add(l); 36 | } 37 | 38 | public void removeBLEServiceValueListener(BLEServiceValueListener l) { 39 | listeners.remove(l); 40 | } 41 | 42 | protected BGAPI bgapi; 43 | protected int connection; 44 | protected int value_handle; 45 | protected int interval_handle; 46 | protected int config_handle; 47 | 48 | public BGAPI getBgapi() { 49 | return bgapi; 50 | } 51 | 52 | public int getConnection() { 53 | return connection; 54 | } 55 | 56 | public int getValue_handle() { 57 | return value_handle; 58 | } 59 | 60 | public int getInterval_handle() { 61 | return interval_handle; 62 | } 63 | 64 | public int getConfig_handle() { 65 | return config_handle; 66 | } 67 | 68 | public BLEServiceInstance(BGAPI bgapi, int connection, int value_handle, int interval_handle, int config_handle) { 69 | this.bgapi = bgapi; 70 | this.connection = connection; 71 | this.value_handle = value_handle; 72 | this.interval_handle = interval_handle; 73 | this.config_handle = config_handle; 74 | bgapi.addListener(this); 75 | } 76 | 77 | public void disconnect(){ 78 | bgapi.removeListener(this); 79 | } 80 | 81 | public BLEServiceInstance(BGAPI bgapi, int connection, BLEService srv) { 82 | // TODO: Impelment 83 | throw new Error("Not Implemented"); 84 | } 85 | 86 | public void subscribeIndications() { 87 | bgapi.send_attclient_write_command(connection, config_handle, new byte[]{0x02, 0x00}); 88 | } 89 | 90 | public void subscribeNotifications() { 91 | bgapi.send_attclient_write_command(connection, config_handle, new byte[]{0x01, 0x00}); 92 | } 93 | public void unsubscribe() { 94 | bgapi.send_attclient_write_command(connection, config_handle, new byte[]{0x00, 0x00}); 95 | } 96 | 97 | public void writeInterval(int value) { 98 | byte[] i = new byte[2]; 99 | i[0] = (byte)((value>>8) & 0xFF); 100 | i[1] = (byte)(value & 0xFF); 101 | bgapi.send_attclient_write_command(connection, interval_handle, i); 102 | } 103 | 104 | public void readInterval() { 105 | bgapi.send_attclient_read_by_handle(connection, interval_handle); 106 | } 107 | 108 | 109 | @Override 110 | public void receive_attclient_attribute_value(int conn, int atthandle, int type, byte[] value) { 111 | if (connection == conn) { 112 | if (atthandle == value_handle) { 113 | for (BLEServiceValueListener l : listeners) { 114 | l.receivedValue(this, value); 115 | } 116 | } 117 | else if (atthandle == interval_handle) { 118 | for (BLEServiceValueListener l : listeners) { 119 | l.receivedInterval(this, (value[0]<<8) + (value[1] & 0xFF)); 120 | } 121 | } 122 | } 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPIPacket.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | import java.io.ByteArrayOutputStream; 19 | import java.io.IOException; 20 | import java.util.logging.Level; 21 | import java.util.logging.Logger; 22 | 23 | /** 24 | * 25 | * @author Franck FLEUREY (SINTEF) 26 | */ 27 | public class BGAPIPacket { 28 | 29 | protected int msgType; 30 | protected int classID; 31 | protected int commandID; 32 | protected int payloadLength = -1; 33 | 34 | public int getClassID() { 35 | return classID; 36 | } 37 | 38 | public int getCommandID() { 39 | return commandID; 40 | } 41 | 42 | public int getMsgType() { 43 | return msgType; 44 | } 45 | 46 | public int getPayloadLength() { 47 | return payloadLength; 48 | } 49 | 50 | protected ByteArrayOutputStream data = new ByteArrayOutputStream(); 51 | 52 | public ByteArrayOutputStream getPayloadData() { 53 | return data; 54 | } 55 | 56 | public BGAPIPacket(byte[] header) { 57 | msgType = (header[0] & 0xFF) >> 7; 58 | payloadLength = ((header[0] & 0x07) << 8) + header[1]; 59 | classID = header[2]; 60 | commandID = header[3]; 61 | } 62 | 63 | public BGAPIPacket(int msg_type, int classID, int commandID) { 64 | this.msgType = msg_type; 65 | this.classID = classID; 66 | this.commandID = commandID; 67 | } 68 | 69 | public String toString() { 70 | StringBuffer result = new StringBuffer(); 71 | result.append("< typ=" + msgType + " cla=" + classID + " cmd=" + commandID + " len=" + payloadLength + " "); 72 | if (data.size() > 0) { 73 | byte[] bytes = data.toByteArray(); 74 | result.append( "[ "); 75 | for (byte b : bytes) result.append( Integer.toHexString((int) (b & 0xFF)) + " "); 76 | result.append( "] "); 77 | } 78 | result.append(">"); 79 | return result.toString(); 80 | } 81 | 82 | public BGAPIPacketReader getPayloadReader() { 83 | return new BGAPIPacketReader(data.toByteArray()); 84 | } 85 | 86 | public byte[] getPacketBytes() { 87 | ByteArrayOutputStream result = new ByteArrayOutputStream(); 88 | payloadLength = data.size(); 89 | result.write( (msgType << 7) + (payloadLength >> 8) ); 90 | result.write( payloadLength & 0xFF ); 91 | result.write( classID & 0xFF ); 92 | result.write( commandID & 0xFF ); 93 | try { 94 | result.write( data.toByteArray() ); 95 | } catch (IOException ex) { 96 | Logger.getLogger(BGAPIPacket.class.getName()).log(Level.SEVERE, null, ex); 97 | } 98 | return result.toByteArray(); 99 | } 100 | 101 | public void w_uint8(int v) { 102 | data.write(v & 0xFF); 103 | } 104 | public void w_int8(int v) { 105 | data.write(v); 106 | } 107 | 108 | 109 | public void w_uint16(int v) { 110 | data.write(v & 0xFF); 111 | data.write((v >> 8) & 0xFF); 112 | } 113 | 114 | public void w_int16(int v) { 115 | data.write(v & 0xFF); 116 | data.write((v >> 8) & 0xFF); 117 | } 118 | 119 | public void w_uint32(int v) { 120 | data.write(v & 0xFF); 121 | data.write((v >> 8) & 0xFF); 122 | data.write((v >> 16) & 0xFF); 123 | data.write((v >> 24) & 0xFF); 124 | } 125 | 126 | public void w_uint8array(byte[] bytes) { 127 | data.write(bytes.length); 128 | for (int i=0; i 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | import java.io.ByteArrayOutputStream; 19 | import java.io.IOException; 20 | import java.util.logging.Level; 21 | import java.util.logging.Logger; 22 | 23 | /** 24 | * 25 | * @author Franck FLEUREY (SINTEF) 26 | */ 27 | public class BGAPIPacket { 28 | 29 | protected int msgType; 30 | protected int classID; 31 | protected int commandID; 32 | protected int payloadLength = -1; 33 | 34 | public int getClassID() { 35 | return classID; 36 | } 37 | 38 | public int getCommandID() { 39 | return commandID; 40 | } 41 | 42 | public int getMsgType() { 43 | return msgType; 44 | } 45 | 46 | public int getPayloadLength() { 47 | return payloadLength; 48 | } 49 | 50 | protected ByteArrayOutputStream data = new ByteArrayOutputStream(); 51 | 52 | public ByteArrayOutputStream getPayloadData() { 53 | return data; 54 | } 55 | 56 | public BGAPIPacket(byte[] header) { 57 | msgType = (header[0] & 0xFF) >> 7; 58 | payloadLength = ((header[0] & 0x07) << 8) + header[1]; 59 | classID = header[2]; 60 | commandID = header[3]; 61 | } 62 | 63 | public BGAPIPacket(int msg_type, int classID, int commandID) { 64 | this.msgType = msg_type; 65 | this.classID = classID; 66 | this.commandID = commandID; 67 | } 68 | 69 | public String toString() { 70 | StringBuffer result = new StringBuffer(); 71 | result.append("< typ=" + msgType + " cla=" + classID + " cmd=" + commandID + " len=" + payloadLength + " "); 72 | if (data.size() > 0) { 73 | byte[] bytes = data.toByteArray(); 74 | result.append( "[ "); 75 | for (byte b : bytes) result.append( Integer.toHexString((int) (b & 0xFF)) + " "); 76 | result.append( "] "); 77 | } 78 | result.append(">"); 79 | return result.toString(); 80 | } 81 | 82 | public BGAPIPacketReader getPayloadReader() { 83 | return new BGAPIPacketReader(data.toByteArray()); 84 | } 85 | 86 | public byte[] getPacketBytes() { 87 | ByteArrayOutputStream result = new ByteArrayOutputStream(); 88 | payloadLength = data.size(); 89 | result.write( (msgType << 7) + (payloadLength >> 8) ); 90 | result.write( payloadLength & 0xFF ); 91 | result.write( classID & 0xFF ); 92 | result.write( commandID & 0xFF ); 93 | try { 94 | result.write( data.toByteArray() ); 95 | } catch (IOException ex) { 96 | Logger.getLogger(BGAPIPacket.class.getName()).log(Level.SEVERE, null, ex); 97 | } 98 | return result.toByteArray(); 99 | } 100 | 101 | public void w_uint8(int v) { 102 | data.write(v & 0xFF); 103 | } 104 | public void w_int8(int v) { 105 | data.write(v); 106 | } 107 | 108 | 109 | public void w_uint16(int v) { 110 | data.write(v & 0xFF); 111 | data.write((v >> 8) & 0xFF); 112 | } 113 | 114 | public void w_int16(int v) { 115 | data.write(v & 0xFF); 116 | data.write((v >> 8) & 0xFF); 117 | } 118 | 119 | public void w_uint32(int v) { 120 | data.write(v & 0xFF); 121 | data.write((v >> 8) & 0xFF); 122 | data.write((v >> 16) & 0xFF); 123 | data.write((v >> 24) & 0xFF); 124 | } 125 | 126 | public void w_uint8array(byte[] bytes) { 127 | data.write(bytes.length); 128 | for (int i=0; i 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
101 | -------------------------------------------------------------------------------- /bglib-gui/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | 4 | org.thingml 5 | bglib-gui 6 | 1.2.1-SNAPSHOT 7 | jar 8 | 9 | BGLib :: GUI 10 | 11 | 12 | org.thingml 13 | bglib 14 | 1.2.1-SNAPSHOT 15 | ../pom.xml 16 | 17 | 18 | 19 | UTF-8 20 | 21 | 22 | 23 | 24 | 25 | maven-compiler-plugin 26 | 2.3.2 27 | 28 | 1.6 29 | 1.6 30 | 31 | 32 | 33 | 34 | maven-assembly-plugin 35 | 36 | 37 | 38 | org.thingml.bglib.gui.BLEExplorerFrame 39 | 40 | 41 | 42 | jar-with-dependencies 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.apache.maven.plugins 50 | maven-jar-plugin 51 | 2.3.1 52 | 53 | 54 | 55 | org.thingml.bglib.gui.BLEExplorerFrame 56 | 57 | 58 | 59 | 60 | 61 | 62 | deploy 63 | 64 | sign 65 | 66 | 67 | ${project.build.directory}/${project.build.finalName}-jar-with-dependencies.jar 68 | /home/franck/thingml.ks 69 | thingml 70 | thingmlkeystore 71 | ${project.build.directory}/${project.build.finalName}-jar-with-dependencies-signed.jar 72 | true 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | com.github.goldin 82 | copy-maven-plugin 83 | 0.2.5 84 | 85 | 86 | create-archive 87 | deploy 88 | 89 | copy 90 | 91 | 92 | 93 | 94 | 95 | /var/www/dist/ble 96 | ${basedir}/BLEExplorer.jnlp 97 | BLEExplorer.jnlp 98 | 99 | 100 | /var/www/dist/ble 101 | 102 | ${project.build.directory}/${project.build.finalName}-jar-with-dependencies-signed.jar 103 | 104 | BLEExplorer.jar 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | org.thingml 120 | bglib-protocol-1.0.3-43 121 | 1.2.1-SNAPSHOT 122 | 123 | 124 | 125 | org.kevoree.extra 126 | org.kevoree.extra.osgi.rxtx 127 | 2.2.0 128 | 129 | 130 | 131 | junit 132 | junit 133 | 3.8.1 134 | test 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/src/main/java/org/thingml/bglib/BGAPITransport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | import java.io.IOError; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | import java.util.ArrayList; 23 | import java.util.logging.Level; 24 | import java.util.logging.Logger; 25 | 26 | /** 27 | * 28 | * @author Franck FLEUREY (SINTEF) 29 | */ 30 | public class BGAPITransport implements Runnable { 31 | 32 | protected ArrayList listeners = new ArrayList(); 33 | public void addListener(BGAPITransportListener l) { 34 | listeners.add(l); 35 | } 36 | public void removeListener(BGAPITransportListener l) { 37 | listeners.remove(l); 38 | } 39 | 40 | protected InputStream in; 41 | protected OutputStream out; 42 | 43 | private Thread rxthread = null; 44 | 45 | private long receivedBytes = 0; 46 | 47 | public long getReceivedBytes() { 48 | return receivedBytes; 49 | } 50 | 51 | public BGAPITransport(InputStream in, OutputStream out) { 52 | this.in = in; 53 | this.out = out; 54 | rxthread = new Thread(this); 55 | rxthread.start(); 56 | } 57 | 58 | public void sendPacket(BGAPIPacket p) { 59 | try { 60 | out.write(p.getPacketBytes()); 61 | } catch (IOException ex) { 62 | Logger.getLogger(BGAPITransport.class.getName()).log(Level.SEVERE, null, ex); 63 | throw new IOError(ex); 64 | } 65 | for(BGAPITransportListener l : listeners) l.packetSent(p); 66 | } 67 | 68 | 69 | 70 | /************************************************************************** 71 | * CODE OF THE RECEIVER THREAD 72 | *************************************************************************/ 73 | 74 | public void stop() { 75 | terminate = true; 76 | } 77 | 78 | public void run() { 79 | 80 | byte[] buffer = new byte[1024]; 81 | byte[] hdr = new byte[HEADER_SIZE]; 82 | //byte[] data = new byte[2048]; 83 | int len = -1; 84 | int idx = 0; 85 | int state = WAITING; 86 | BGAPIPacket p = null; 87 | 88 | 89 | try { 90 | //System.out.println("Receiver Thread Started."); 91 | while (!terminate && ((len = this.in.read(buffer)) > -1)) { 92 | receivedBytes += len; 93 | 94 | for (int i = 0; i < len; i++) { 95 | byte c = buffer[i]; 96 | if (state == WAITING) { 97 | idx = 0; 98 | state = HEADER; 99 | hdr[idx++] = c; 100 | } 101 | else if (state == HEADER) { 102 | hdr[idx++] = c; 103 | if (idx == HEADER_SIZE) { // We got the whole header 104 | p = new BGAPIPacket(hdr); 105 | //System.out.println("Got Header" + p.toString()); 106 | 107 | if (p.getPayloadLength() > 0) { // there is a payload 108 | state = PAYLOAD; 109 | idx = 0; 110 | } 111 | else { // There is no payload 112 | state = WAITING; 113 | for (BGAPITransportListener l : listeners) l.packetReceived(p); 114 | p = null; 115 | } 116 | } 117 | } 118 | else if (state == PAYLOAD) { 119 | p.getPayloadData().write(c); 120 | idx++; 121 | if (idx == p.getPayloadLength()) { // We got a complete message 122 | state = WAITING; 123 | for (BGAPITransportListener l : listeners) l.packetReceived(p); 124 | p = null; 125 | } 126 | } 127 | } 128 | } 129 | } catch (IOException e) { 130 | e.printStackTrace(); 131 | } 132 | try { 133 | in.close(); 134 | } catch (IOException ex) { 135 | ex.printStackTrace(); 136 | } 137 | 138 | System.err.println("BLED112: Receiver thread stopped."); 139 | } 140 | 141 | private boolean terminate = false; 142 | 143 | private static final int WAITING = 0; 144 | private static final int HEADER = 1; 145 | private static final int PAYLOAD = 2; 146 | 147 | private static final int HEADER_SIZE = 4; 148 | 149 | } 150 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | org.thingml 4 | bglib 5 | pom 6 | BGLib :: Root 7 | https://github.com/SINTEF-9012/bglib 8 | 9 | 10 | 11 | Franck Fleurey 12 | franck.fleurey@sintef.no 13 | 14 | 15 | 16 | 17 | SINTEF 18 | http://www.sintef.no 19 | 20 | 21 | 22 | 23 | LGPL 24 | http://www.gnu.org/licenses/lgpl-3.0.txt 25 | repo 26 | 27 | 28 | 29 | 1.2.1-SNAPSHOT 30 | 31 | 32 | UTF-8 33 | ${project.version} 34 | SINTEF 35 | 36 | 37 | 38 | bglib-protocol-1.0.3-43 39 | bglib-samples 40 | bglib-gui 41 | 42 | 43 | 44 | 45 | 46 | false 47 | com.mycila.maven-license-plugin 48 | maven-license-plugin 49 | 1.9.0 50 | 51 | ${basedir} 52 |
${basedir}/HEADER
53 | true 54 | 55 | SINTEF 56 | 2012 57 | franck.fleurey@sintef.no 58 | 59 | 60 | 61 | **/*.cs 62 | 63 | 64 | **/test_out/**/*.* 65 | 66 | 67 | **/resources/**/**.* 68 | 69 | 70 |
71 | 72 | 73 | process-sources 74 | 75 | format 76 | 77 | 78 | 79 |
80 | 81 | 82 | 83 | org.apache.maven.plugins 84 | maven-compiler-plugin 85 | 2.3.2 86 | 87 | 1.6 88 | 1.6 89 | ${project.build.sourceEncoding} 90 | 91 | 92 | 93 | 94 | org.apache.maven.plugins 95 | maven-resources-plugin 96 | 2.4.3 97 | 98 | ${project.build.sourceEncoding} 99 | 100 | 101 | 102 | 103 | org.apache.maven.plugins 104 | maven-release-plugin 105 | 2.3.2 106 | 107 | https://svn.apache.org/repos/asf/maven/components/releases 108 | 109 | 110 | 111 |
112 |
113 | 114 | 115 | 116 | 117 | thingml-snapshot 118 | thingml-snapshot 119 | http://maven.thingml.org/thingml-snapshot/ 120 | 121 | 122 | 123 | thingml-release 124 | thingml-release 125 | http://maven.thingml.org/thingml-release/ 126 | 127 | 128 | 129 | thirdparty 130 | thirdparty 131 | http://maven.thingml.org/thirdparty/ 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | thingml-release 140 | thingml-release 141 | http://maven.thingml.org/archiva/repository/thingml-release/ 142 | 143 | 144 | 145 | thingml-snapshot 146 | thingml-snapshot 147 | http://maven.thingml.org/archiva/repository/thingml-snapshot/ 148 | 149 | 150 | 151 | 152 | 153 | scm:git:git@github.com:SINTEF-9012/bglib.git 154 | scm:git:git@github.com:SINTEF-9012/bglib.git 155 | scm:git:git@github.com:SINTEF-9012/bglib.git 156 | HEAD 157 | 158 | 159 |
-------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPITransport.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | 18 | import java.io.IOError; 19 | import java.io.IOException; 20 | import java.io.InputStream; 21 | import java.io.OutputStream; 22 | //import java.util.ArrayList; 23 | import java.util.Iterator; 24 | import java.util.List; 25 | import java.util.concurrent.CopyOnWriteArrayList; 26 | import java.util.logging.Level; 27 | import java.util.logging.Logger; 28 | 29 | /** 30 | * 31 | * @author Franck FLEUREY (SINTEF) 32 | */ 33 | public class BGAPITransport implements Runnable { 34 | 35 | //protected ArrayList listeners = new ArrayList(); 36 | protected List listeners = new CopyOnWriteArrayList(); 37 | public void addListener(BGAPITransportListener l) { 38 | listeners.add(l); 39 | } 40 | public void removeListener(BGAPITransportListener l) { 41 | listeners.remove(l); 42 | } 43 | 44 | protected InputStream in; 45 | protected OutputStream out; 46 | 47 | private Thread rxthread = null; 48 | 49 | private long receivedBytes = 0; 50 | 51 | public long getReceivedBytes() { 52 | return receivedBytes; 53 | } 54 | 55 | public BGAPITransport(InputStream in, OutputStream out) { 56 | this.in = in; 57 | this.out = out; 58 | rxthread = new Thread(this); 59 | rxthread.start(); 60 | } 61 | 62 | public void sendPacket(BGAPIPacket p) { 63 | try { 64 | out.write(p.getPacketBytes()); 65 | } catch (IOException ex) { 66 | Logger.getLogger(BGAPITransport.class.getName()).log(Level.SEVERE, null, ex); 67 | throw new IOError(ex); 68 | } 69 | Iterator iter = listeners.iterator(); 70 | while(iter.hasNext()) { 71 | ((BGAPITransportListener)(iter.next())).packetSent(p); 72 | } 73 | //for(BGAPITransportListener l : listeners) l.packetSent(p); 74 | } 75 | 76 | 77 | 78 | /************************************************************************** 79 | * CODE OF THE RECEIVER THREAD 80 | *************************************************************************/ 81 | 82 | public void stop() { 83 | terminate = true; 84 | } 85 | 86 | public void run() { 87 | 88 | byte[] buffer = new byte[1024]; 89 | byte[] hdr = new byte[HEADER_SIZE]; 90 | //byte[] data = new byte[2048]; 91 | int len = -1; 92 | int idx = 0; 93 | int state = WAITING; 94 | BGAPIPacket p = null; 95 | 96 | 97 | try { 98 | //System.out.println("Receiver Thread Started."); 99 | while (!terminate && ((len = this.in.read(buffer)) > -1)) { 100 | receivedBytes += len; 101 | 102 | for (int i = 0; i < len; i++) { 103 | byte c = buffer[i]; 104 | if (state == WAITING) { 105 | idx = 0; 106 | state = HEADER; 107 | hdr[idx++] = c; 108 | } 109 | else if (state == HEADER) { 110 | hdr[idx++] = c; 111 | if (idx == HEADER_SIZE) { // We got the whole header 112 | p = new BGAPIPacket(hdr); 113 | //System.out.println("Got Header" + p.toString()); 114 | 115 | if (p.getPayloadLength() > 0) { // there is a payload 116 | state = PAYLOAD; 117 | idx = 0; 118 | } 119 | else { // There is no payload 120 | state = WAITING; 121 | Iterator iter = listeners.iterator(); 122 | while(iter.hasNext()) { 123 | ((BGAPITransportListener)(iter.next())).packetReceived(p); 124 | } 125 | //for (BGAPITransportListener l : listeners) l.packetReceived(p); 126 | p = null; 127 | } 128 | } 129 | } 130 | else if (state == PAYLOAD) { 131 | p.getPayloadData().write(c); 132 | idx++; 133 | if (idx == p.getPayloadLength()) { // We got a complete message 134 | state = WAITING; 135 | Iterator iter = listeners.iterator(); 136 | while(iter.hasNext()) { 137 | ((BGAPITransportListener)(iter.next())).packetReceived(p); 138 | } 139 | //for (BGAPITransportListener l : listeners) l.packetReceived(p); 140 | p = null; 141 | } 142 | } 143 | } 144 | } 145 | } catch (IOException e) { 146 | e.printStackTrace(); 147 | } 148 | try { 149 | in.close(); 150 | } catch (IOException ex) { 151 | ex.printStackTrace(); 152 | } 153 | 154 | System.err.println("BLED112: Receiver thread stopped."); 155 | } 156 | 157 | private boolean terminate = false; 158 | 159 | private static final int WAITING = 0; 160 | private static final int HEADER = 1; 161 | private static final int PAYLOAD = 2; 162 | 163 | private static final int HEADER_SIZE = 4; 164 | 165 | } 166 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/AttributeFrame.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | /* 17 | * To change this template, choose Tools | Templates 18 | * and open the template in the editor. 19 | */ 20 | package org.thingml.bglib.gui; 21 | 22 | import org.thingml.bglib.BGAPI; 23 | 24 | /** 25 | * 26 | * @author ffl 27 | */ 28 | public class AttributeFrame extends javax.swing.JFrame { 29 | 30 | 31 | private BGAPI bgapi; 32 | private int connection; 33 | 34 | /** 35 | * Creates new form AttributeFrame 36 | */ 37 | public AttributeFrame(BGAPI bgapi, int connection) { 38 | initComponents(); 39 | this.bgapi = bgapi; 40 | this.connection = connection; 41 | } 42 | 43 | 44 | /** 45 | * This method is called from within the constructor to initialize the form. 46 | * WARNING: Do NOT modify this code. The content of this method is always 47 | * regenerated by the Form Editor. 48 | */ 49 | @SuppressWarnings("unchecked") 50 | // //GEN-BEGIN:initComponents 51 | private void initComponents() { 52 | 53 | jTextFieldHandle = new javax.swing.JTextField(); 54 | jLabel1 = new javax.swing.JLabel(); 55 | jButtonRead = new javax.swing.JButton(); 56 | jLabel2 = new javax.swing.JLabel(); 57 | jTextFieldValue = new javax.swing.JTextField(); 58 | jButtonWrite = new javax.swing.JButton(); 59 | 60 | setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); 61 | 62 | jTextFieldHandle.setText("0x20"); 63 | 64 | jLabel1.setText("Handle : "); 65 | 66 | jButtonRead.setText("Read"); 67 | jButtonRead.addActionListener(new java.awt.event.ActionListener() { 68 | public void actionPerformed(java.awt.event.ActionEvent evt) { 69 | jButtonReadActionPerformed(evt); 70 | } 71 | }); 72 | 73 | jLabel2.setText("Value : "); 74 | 75 | jButtonWrite.setText("Write"); 76 | jButtonWrite.addActionListener(new java.awt.event.ActionListener() { 77 | public void actionPerformed(java.awt.event.ActionEvent evt) { 78 | jButtonWriteActionPerformed(evt); 79 | } 80 | }); 81 | 82 | javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); 83 | getContentPane().setLayout(layout); 84 | layout.setHorizontalGroup( 85 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 86 | .addGroup(layout.createSequentialGroup() 87 | .addContainerGap() 88 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) 89 | .addComponent(jLabel2) 90 | .addComponent(jLabel1)) 91 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 92 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 93 | .addComponent(jTextFieldHandle, javax.swing.GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE) 94 | .addComponent(jTextFieldValue)) 95 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 96 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) 97 | .addComponent(jButtonWrite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 98 | .addComponent(jButtonRead, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 99 | .addContainerGap()) 100 | ); 101 | layout.setVerticalGroup( 102 | layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) 103 | .addGroup(layout.createSequentialGroup() 104 | .addContainerGap() 105 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 106 | .addComponent(jTextFieldHandle, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 107 | .addComponent(jLabel1) 108 | .addComponent(jButtonRead)) 109 | .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 110 | .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) 111 | .addComponent(jLabel2) 112 | .addComponent(jTextFieldValue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 113 | .addComponent(jButtonWrite)) 114 | .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) 115 | ); 116 | 117 | pack(); 118 | }// //GEN-END:initComponents 119 | 120 | private void jButtonReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonReadActionPerformed 121 | bgapi.send_attclient_read_by_handle(connection, Integer.parseInt(jTextFieldHandle.getText(), 16)); 122 | }//GEN-LAST:event_jButtonReadActionPerformed 123 | 124 | private void jButtonWriteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonWriteActionPerformed 125 | bgapi.send_attclient_attribute_write(connection, Integer.parseInt(jTextFieldHandle.getText(), 16), ByteUtils.bytesFromString(jTextFieldValue.getText())); 126 | }//GEN-LAST:event_jButtonWriteActionPerformed 127 | 128 | 129 | // Variables declaration - do not modify//GEN-BEGIN:variables 130 | private javax.swing.JButton jButtonRead; 131 | private javax.swing.JButton jButtonWrite; 132 | private javax.swing.JLabel jLabel1; 133 | private javax.swing.JLabel jLabel2; 134 | private javax.swing.JTextField jTextFieldHandle; 135 | private javax.swing.JTextField jTextFieldValue; 136 | // End of variables declaration//GEN-END:variables 137 | } 138 | -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPIListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | /** 18 | * @author Franck FLEUREY (SINTEF) 19 | */ 20 | public interface BGAPIListener { 21 | 22 | 23 | // Callbacks for class system (index = 0) 24 | void receive_system_reset(); 25 | void receive_system_hello(); 26 | void receive_system_address_get(BDAddr address); 27 | void receive_system_reg_write(int result); 28 | void receive_system_reg_read(int address, int value); 29 | void receive_system_get_counters(int txok, int txretry, int rxok, int rxfail); 30 | void receive_system_get_connections(int maxconn); 31 | void receive_system_read_memory(int address, byte[] data); 32 | void receive_system_get_info(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw); 33 | void receive_system_endpoint_tx(); 34 | void receive_system_whitelist_append(int result); 35 | void receive_system_whitelist_remove(int result); 36 | void receive_system_whitelist_clear(); 37 | void receive_system_boot(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw); 38 | void receive_system_debug(byte[] data); 39 | void receive_system_endpoint_rx(int endpoint, byte[] data); 40 | 41 | // Callbacks for class flash (index = 1) 42 | void receive_flash_ps_defrag(); 43 | void receive_flash_ps_dump(); 44 | void receive_flash_ps_erase_all(); 45 | void receive_flash_ps_save(int result); 46 | void receive_flash_ps_load(int result, byte[] value); 47 | void receive_flash_ps_erase(); 48 | void receive_flash_erase_page(int result); 49 | void receive_flash_write_words(); 50 | void receive_flash_ps_key(int key, byte[] value); 51 | 52 | // Callbacks for class attributes (index = 2) 53 | void receive_attributes_write(int result); 54 | void receive_attributes_read(int handle, int offset, int result, byte[] value); 55 | void receive_attributes_read_type(int handle, int result, byte[] value); 56 | void receive_attributes_user_response(); 57 | void receive_attributes_value(int connection, int reason, int handle, int offset, byte[] value); 58 | void receive_attributes_user_request(int connection, int handle, int offset); 59 | 60 | // Callbacks for class connection (index = 3) 61 | void receive_connection_disconnect(int connection, int result); 62 | void receive_connection_get_rssi(int connection, int rssi); 63 | void receive_connection_update(int connection, int result); 64 | void receive_connection_version_update(int connection, int result); 65 | void receive_connection_channel_map_get(int connection, byte[] map); 66 | void receive_connection_channel_map_set(int connection, int result); 67 | void receive_connection_features_get(int connection, int result); 68 | void receive_connection_get_status(int connection); 69 | void receive_connection_raw_tx(int connection); 70 | void receive_connection_status(int connection, int flags, BDAddr address, int address_type, int conn_interval, int timeout, int latency, int bonding); 71 | void receive_connection_version_ind(int connection, int vers_nr, int comp_id, int sub_vers_nr); 72 | void receive_connection_feature_ind(int connection, byte[] features); 73 | void receive_connection_raw_rx(int connection, byte[] data); 74 | void receive_connection_disconnected(int connection, int reason); 75 | 76 | // Callbacks for class attclient (index = 4) 77 | void receive_attclient_find_by_type_value(int connection, int result); 78 | void receive_attclient_read_by_group_type(int connection, int result); 79 | void receive_attclient_read_by_type(int connection, int result); 80 | void receive_attclient_find_information(int connection, int result); 81 | void receive_attclient_read_by_handle(int connection, int result); 82 | void receive_attclient_attribute_write(int connection, int result); 83 | void receive_attclient_write_command(int connection, int result); 84 | void receive_attclient_reserved(); 85 | void receive_attclient_read_long(int connection, int result); 86 | void receive_attclient_prepare_write(int connection, int result); 87 | void receive_attclient_execute_write(int connection, int result); 88 | void receive_attclient_read_multiple(int connection, int result); 89 | void receive_attclient_indicated(int connection, int attrhandle); 90 | void receive_attclient_procedure_completed(int connection, int result, int chrhandle); 91 | void receive_attclient_group_found(int connection, int start, int end, byte[] uuid); 92 | void receive_attclient_attribute_found(int connection, int chrdecl, int value, int properties, byte[] uuid); 93 | void receive_attclient_find_information_found(int connection, int chrhandle, byte[] uuid); 94 | void receive_attclient_attribute_value(int connection, int atthandle, int type, byte[] value); 95 | void receive_attclient_read_multiple_response(int connection, byte[] handles); 96 | 97 | // Callbacks for class sm (index = 5) 98 | void receive_sm_encrypt_start(int handle, int result); 99 | void receive_sm_set_bondable_mode(); 100 | void receive_sm_delete_bonding(int result); 101 | void receive_sm_set_parameters(); 102 | void receive_sm_passkey_entry(int result); 103 | void receive_sm_get_bonds(int bonds); 104 | void receive_sm_set_oob_data(); 105 | void receive_sm_smp_data(int handle, int packet, byte[] data); 106 | void receive_sm_bonding_fail(int handle, int result); 107 | void receive_sm_passkey_display(int handle, int passkey); 108 | void receive_sm_passkey_request(int handle); 109 | void receive_sm_bond_status(int bond, int keysize, int mitm, int keys); 110 | 111 | // Callbacks for class gap (index = 6) 112 | void receive_gap_set_privacy_flags(); 113 | void receive_gap_set_mode(int result); 114 | void receive_gap_discover(int result); 115 | void receive_gap_connect_direct(int result, int connection_handle); 116 | void receive_gap_end_procedure(int result); 117 | void receive_gap_connect_selective(int result, int connection_handle); 118 | void receive_gap_set_filtering(int result); 119 | void receive_gap_set_scan_parameters(int result); 120 | void receive_gap_set_adv_parameters(int result); 121 | void receive_gap_set_adv_data(int result); 122 | void receive_gap_set_directed_connectable_mode(int result); 123 | void receive_gap_scan_response(int rssi, int packet_type, BDAddr sender, int address_type, int bond, byte[] data); 124 | void receive_gap_mode_changed(int discover, int connect); 125 | 126 | // Callbacks for class hardware (index = 7) 127 | void receive_hardware_io_port_config_irq(int result); 128 | void receive_hardware_set_soft_timer(int result); 129 | void receive_hardware_adc_read(int result); 130 | void receive_hardware_io_port_config_direction(int result); 131 | void receive_hardware_io_port_config_function(int result); 132 | void receive_hardware_io_port_config_pull(int result); 133 | void receive_hardware_io_port_write(int result); 134 | void receive_hardware_io_port_read(int result, int port, int data); 135 | void receive_hardware_spi_config(int result); 136 | void receive_hardware_spi_transfer(int result, int channel, byte[] data); 137 | void receive_hardware_i2c_read(int result, byte[] data); 138 | void receive_hardware_i2c_write(int written); 139 | void receive_hardware_set_txpower(); 140 | void receive_hardware_io_port_status(int timestamp, int port, int irq, int state); 141 | void receive_hardware_soft_timer(int handle); 142 | void receive_hardware_adc_result(int input, int value); 143 | 144 | // Callbacks for class test (index = 8) 145 | void receive_test_phy_tx(); 146 | void receive_test_phy_rx(); 147 | void receive_test_phy_end(int counter); 148 | void receive_test_phy_reset(); 149 | void receive_test_get_channel_map(byte[] channel_map); 150 | 151 | 152 | } -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/src/main/java/org/thingml/bglib/BGAPIListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | /** 18 | * @author Franck FLEUREY (SINTEF) 19 | */ 20 | public interface BGAPIListener { 21 | 22 | 23 | // Callbacks for class system (index = 0) 24 | void receive_system_reset(); 25 | void receive_system_hello(); 26 | void receive_system_address_get(BDAddr address); 27 | void receive_system_reg_write(int result); 28 | void receive_system_reg_read(int address, int value); 29 | void receive_system_get_counters(int txok, int txretry, int rxok, int rxfail, int mbuf); 30 | void receive_system_get_connections(int maxconn); 31 | void receive_system_read_memory(int address, byte[] data); 32 | void receive_system_get_info(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw); 33 | void receive_system_endpoint_tx(int result); 34 | void receive_system_whitelist_append(int result); 35 | void receive_system_whitelist_remove(int result); 36 | void receive_system_whitelist_clear(); 37 | void receive_system_endpoint_rx(int result, byte[] data); 38 | void receive_system_endpoint_set_watermarks(int result); 39 | void receive_system_boot(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw); 40 | void receive_system_debug(byte[] data); 41 | void receive_system_endpoint_watermark_rx(int endpoint, int data); 42 | void receive_system_endpoint_watermark_tx(int endpoint, int data); 43 | void receive_system_script_failure(int address, int reason); 44 | 45 | // Callbacks for class flash (index = 1) 46 | void receive_flash_ps_defrag(); 47 | void receive_flash_ps_dump(); 48 | void receive_flash_ps_erase_all(); 49 | void receive_flash_ps_save(int result); 50 | void receive_flash_ps_load(int result, byte[] value); 51 | void receive_flash_ps_erase(); 52 | void receive_flash_erase_page(int result); 53 | void receive_flash_write_words(); 54 | void receive_flash_ps_key(int key, byte[] value); 55 | 56 | // Callbacks for class attributes (index = 2) 57 | void receive_attributes_write(int result); 58 | void receive_attributes_read(int handle, int offset, int result, byte[] value); 59 | void receive_attributes_read_type(int handle, int result, byte[] value); 60 | void receive_attributes_user_read_response(); 61 | void receive_attributes_user_write_response(); 62 | void receive_attributes_value(int connection, int reason, int handle, int offset, byte[] value); 63 | void receive_attributes_user_read_request(int connection, int handle, int offset, int maxsize); 64 | void receive_attributes_status(int handle, int flags); 65 | 66 | // Callbacks for class connection (index = 3) 67 | void receive_connection_disconnect(int connection, int result); 68 | void receive_connection_get_rssi(int connection, int rssi); 69 | void receive_connection_update(int connection, int result); 70 | void receive_connection_version_update(int connection, int result); 71 | void receive_connection_channel_map_get(int connection, byte[] map); 72 | void receive_connection_channel_map_set(int connection, int result); 73 | void receive_connection_features_get(int connection, int result); 74 | void receive_connection_get_status(int connection); 75 | void receive_connection_raw_tx(int connection); 76 | void receive_connection_status(int connection, int flags, BDAddr address, int address_type, int conn_interval, int timeout, int latency, int bonding); 77 | void receive_connection_version_ind(int connection, int vers_nr, int comp_id, int sub_vers_nr); 78 | void receive_connection_feature_ind(int connection, byte[] features); 79 | void receive_connection_raw_rx(int connection, byte[] data); 80 | void receive_connection_disconnected(int connection, int reason); 81 | 82 | // Callbacks for class attclient (index = 4) 83 | void receive_attclient_find_by_type_value(int connection, int result); 84 | void receive_attclient_read_by_group_type(int connection, int result); 85 | void receive_attclient_read_by_type(int connection, int result); 86 | void receive_attclient_find_information(int connection, int result); 87 | void receive_attclient_read_by_handle(int connection, int result); 88 | void receive_attclient_attribute_write(int connection, int result); 89 | void receive_attclient_write_command(int connection, int result); 90 | void receive_attclient_indicate_confirm(int result); 91 | void receive_attclient_read_long(int connection, int result); 92 | void receive_attclient_prepare_write(int connection, int result); 93 | void receive_attclient_execute_write(int connection, int result); 94 | void receive_attclient_read_multiple(int connection, int result); 95 | void receive_attclient_indicated(int connection, int attrhandle); 96 | void receive_attclient_procedure_completed(int connection, int result, int chrhandle); 97 | void receive_attclient_group_found(int connection, int start, int end, byte[] uuid); 98 | void receive_attclient_attribute_found(int connection, int chrdecl, int value, int properties, byte[] uuid); 99 | void receive_attclient_find_information_found(int connection, int chrhandle, byte[] uuid); 100 | void receive_attclient_attribute_value(int connection, int atthandle, int type, byte[] value); 101 | void receive_attclient_read_multiple_response(int connection, byte[] handles); 102 | 103 | // Callbacks for class sm (index = 5) 104 | void receive_sm_encrypt_start(int handle, int result); 105 | void receive_sm_set_bondable_mode(); 106 | void receive_sm_delete_bonding(int result); 107 | void receive_sm_set_parameters(); 108 | void receive_sm_passkey_entry(int result); 109 | void receive_sm_get_bonds(int bonds); 110 | void receive_sm_set_oob_data(); 111 | void receive_sm_smp_data(int handle, int packet, byte[] data); 112 | void receive_sm_bonding_fail(int handle, int result); 113 | void receive_sm_passkey_display(int handle, int passkey); 114 | void receive_sm_passkey_request(int handle); 115 | void receive_sm_bond_status(int bond, int keysize, int mitm, int keys); 116 | 117 | // Callbacks for class gap (index = 6) 118 | void receive_gap_set_privacy_flags(); 119 | void receive_gap_set_mode(int result); 120 | void receive_gap_discover(int result); 121 | void receive_gap_connect_direct(int result, int connection_handle); 122 | void receive_gap_end_procedure(int result); 123 | void receive_gap_connect_selective(int result, int connection_handle); 124 | void receive_gap_set_filtering(int result); 125 | void receive_gap_set_scan_parameters(int result); 126 | void receive_gap_set_adv_parameters(int result); 127 | void receive_gap_set_adv_data(int result); 128 | void receive_gap_set_directed_connectable_mode(int result); 129 | void receive_gap_scan_response(int rssi, int packet_type, BDAddr sender, int address_type, int bond, byte[] data); 130 | void receive_gap_mode_changed(int discover, int connect); 131 | 132 | // Callbacks for class hardware (index = 7) 133 | void receive_hardware_io_port_config_irq(int result); 134 | void receive_hardware_set_soft_timer(int result); 135 | void receive_hardware_adc_read(int result); 136 | void receive_hardware_io_port_config_direction(int result); 137 | void receive_hardware_io_port_config_function(int result); 138 | void receive_hardware_io_port_config_pull(int result); 139 | void receive_hardware_io_port_write(int result); 140 | void receive_hardware_io_port_read(int result, int port, int data); 141 | void receive_hardware_spi_config(int result); 142 | void receive_hardware_spi_transfer(int result, int channel, byte[] data); 143 | void receive_hardware_i2c_read(int result, byte[] data); 144 | void receive_hardware_i2c_write(int written); 145 | void receive_hardware_set_txpower(); 146 | void receive_hardware_timer_comparator(int result); 147 | void receive_hardware_io_port_status(int timestamp, int port, int irq, int state); 148 | void receive_hardware_soft_timer(int handle); 149 | void receive_hardware_adc_result(int input, int value); 150 | 151 | // Callbacks for class test (index = 8) 152 | void receive_test_phy_tx(); 153 | void receive_test_phy_rx(); 154 | void receive_test_phy_end(int counter); 155 | void receive_test_phy_reset(); 156 | void receive_test_get_channel_map(byte[] channel_map); 157 | void receive_test_debug(byte[] output); 158 | 159 | 160 | } -------------------------------------------------------------------------------- /bglib-protocol-1.0.3-43/src/main/java/org/thingml/bglib/BGAPIDefaultListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | /** 18 | * @author Franck FLEUREY (SINTEF) 19 | */ 20 | public class BGAPIDefaultListener implements BGAPIListener { 21 | 22 | 23 | // Callbacks for class system (index = 0) 24 | public void receive_system_reset() {} 25 | public void receive_system_hello() {} 26 | public void receive_system_address_get(BDAddr address) {} 27 | public void receive_system_reg_write(int result) {} 28 | public void receive_system_reg_read(int address, int value) {} 29 | public void receive_system_get_counters(int txok, int txretry, int rxok, int rxfail) {} 30 | public void receive_system_get_connections(int maxconn) {} 31 | public void receive_system_read_memory(int address, byte[] data) {} 32 | public void receive_system_get_info(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw) {} 33 | public void receive_system_endpoint_tx() {} 34 | public void receive_system_whitelist_append(int result) {} 35 | public void receive_system_whitelist_remove(int result) {} 36 | public void receive_system_whitelist_clear() {} 37 | public void receive_system_boot(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw) {} 38 | public void receive_system_debug(byte[] data) {} 39 | public void receive_system_endpoint_rx(int endpoint, byte[] data) {} 40 | 41 | // Callbacks for class flash (index = 1) 42 | public void receive_flash_ps_defrag() {} 43 | public void receive_flash_ps_dump() {} 44 | public void receive_flash_ps_erase_all() {} 45 | public void receive_flash_ps_save(int result) {} 46 | public void receive_flash_ps_load(int result, byte[] value) {} 47 | public void receive_flash_ps_erase() {} 48 | public void receive_flash_erase_page(int result) {} 49 | public void receive_flash_write_words() {} 50 | public void receive_flash_ps_key(int key, byte[] value) {} 51 | 52 | // Callbacks for class attributes (index = 2) 53 | public void receive_attributes_write(int result) {} 54 | public void receive_attributes_read(int handle, int offset, int result, byte[] value) {} 55 | public void receive_attributes_read_type(int handle, int result, byte[] value) {} 56 | public void receive_attributes_user_response() {} 57 | public void receive_attributes_value(int connection, int reason, int handle, int offset, byte[] value) {} 58 | public void receive_attributes_user_request(int connection, int handle, int offset) {} 59 | 60 | // Callbacks for class connection (index = 3) 61 | public void receive_connection_disconnect(int connection, int result) {} 62 | public void receive_connection_get_rssi(int connection, int rssi) {} 63 | public void receive_connection_update(int connection, int result) {} 64 | public void receive_connection_version_update(int connection, int result) {} 65 | public void receive_connection_channel_map_get(int connection, byte[] map) {} 66 | public void receive_connection_channel_map_set(int connection, int result) {} 67 | public void receive_connection_features_get(int connection, int result) {} 68 | public void receive_connection_get_status(int connection) {} 69 | public void receive_connection_raw_tx(int connection) {} 70 | public void receive_connection_status(int connection, int flags, BDAddr address, int address_type, int conn_interval, int timeout, int latency, int bonding) {} 71 | public void receive_connection_version_ind(int connection, int vers_nr, int comp_id, int sub_vers_nr) {} 72 | public void receive_connection_feature_ind(int connection, byte[] features) {} 73 | public void receive_connection_raw_rx(int connection, byte[] data) {} 74 | public void receive_connection_disconnected(int connection, int reason) {} 75 | 76 | // Callbacks for class attclient (index = 4) 77 | public void receive_attclient_find_by_type_value(int connection, int result) {} 78 | public void receive_attclient_read_by_group_type(int connection, int result) {} 79 | public void receive_attclient_read_by_type(int connection, int result) {} 80 | public void receive_attclient_find_information(int connection, int result) {} 81 | public void receive_attclient_read_by_handle(int connection, int result) {} 82 | public void receive_attclient_attribute_write(int connection, int result) {} 83 | public void receive_attclient_write_command(int connection, int result) {} 84 | public void receive_attclient_reserved() {} 85 | public void receive_attclient_read_long(int connection, int result) {} 86 | public void receive_attclient_prepare_write(int connection, int result) {} 87 | public void receive_attclient_execute_write(int connection, int result) {} 88 | public void receive_attclient_read_multiple(int connection, int result) {} 89 | public void receive_attclient_indicated(int connection, int attrhandle) {} 90 | public void receive_attclient_procedure_completed(int connection, int result, int chrhandle) {} 91 | public void receive_attclient_group_found(int connection, int start, int end, byte[] uuid) {} 92 | public void receive_attclient_attribute_found(int connection, int chrdecl, int value, int properties, byte[] uuid) {} 93 | public void receive_attclient_find_information_found(int connection, int chrhandle, byte[] uuid) {} 94 | public void receive_attclient_attribute_value(int connection, int atthandle, int type, byte[] value) { 95 | 96 | 97 | } 98 | public void receive_attclient_read_multiple_response(int connection, byte[] handles) {} 99 | 100 | // Callbacks for class sm (index = 5) 101 | public void receive_sm_encrypt_start(int handle, int result) {} 102 | public void receive_sm_set_bondable_mode() {} 103 | public void receive_sm_delete_bonding(int result) {} 104 | public void receive_sm_set_parameters() {} 105 | public void receive_sm_passkey_entry(int result) {} 106 | public void receive_sm_get_bonds(int bonds) {} 107 | public void receive_sm_set_oob_data() {} 108 | public void receive_sm_smp_data(int handle, int packet, byte[] data) {} 109 | public void receive_sm_bonding_fail(int handle, int result) {} 110 | public void receive_sm_passkey_display(int handle, int passkey) {} 111 | public void receive_sm_passkey_request(int handle) {} 112 | public void receive_sm_bond_status(int bond, int keysize, int mitm, int keys) {} 113 | 114 | // Callbacks for class gap (index = 6) 115 | public void receive_gap_set_privacy_flags() {} 116 | public void receive_gap_set_mode(int result) {} 117 | public void receive_gap_discover(int result) {} 118 | public void receive_gap_connect_direct(int result, int connection_handle) {} 119 | public void receive_gap_end_procedure(int result) {} 120 | public void receive_gap_connect_selective(int result, int connection_handle) {} 121 | public void receive_gap_set_filtering(int result) {} 122 | public void receive_gap_set_scan_parameters(int result) {} 123 | public void receive_gap_set_adv_parameters(int result) {} 124 | public void receive_gap_set_adv_data(int result) {} 125 | public void receive_gap_set_directed_connectable_mode(int result) {} 126 | public void receive_gap_scan_response(int rssi, int packet_type, BDAddr sender, int address_type, int bond, byte[] data) {} 127 | public void receive_gap_mode_changed(int discover, int connect) {} 128 | 129 | // Callbacks for class hardware (index = 7) 130 | public void receive_hardware_io_port_config_irq(int result) {} 131 | public void receive_hardware_set_soft_timer(int result) {} 132 | public void receive_hardware_adc_read(int result) {} 133 | public void receive_hardware_io_port_config_direction(int result) {} 134 | public void receive_hardware_io_port_config_function(int result) {} 135 | public void receive_hardware_io_port_config_pull(int result) {} 136 | public void receive_hardware_io_port_write(int result) {} 137 | public void receive_hardware_io_port_read(int result, int port, int data) {} 138 | public void receive_hardware_spi_config(int result) {} 139 | public void receive_hardware_spi_transfer(int result, int channel, byte[] data) {} 140 | public void receive_hardware_i2c_read(int result, byte[] data) {} 141 | public void receive_hardware_i2c_write(int written) {} 142 | public void receive_hardware_set_txpower() {} 143 | public void receive_hardware_io_port_status(int timestamp, int port, int irq, int state) {} 144 | public void receive_hardware_soft_timer(int handle) {} 145 | public void receive_hardware_adc_result(int input, int value) {} 146 | 147 | // Callbacks for class test (index = 8) 148 | public void receive_test_phy_tx() {} 149 | public void receive_test_phy_rx() {} 150 | public void receive_test_phy_end(int counter) {} 151 | public void receive_test_phy_reset() {} 152 | public void receive_test_get_channel_map(byte[] channel_map) {} 153 | 154 | 155 | } -------------------------------------------------------------------------------- /bglib-protocol-1.1.0-55Beta/src/main/java/org/thingml/bglib/BGAPIDefaultListener.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib; 17 | /** 18 | * @author Franck FLEUREY (SINTEF) 19 | */ 20 | public class BGAPIDefaultListener implements BGAPIListener { 21 | 22 | 23 | // Callbacks for class system (index = 0) 24 | public void receive_system_reset() {} 25 | public void receive_system_hello() {} 26 | public void receive_system_address_get(BDAddr address) {} 27 | public void receive_system_reg_write(int result) {} 28 | public void receive_system_reg_read(int address, int value) {} 29 | public void receive_system_get_counters(int txok, int txretry, int rxok, int rxfail, int mbuf) {} 30 | public void receive_system_get_connections(int maxconn) {} 31 | public void receive_system_read_memory(int address, byte[] data) {} 32 | public void receive_system_get_info(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw) {} 33 | public void receive_system_endpoint_tx(int result) {} 34 | public void receive_system_whitelist_append(int result) {} 35 | public void receive_system_whitelist_remove(int result) {} 36 | public void receive_system_whitelist_clear() {} 37 | public void receive_system_endpoint_rx(int result, byte[] data) {} 38 | public void receive_system_endpoint_set_watermarks(int result) {} 39 | public void receive_system_boot(int major, int minor, int patch, int build, int ll_version, int protocol_version, int hw) {} 40 | public void receive_system_debug(byte[] data) {} 41 | public void receive_system_endpoint_watermark_rx(int endpoint, int data) {} 42 | public void receive_system_endpoint_watermark_tx(int endpoint, int data) {} 43 | public void receive_system_script_failure(int address, int reason) {} 44 | 45 | // Callbacks for class flash (index = 1) 46 | public void receive_flash_ps_defrag() {} 47 | public void receive_flash_ps_dump() {} 48 | public void receive_flash_ps_erase_all() {} 49 | public void receive_flash_ps_save(int result) {} 50 | public void receive_flash_ps_load(int result, byte[] value) {} 51 | public void receive_flash_ps_erase() {} 52 | public void receive_flash_erase_page(int result) {} 53 | public void receive_flash_write_words() {} 54 | public void receive_flash_ps_key(int key, byte[] value) {} 55 | 56 | // Callbacks for class attributes (index = 2) 57 | public void receive_attributes_write(int result) {} 58 | public void receive_attributes_read(int handle, int offset, int result, byte[] value) {} 59 | public void receive_attributes_read_type(int handle, int result, byte[] value) {} 60 | public void receive_attributes_user_read_response() {} 61 | public void receive_attributes_user_write_response() {} 62 | public void receive_attributes_value(int connection, int reason, int handle, int offset, byte[] value) {} 63 | public void receive_attributes_user_read_request(int connection, int handle, int offset, int maxsize) {} 64 | public void receive_attributes_status(int handle, int flags) {} 65 | 66 | // Callbacks for class connection (index = 3) 67 | public void receive_connection_disconnect(int connection, int result) {} 68 | public void receive_connection_get_rssi(int connection, int rssi) {} 69 | public void receive_connection_update(int connection, int result) {} 70 | public void receive_connection_version_update(int connection, int result) {} 71 | public void receive_connection_channel_map_get(int connection, byte[] map) {} 72 | public void receive_connection_channel_map_set(int connection, int result) {} 73 | public void receive_connection_features_get(int connection, int result) {} 74 | public void receive_connection_get_status(int connection) {} 75 | public void receive_connection_raw_tx(int connection) {} 76 | public void receive_connection_status(int connection, int flags, BDAddr address, int address_type, int conn_interval, int timeout, int latency, int bonding) {} 77 | public void receive_connection_version_ind(int connection, int vers_nr, int comp_id, int sub_vers_nr) {} 78 | public void receive_connection_feature_ind(int connection, byte[] features) {} 79 | public void receive_connection_raw_rx(int connection, byte[] data) {} 80 | public void receive_connection_disconnected(int connection, int reason) {} 81 | 82 | // Callbacks for class attclient (index = 4) 83 | public void receive_attclient_find_by_type_value(int connection, int result) {} 84 | public void receive_attclient_read_by_group_type(int connection, int result) {} 85 | public void receive_attclient_read_by_type(int connection, int result) {} 86 | public void receive_attclient_find_information(int connection, int result) {} 87 | public void receive_attclient_read_by_handle(int connection, int result) {} 88 | public void receive_attclient_attribute_write(int connection, int result) {} 89 | public void receive_attclient_write_command(int connection, int result) {} 90 | public void receive_attclient_indicate_confirm(int result) {} 91 | public void receive_attclient_read_long(int connection, int result) {} 92 | public void receive_attclient_prepare_write(int connection, int result) {} 93 | public void receive_attclient_execute_write(int connection, int result) {} 94 | public void receive_attclient_read_multiple(int connection, int result) {} 95 | public void receive_attclient_indicated(int connection, int attrhandle) {} 96 | public void receive_attclient_procedure_completed(int connection, int result, int chrhandle) {} 97 | public void receive_attclient_group_found(int connection, int start, int end, byte[] uuid) {} 98 | public void receive_attclient_attribute_found(int connection, int chrdecl, int value, int properties, byte[] uuid) {} 99 | public void receive_attclient_find_information_found(int connection, int chrhandle, byte[] uuid) {} 100 | public void receive_attclient_attribute_value(int connection, int atthandle, int type, byte[] value) {} 101 | public void receive_attclient_read_multiple_response(int connection, byte[] handles) {} 102 | 103 | // Callbacks for class sm (index = 5) 104 | public void receive_sm_encrypt_start(int handle, int result) {} 105 | public void receive_sm_set_bondable_mode() {} 106 | public void receive_sm_delete_bonding(int result) {} 107 | public void receive_sm_set_parameters() {} 108 | public void receive_sm_passkey_entry(int result) {} 109 | public void receive_sm_get_bonds(int bonds) {} 110 | public void receive_sm_set_oob_data() {} 111 | public void receive_sm_smp_data(int handle, int packet, byte[] data) {} 112 | public void receive_sm_bonding_fail(int handle, int result) {} 113 | public void receive_sm_passkey_display(int handle, int passkey) {} 114 | public void receive_sm_passkey_request(int handle) {} 115 | public void receive_sm_bond_status(int bond, int keysize, int mitm, int keys) {} 116 | 117 | // Callbacks for class gap (index = 6) 118 | public void receive_gap_set_privacy_flags() {} 119 | public void receive_gap_set_mode(int result) {} 120 | public void receive_gap_discover(int result) {} 121 | public void receive_gap_connect_direct(int result, int connection_handle) {} 122 | public void receive_gap_end_procedure(int result) {} 123 | public void receive_gap_connect_selective(int result, int connection_handle) {} 124 | public void receive_gap_set_filtering(int result) {} 125 | public void receive_gap_set_scan_parameters(int result) {} 126 | public void receive_gap_set_adv_parameters(int result) {} 127 | public void receive_gap_set_adv_data(int result) {} 128 | public void receive_gap_set_directed_connectable_mode(int result) {} 129 | public void receive_gap_scan_response(int rssi, int packet_type, BDAddr sender, int address_type, int bond, byte[] data) {} 130 | public void receive_gap_mode_changed(int discover, int connect) {} 131 | 132 | // Callbacks for class hardware (index = 7) 133 | public void receive_hardware_io_port_config_irq(int result) {} 134 | public void receive_hardware_set_soft_timer(int result) {} 135 | public void receive_hardware_adc_read(int result) {} 136 | public void receive_hardware_io_port_config_direction(int result) {} 137 | public void receive_hardware_io_port_config_function(int result) {} 138 | public void receive_hardware_io_port_config_pull(int result) {} 139 | public void receive_hardware_io_port_write(int result) {} 140 | public void receive_hardware_io_port_read(int result, int port, int data) {} 141 | public void receive_hardware_spi_config(int result) {} 142 | public void receive_hardware_spi_transfer(int result, int channel, byte[] data) {} 143 | public void receive_hardware_i2c_read(int result, byte[] data) {} 144 | public void receive_hardware_i2c_write(int written) {} 145 | public void receive_hardware_set_txpower() {} 146 | public void receive_hardware_timer_comparator(int result) {} 147 | public void receive_hardware_io_port_status(int timestamp, int port, int irq, int state) {} 148 | public void receive_hardware_soft_timer(int handle) {} 149 | public void receive_hardware_adc_result(int input, int value) {} 150 | 151 | // Callbacks for class test (index = 8) 152 | public void receive_test_phy_tx() {} 153 | public void receive_test_phy_rx() {} 154 | public void receive_test_phy_end(int counter) {} 155 | public void receive_test_phy_reset() {} 156 | public void receive_test_get_channel_map(byte[] channel_map) {} 157 | public void receive_test_debug(byte[] output) {} 158 | 159 | 160 | } -------------------------------------------------------------------------------- /bglib-samples/src/main/java/org/thingml/bglib/samples/BLED112.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.samples; 17 | 18 | import gnu.io.*; 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.lang.reflect.Field; 22 | import java.util.ArrayList; 23 | import java.util.Enumeration; 24 | import java.util.HashSet; 25 | import java.util.logging.Level; 26 | import java.util.logging.Logger; 27 | import javax.swing.JOptionPane; 28 | import org.thingml.bglib.BGAPITransport; 29 | 30 | /** 31 | * 32 | * @author ffl 33 | */ 34 | public class BLED112 { 35 | /* *********************************************************************** 36 | * Serial port utilities: listing 37 | *************************************************************************/ 38 | /** 39 | * @return A HashSet containing the CommPortIdentifier for all serial ports that are not currently being used. 40 | */ 41 | public static HashSet getAvailableSerialPorts() { 42 | HashSet h = new HashSet(); 43 | Enumeration thePorts = CommPortIdentifier.getPortIdentifiers(); 44 | while (thePorts.hasMoreElements()) { 45 | CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement(); 46 | switch (com.getPortType()) { 47 | case CommPortIdentifier.PORT_SERIAL: 48 | try { 49 | CommPort thePort = com.open("CommUtil", 50); 50 | thePort.close(); 51 | h.add(com); 52 | } catch (PortInUseException e) { 53 | System.out.println("Port, " + com.getName() + ", is in use."); 54 | } catch (Exception e) { 55 | System.err.println("Failed to open port " + com.getName()); 56 | e.printStackTrace(); 57 | } 58 | } 59 | } 60 | return h; 61 | } 62 | 63 | public static void registerPort(String port) { 64 | 65 | String prop = System.getProperty("gnu.io.rxtx.SerialPorts"); 66 | if (prop == null) { 67 | prop = ""; 68 | } 69 | if (!prop.contains(port)) { 70 | prop += port + File.pathSeparator; 71 | System.setProperty("gnu.io.rxtx.SerialPorts", prop); 72 | } 73 | System.out.println("gnu.io.rxtx.SerialPorts = " + prop); 74 | 75 | prop = System.getProperty("javax.comm.rxtx.SerialPorts"); 76 | if (prop == null) { 77 | prop = ""; 78 | } 79 | if (!prop.contains(port)) { 80 | prop += port + File.pathSeparator; 81 | System.setProperty("javax.comm.rxtx.SerialPorts", prop); 82 | } 83 | System.out.println("javax.comm.rxtx.SerialPorts = " + prop); 84 | } 85 | 86 | public static String selectSerialPort() { 87 | 88 | ArrayList possibilities = new ArrayList(); 89 | //possibilities.add("Emulator"); 90 | for (CommPortIdentifier commportidentifier : getAvailableSerialPorts()) { 91 | possibilities.add(commportidentifier.getName()); 92 | } 93 | 94 | int startPosition = 0; 95 | if (possibilities.size() > 1) { 96 | startPosition = 1; 97 | } 98 | 99 | return (String) JOptionPane.showInputDialog( 100 | null, 101 | "BLED112", 102 | "Select serial port", 103 | JOptionPane.PLAIN_MESSAGE, 104 | null, 105 | possibilities.toArray(), 106 | possibilities.toArray()[startPosition]); 107 | 108 | } 109 | 110 | public static BGAPITransport connectBLED112() { 111 | SerialPort port = connectSerial(); 112 | try { 113 | return new BGAPITransport(port.getInputStream(), port.getOutputStream()); 114 | } catch (IOException ex) { 115 | Logger.getLogger(BLED112.class.getName()).log(Level.SEVERE, null, ex); 116 | } 117 | return null; 118 | } 119 | 120 | public static SerialPort connectSerial() { 121 | try { 122 | 123 | String portName = selectSerialPort(); 124 | 125 | CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); 126 | 127 | if (portIdentifier.isCurrentlyOwned()) { 128 | System.err.println("Error: Port " + portName + " is currently in use"); 129 | } 130 | else { 131 | CommPort commPort = portIdentifier.open("BLED112", 2000); 132 | 133 | System.out.println("port = " + commPort); 134 | 135 | if (commPort instanceof SerialPort) { 136 | SerialPort serialPort = (SerialPort) commPort; 137 | serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); 138 | 139 | serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT); 140 | serialPort.setRTS(true); 141 | 142 | 143 | System.out.println("serial port = " + serialPort); 144 | 145 | return serialPort; 146 | 147 | } else { 148 | System.err.println("Error: Port " + portName + " is not a valid serial port."); 149 | } 150 | } 151 | } catch (Exception e) { 152 | e.printStackTrace(); 153 | } 154 | return null; 155 | } 156 | 157 | public static void initRXTX() { 158 | System.out.println("Init RXTX."); 159 | } 160 | 161 | static { 162 | 163 | try { 164 | // This is a very dirty hack to try and set the java.library.path dynamically. 165 | System.setProperty("java.library.path", "."); 166 | Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); 167 | fieldSysPath.setAccessible(true); 168 | fieldSysPath.set(null, null); 169 | } catch (Exception e) { 170 | e.printStackTrace(); 171 | } 172 | 173 | try { 174 | String osName = System.getProperty("os.name"); 175 | String osProc = System.getProperty("os.arch"); 176 | 177 | //System.out.println(System.properties['java.library.path']); 178 | 179 | System.out.println("Load RxTx for os.name=" + osName + " os.arch=" + osProc + " sun.arch.data.model=" + System.getProperty("sun.arch.data.model")); 180 | System.out.println("Current path = " + new File(".").getAbsolutePath()); 181 | 182 | if (osName.equals("Mac OS X")) { 183 | System.out.println("Copiying " + "nativelib/Mac_OS_X/librxtxSerial.jnilib"); 184 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Mac_OS_X/librxtxSerial.jnilib"), "librxtxSerial.jnilib"); 185 | } 186 | if (osName.contains("Win") && System.getProperty("sun.arch.data.model").contains("32")) { 187 | System.out.println("Copiying " + "nativelib/Windows/win32/rxtxSerial.dll"); 188 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Windows/win32/rxtxSerial.dll"), "rxtxSerial.dll"); 189 | } 190 | if (osName.contains("Win") && System.getProperty("sun.arch.data.model").contains("64")) { 191 | System.out.println("Copiying " + "nativelib/Windows/win64/rxtxSerial.dll"); 192 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Windows/win64/rxtxSerial.dll"), "rxtxSerial.dll"); 193 | } 194 | if (osName.equals("Linux") && osProc.equals("ia64")) { 195 | System.out.println("Copiying " + "nativelib/Linux/ia64-unknown-linux-gnu/librxtxSerial.so"); 196 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/ia64-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 197 | } 198 | else if (osName.equals("Linux") && System.getProperty("sun.arch.data.model").contains("64")) { 199 | System.out.println("Copiying " + "nativelib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so"); 200 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 201 | } 202 | if (osName.equals("Linux") && System.getProperty("sun.arch.data.model").contains("32")) { 203 | System.out.println("Copiying " + "nativelib/Linux/i686-unknown-linux-gnu/librxtxSerial.so"); 204 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/i686-unknown-linux-gnu/librxtxParallel.so"), "librxtxParallel.so"); 205 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/i686-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 206 | } 207 | } catch (Exception e) { 208 | e.printStackTrace(); 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLED112.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package org.thingml.bglib.gui; 17 | 18 | import gnu.io.*; 19 | import java.io.File; 20 | import java.io.IOException; 21 | import java.lang.reflect.Field; 22 | import java.util.ArrayList; 23 | import java.util.Enumeration; 24 | import java.util.HashSet; 25 | import java.util.logging.Level; 26 | import java.util.logging.Logger; 27 | import javax.swing.JOptionPane; 28 | import org.thingml.bglib.BGAPITransport; 29 | 30 | /** 31 | * 32 | * @author ffl 33 | */ 34 | public class BLED112 { 35 | /* *********************************************************************** 36 | * Serial port utilities: listing 37 | *************************************************************************/ 38 | /** 39 | * @return A HashSet containing the CommPortIdentifier for all serial ports that are not currently being used. 40 | */ 41 | public static HashSet getAvailableSerialPorts() { 42 | HashSet h = new HashSet(); 43 | Enumeration thePorts = CommPortIdentifier.getPortIdentifiers(); 44 | while (thePorts.hasMoreElements()) { 45 | CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement(); 46 | switch (com.getPortType()) { 47 | case CommPortIdentifier.PORT_SERIAL: 48 | try { 49 | CommPort thePort = com.open("CommUtil", 50); 50 | thePort.close(); 51 | h.add(com); 52 | } catch (PortInUseException e) { 53 | System.out.println("Port, " + com.getName() + ", is in use."); 54 | } catch (Exception e) { 55 | System.err.println("Failed to open port " + com.getName()); 56 | e.printStackTrace(); 57 | } 58 | } 59 | } 60 | return h; 61 | } 62 | 63 | public static void registerPort(String port) { 64 | 65 | String prop = System.getProperty("gnu.io.rxtx.SerialPorts"); 66 | if (prop == null) { 67 | prop = ""; 68 | } 69 | if (!prop.contains(port)) { 70 | prop += port + File.pathSeparator; 71 | System.setProperty("gnu.io.rxtx.SerialPorts", prop); 72 | } 73 | System.out.println("gnu.io.rxtx.SerialPorts = " + prop); 74 | 75 | prop = System.getProperty("javax.comm.rxtx.SerialPorts"); 76 | if (prop == null) { 77 | prop = ""; 78 | } 79 | if (!prop.contains(port)) { 80 | prop += port + File.pathSeparator; 81 | System.setProperty("javax.comm.rxtx.SerialPorts", prop); 82 | } 83 | System.out.println("javax.comm.rxtx.SerialPorts = " + prop); 84 | } 85 | 86 | public static String selectSerialPort() { 87 | 88 | ArrayList possibilities = new ArrayList(); 89 | //possibilities.add("Emulator"); 90 | for (CommPortIdentifier commportidentifier : getAvailableSerialPorts()) { 91 | possibilities.add(commportidentifier.getName()); 92 | } 93 | 94 | int startPosition = 0; 95 | if (possibilities.size() > 1) { 96 | startPosition = 1; 97 | } 98 | 99 | return (String) JOptionPane.showInputDialog( 100 | null, 101 | "BLED112", 102 | "Select serial port", 103 | JOptionPane.PLAIN_MESSAGE, 104 | null, 105 | possibilities.toArray(), 106 | possibilities.toArray()[startPosition]); 107 | 108 | } 109 | 110 | public static BGAPITransport connectBLED112(String portName) { 111 | SerialPort port = connectSerial(portName); 112 | try { 113 | return new BGAPITransport(port.getInputStream(), port.getOutputStream()); 114 | } catch (IOException ex) { 115 | Logger.getLogger(BLED112.class.getName()).log(Level.SEVERE, null, ex); 116 | } 117 | return null; 118 | } 119 | 120 | public static SerialPort connectSerial(String portName) { 121 | try { 122 | 123 | //String portName = selectSerialPort(); 124 | 125 | CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); 126 | 127 | if (portIdentifier.isCurrentlyOwned()) { 128 | System.err.println("Error: Port " + portName + " is currently in use"); 129 | } 130 | else { 131 | CommPort commPort = portIdentifier.open("BLED112", 2000); 132 | 133 | System.out.println("port = " + commPort); 134 | 135 | if (commPort instanceof SerialPort) { 136 | SerialPort serialPort = (SerialPort) commPort; 137 | serialPort.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); 138 | 139 | serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN | SerialPort.FLOWCONTROL_RTSCTS_OUT); 140 | serialPort.setRTS(true); 141 | 142 | 143 | System.out.println("serial port = " + serialPort); 144 | 145 | return serialPort; 146 | 147 | } else { 148 | System.err.println("Error: Port " + portName + " is not a valid serial port."); 149 | } 150 | } 151 | } catch (Exception e) { 152 | e.printStackTrace(); 153 | } 154 | return null; 155 | } 156 | 157 | public static void initRXTX() { 158 | System.out.println("Init RXTX."); 159 | } 160 | 161 | static { 162 | 163 | try { 164 | // This is a very dirty hack to try and set the java.library.path dynamically. 165 | System.setProperty("java.library.path", "."); 166 | Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths"); 167 | fieldSysPath.setAccessible(true); 168 | fieldSysPath.set(null, null); 169 | } catch (Exception e) { 170 | e.printStackTrace(); 171 | } 172 | 173 | try { 174 | String osName = System.getProperty("os.name"); 175 | String osProc = System.getProperty("os.arch"); 176 | 177 | //System.out.println(System.properties['java.library.path']); 178 | 179 | System.out.println("Load RxTx for os.name=" + osName + " os.arch=" + osProc + " sun.arch.data.model=" + System.getProperty("sun.arch.data.model")); 180 | System.out.println("Current path = " + new File(".").getAbsolutePath()); 181 | 182 | if (osName.equals("Mac OS X")) { 183 | System.out.println("Copiying " + "nativelib/Mac_OS_X/librxtxSerial.jnilib"); 184 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Mac_OS_X/librxtxSerial.jnilib"), "librxtxSerial.jnilib"); 185 | } 186 | if (osName.contains("Win") && System.getProperty("sun.arch.data.model").contains("32")) { 187 | System.out.println("Copiying " + "nativelib/Windows/win32/rxtxSerial.dll"); 188 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Windows/win32/rxtxSerial.dll"), "rxtxSerial.dll"); 189 | } 190 | if (osName.contains("Win") && System.getProperty("sun.arch.data.model").contains("64")) { 191 | System.out.println("Copiying " + "nativelib/Windows/win64/rxtxSerial.dll"); 192 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Windows/win64/rxtxSerial.dll"), "rxtxSerial.dll"); 193 | } 194 | if (osName.equals("Linux") && osProc.equals("ia64")) { 195 | System.out.println("Copiying " + "nativelib/Linux/ia64-unknown-linux-gnu/librxtxSerial.so"); 196 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/ia64-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 197 | } 198 | else if (osName.equals("Linux") && System.getProperty("sun.arch.data.model").contains("64")) { 199 | System.out.println("Copiying " + "nativelib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so"); 200 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/x86_64-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 201 | } 202 | if (osName.equals("Linux") && System.getProperty("sun.arch.data.model").contains("32")) { 203 | System.out.println("Copiying " + "nativelib/Linux/i686-unknown-linux-gnu/librxtxSerial.so"); 204 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/i686-unknown-linux-gnu/librxtxParallel.so"), "librxtxParallel.so"); 205 | NativeLibUtil.copyFile(NativeLibUtil.class.getClassLoader().getResourceAsStream("nativelib/Linux/i686-unknown-linux-gnu/librxtxSerial.so"), "librxtxSerial.so"); 206 | } 207 | } catch (Exception e) { 208 | e.printStackTrace(); 209 | } 210 | } 211 | } 212 | -------------------------------------------------------------------------------- /bglib-generator/src/main/scala/BGLibGen/BluegigaJavaGenerator.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package BGLibGen 17 | 18 | import xml.XML 19 | import java.util.Hashtable 20 | object BluegigaJavaGenerator { 21 | 22 | val java_types : Hashtable[String, String] = { 23 | val result = new Hashtable[String, String]() 24 | result.put("uint8", "int") 25 | result.put("uint16", "int") 26 | result.put("int16", "int") 27 | result.put("uint32", "int") 28 | result.put("int8", "int") 29 | result.put("bd_addr", "BDAddr") 30 | result.put("uint8array", "byte[]") 31 | result 32 | } 33 | 34 | def getJavaType(t : String) = { 35 | var result = java_types.get(t) 36 | if (result == null) result = "[" + t + "]" 37 | result 38 | } 39 | 40 | def generateReceiveOperations (out : StringBuilder, root: scala.xml.Elem, before : String, after : String) = { 41 | 42 | root \ "class" foreach { p => 43 | val p_index = (p \ "@index").text 44 | var p_name = (p \ "@name").text 45 | out append "\n\t// Callbacks for class " + p_name + " (index = " + p_index + ")\n" 46 | 47 | p \ "command" foreach { c => 48 | val c_index = (c \ "@index").text 49 | val c_name = (c \ "@name").text 50 | val c_script = (c \ "@script").text 51 | 52 | out append "\t" + before + "void receive_" + p_name + "_" + c_name + "(" 53 | 54 | var params = List[String]() 55 | c \ "returns" \ "param" foreach { a => 56 | val a_datatype = (a \ "@datatype").text 57 | var a_name = (a \ "@name").text 58 | val a_type = (a \ "@type").text 59 | params ::= getJavaType(a_type) + " " + a_name 60 | } 61 | 62 | out append params.reverse.mkString(", ") 63 | out append ")" 64 | out append after 65 | out append "\n" 66 | 67 | } 68 | p \ "event" foreach { e => 69 | val e_index = (e \ "@index").text 70 | val e_name = (e \ "@name").text 71 | val e_script = (e \ "@script").text 72 | 73 | out append "\t" + before + "void receive_" + p_name + "_" + e_name + "(" 74 | 75 | var params = List[String]() 76 | e \ "params" \ "param" foreach { a => 77 | val a_datatype = (a \ "@datatype").text 78 | var a_name = (a \ "@name").text 79 | val a_type = (a \ "@type").text 80 | params ::= getJavaType(a_type) + " " + a_name 81 | } 82 | 83 | out append params.reverse.mkString(", ") 84 | out append ")" 85 | out append after 86 | out append "\n" 87 | 88 | } 89 | } 90 | } 91 | 92 | 93 | def generateReceiveHandlers (out : StringBuilder, root: scala.xml.Elem) = { 94 | 95 | root \ "class" foreach { p => 96 | val p_index = (p \ "@index").text 97 | var p_name = (p \ "@name").text 98 | out append "\n\t// Callbacks for class " + p_name + " (index = " + p_index + ")\n" 99 | 100 | p \ "command" foreach { c => 101 | val c_index = (c \ "@index").text 102 | val c_name = (c \ "@name").text 103 | val c_script = (c \ "@script").text 104 | 105 | out append "\tprivate void receive_" + p_name + "_" + c_name + "(BGAPIPacket packet) {\n" 106 | out append "\t\tBGAPIPacketReader r = packet.getPayloadReader();\n" 107 | 108 | var params = List[String]() 109 | c \ "returns" \ "param" foreach { a => 110 | val a_datatype = (a \ "@datatype").text 111 | var a_name = (a \ "@name").text 112 | val a_type = (a \ "@type").text 113 | params ::= "\t\t" + getJavaType(a_type) + " " + a_name + " = r.r_" + a_type + "();\n" 114 | } 115 | out append params.reverse.mkString("") 116 | 117 | out append "\t\tfor(BGAPIListener l : listeners) l.receive_" + p_name + "_" + c_name + "(" 118 | params = List[String]() 119 | c \ "returns" \ "param" foreach { a => 120 | val a_datatype = (a \ "@datatype").text 121 | var a_name = (a \ "@name").text 122 | val a_type = (a \ "@type").text 123 | params ::= a_name 124 | } 125 | out append params.reverse.mkString(", ") 126 | out append ");\n" 127 | out append "\t}\n" 128 | 129 | } 130 | p \ "event" foreach { e => 131 | val e_index = (e \ "@index").text 132 | val e_name = (e \ "@name").text 133 | val e_script = (e \ "@script").text 134 | 135 | 136 | out append "\tprivate void receive_" + p_name + "_" + e_name + "(BGAPIPacket __packet) {\n" 137 | out append "\t\tBGAPIPacketReader r = __packet.getPayloadReader();\n" 138 | 139 | var params = List[String]() 140 | e \ "params" \ "param" foreach { a => 141 | val a_datatype = (a \ "@datatype").text 142 | var a_name = (a \ "@name").text 143 | val a_type = (a \ "@type").text 144 | params ::= "\t\t" + getJavaType(a_type) + " " + a_name + " = r.r_" + a_type + "();\n" 145 | } 146 | out append params.reverse.mkString("") 147 | 148 | out append "\t\tfor(BGAPIListener l : listeners) l.receive_" + p_name + "_" + e_name + "(" 149 | params = List[String]() 150 | e \ "params" \ "param" foreach { a => 151 | val a_datatype = (a \ "@datatype").text 152 | var a_name = (a \ "@name").text 153 | val a_type = (a \ "@type").text 154 | params ::= a_name 155 | } 156 | out append params.reverse.mkString(", ") 157 | out append ");\n" 158 | out append "\t}\n" 159 | 160 | } 161 | } 162 | } 163 | 164 | def generateReceiveSwitch (out : StringBuilder, root: scala.xml.Elem) = { 165 | 166 | out append "\t\tif (packet.getMsgType() == 0) {\n" 167 | out append "\t\t\tswitch(packet.classID) {\n" 168 | root \ "class" foreach { p => 169 | val p_index = (p \ "@index").text 170 | var p_name = (p \ "@name").text 171 | out append "\t\t\t\tcase " + p_index + ": receive_" + p_name + "_cmd(packet);break;\n" 172 | } 173 | out append "\t\t\t\tdefault: break;\n" 174 | out append "\t\t\t}\n" 175 | out append "\t\t}\n" 176 | 177 | out append "\t\telse {\n" 178 | out append "\t\t\tswitch(packet.classID) {\n" 179 | root \ "class" foreach { p => 180 | val p_index = (p \ "@index").text 181 | var p_name = (p \ "@name").text 182 | out append "\t\t\t\tcase " + p_index + ": receive_" + p_name + "_evt(packet);break;\n" 183 | } 184 | out append "\t\t\t\tdefault: break;\n" 185 | out append "\t\t\t}\n" 186 | out append "\t\t}\n" 187 | } 188 | 189 | 190 | def generateReceiveSwitchOps (out : StringBuilder, root: scala.xml.Elem) = { 191 | 192 | root \ "class" foreach { p => 193 | val p_index = (p \ "@index").text 194 | var p_name = (p \ "@name").text 195 | //out append "\n\t// Callbacks for class " + p_name + " (index = " + p_index + ")\n" 196 | 197 | out append "\tprivate void receive_" + p_name + "_cmd(BGAPIPacket packet) {\n" 198 | out append "\t\tswitch(packet.commandID) {\n" 199 | 200 | p \ "command" foreach { c => 201 | val c_index = (c \ "@index").text 202 | val c_name = (c \ "@name").text 203 | val c_script = (c \ "@script").text 204 | out append "\t\t\tcase " + c_index + ": receive_" + p_name + "_" + c_name + "(packet); break;\n" 205 | } 206 | 207 | out append "\t\t\tdefault: break;\n" 208 | out append "\t\t}\n" 209 | out append "\t}\n" 210 | 211 | out append "\tprivate void receive_" + p_name + "_evt(BGAPIPacket packet) {\n" 212 | out append "\t\tswitch(packet.commandID) {\n" 213 | 214 | p \ "event" foreach { e => 215 | val e_index = (e \ "@index").text 216 | val e_name = (e \ "@name").text 217 | val e_script = (e \ "@script").text 218 | out append "\t\t\tcase " + e_index + ": receive_" + p_name + "_" + e_name + "(packet); break;\n" 219 | } 220 | 221 | out append "\t\t\tdefault: break;\n" 222 | out append "\t\t}\n" 223 | out append "\t}\n" 224 | } 225 | } 226 | 227 | 228 | def generateSendOperations (out : StringBuilder, root: scala.xml.Elem) = { 229 | 230 | root \ "class" foreach { p => 231 | val p_index = (p \ "@index").text 232 | var p_name = (p \ "@name").text 233 | out append "\n\t// Callbacks for class " + p_name + " (index = " + p_index + ")\n" 234 | 235 | p \ "command" foreach { c => 236 | val c_index = (c \ "@index").text 237 | val c_name = (c \ "@name").text 238 | val c_script = (c \ "@script").text 239 | 240 | out append "\tpublic void send_" + p_name + "_" + c_name + "(" 241 | 242 | var params = List[String]() 243 | c \ "params" \ "param" foreach { a => 244 | val a_datatype = (a \ "@datatype").text 245 | var a_name = (a \ "@name").text 246 | val a_type = (a \ "@type").text 247 | params ::= getJavaType(a_type) + " " + a_name 248 | } 249 | 250 | out append params.reverse.mkString(", ") 251 | out append ") {\n" 252 | out append "\t\tBGAPIPacket p = new BGAPIPacket(0, "+ p_index +", "+c_index+");\n" 253 | 254 | params = List[String]() 255 | c \ "params" \ "param" foreach { a => 256 | val a_datatype = (a \ "@datatype").text 257 | var a_name = (a \ "@name").text 258 | val a_type = (a \ "@type").text 259 | params ::= "\t\tp.w_" + a_type + "(" + a_name +");\n" 260 | } 261 | out append params.reverse.mkString("") 262 | out append "\t\tbgapi.sendPacket(p);\n" 263 | 264 | out append "\t}\n" 265 | } 266 | } 267 | } 268 | 269 | def main(args : Array[String]) { 270 | println( "Loading XML..." ); 271 | val url = getClass.getResource("/bleapi1155.xml") 272 | println( "url = " + url ); 273 | val bleapi = XML.loadFile(url.getFile) 274 | 275 | { 276 | var result = SimpleCopyTemplate.copyFromClassPath("BGAPIListener.javat") 277 | 278 | var builder = new StringBuilder() 279 | generateReceiveOperations(builder, bleapi, "", ";") 280 | result = result.replace("/*METHODS*/", builder.toString()) 281 | 282 | println("************************************************************************************") 283 | println("* BGAPIListener.java") 284 | println("************************************************************************************") 285 | println(result.toString) 286 | } 287 | 288 | { 289 | var result = SimpleCopyTemplate.copyFromClassPath("BGAPIDefaultListener.javat") 290 | 291 | var builder = new StringBuilder() 292 | generateReceiveOperations(builder, bleapi, "public ", " {}") 293 | result = result.replace("/*METHODS*/", builder.toString()) 294 | 295 | println("************************************************************************************") 296 | println("* BGAPIDefaultListener.java") 297 | println("************************************************************************************") 298 | println(result.toString) 299 | } 300 | 301 | { 302 | var result = SimpleCopyTemplate.copyFromClassPath("BGAPIImpl.javat") 303 | 304 | var builder = new StringBuilder() 305 | generateSendOperations(builder, bleapi) 306 | result = result.replace("/*SENDS*/", builder.toString()) 307 | 308 | builder = new StringBuilder() 309 | generateReceiveHandlers(builder, bleapi) 310 | result = result.replace("/*RECEIVES*/", builder.toString()) 311 | 312 | builder = new StringBuilder() 313 | generateReceiveSwitch(builder, bleapi) 314 | result = result.replace("/*SWITCH*/", builder.toString()) 315 | 316 | builder = new StringBuilder() 317 | generateReceiveSwitchOps(builder, bleapi) 318 | result = result.replace("/*SWITCHOPS*/", builder.toString()) 319 | 320 | println("************************************************************************************") 321 | println("* BGAPIImpl.java") 322 | println("************************************************************************************") 323 | println(result.toString) 324 | } 325 | 326 | 327 | /* 328 | result = result.replace("/*TYPES*/", builder.toString()) 329 | 330 | builder = new StringBuilder() 331 | generateMessages(builder, bleapi) 332 | result = result.replace("/*MESSAGES*/", builder.toString()) 333 | 334 | builder = new StringBuilder() 335 | generatePortsFragment(builder, bleapi) 336 | result = result.replace("/*LIB_PORTS*/", builder.toString()) 337 | 338 | builder = new StringBuilder() 339 | generateClientPortsFragment(builder, bleapi) 340 | result = result.replace("/*CLIENT_PORTS*/", builder.toString()) 341 | 342 | builder = new StringBuilder() 343 | generateCallbacks(builder, bleapi) 344 | result = result.replace("/*CALLBACKS*/", builder.toString()) 345 | 346 | builder = new StringBuilder() 347 | generateImpl(builder, bleapi) 348 | result = result.replace("/*IMPL_SM*/", builder.toString()) 349 | 350 | println(result.toString) */ 351 | } 352 | 353 | 354 | 355 | 356 | 357 | } 358 | -------------------------------------------------------------------------------- /bglib-generator/src/main/scala/BGLibGen/BluegigaGenerator.scala: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (C) 2012 SINTEF 3 | * 4 | * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE, Version 3, 29 June 2007; 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.gnu.org/licenses/lgpl-3.0.txt 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package BGLibGen 17 | 18 | import xml.XML 19 | import java.util.Hashtable 20 | import io.Source 21 | 22 | 23 | 24 | object BluegigaGenerator { 25 | 26 | val kwds = List[String]("port", "end", "state", "function") 27 | 28 | 29 | val byte_sizes : Hashtable[String, String] = { 30 | val result = new Hashtable[String, String]() 31 | result.put("uint8", "1") 32 | result.put("uint16", "2") 33 | result.put("int16", "2") 34 | result.put("uint32", "4") 35 | result.put("int8", "1") 36 | result 37 | } 38 | 39 | def getByteSize(c_type : String) = { 40 | var result = byte_sizes.get(c_type) 41 | if (result == null) result = "*" 42 | result 43 | } 44 | 45 | def generateDataTypes(out : StringBuilder, root: scala.xml.Elem) = { 46 | 47 | out append "/* Datatypes definitions */\n\n" 48 | 49 | root \ "datatypes" \ "datatype" foreach { dt => 50 | val name = (dt \ "@name").text 51 | var base = (dt \ "@base").text 52 | if (base == "bd_addr") base += "*" 53 | out append "datatype " + name + "\n" 54 | out append "\t@c_type \""+ base +"\"\n" 55 | out append "\t@c_byte_size \"" + getByteSize(base) + "\"\n" 56 | out append "\t@java_type \"???\";\n\n" 57 | } 58 | 59 | out append "datatype byteArray\n" 60 | out append "@c_type \"uint8*\"\n" 61 | out append "@c_byte_size \"*\"\n" 62 | out append "@java_type \"???\";\n\n" 63 | 64 | } 65 | 66 | def generateMessages (out : StringBuilder, root: scala.xml.Elem) = { 67 | 68 | out append "// Messages defintions fragment\n" 69 | out append "thing fragment BGLibMsgs\n" 70 | out append "@c_header \"#include \\\"apitypes.h\\\"\"\n" 71 | out append "{\n" 72 | 73 | root \ "class" foreach { p => 74 | val p_index = (p \ "@index").text 75 | var p_name = (p \ "@name").text 76 | out append "\n\t// Messages for class " + p_name + " (index = " + p_index + ")\n" 77 | 78 | p \ "command" foreach { c => 79 | val c_index = (c \ "@index").text 80 | val c_name = (c \ "@name").text 81 | val c_script = (c \ "@script").text 82 | 83 | out append "\tmessage " + c_name + "(" 84 | 85 | var params = List[String]() 86 | c \ "params" \ "param" foreach { a => 87 | val a_datatype = (a \ "@datatype").text 88 | var a_name = (a \ "@name").text 89 | val a_type = (a \ "@type").text 90 | 91 | if (a_datatype == "uint8array") { 92 | // Generate 2 parameters array, followed by length 93 | params ::= (a_name + "_len : uint8") 94 | params ::= (a_name + "_data : byteArray") 95 | } 96 | else { 97 | if (kwds.contains(a_name)) a_name = "_" + a_name 98 | params ::= (a_name + " : " + a_datatype) 99 | } 100 | } 101 | 102 | out append params.reverse.mkString(", ") 103 | out append ")\n" 104 | out append "\t\t@bgapi_index \"" + c_index + "\" " 105 | out append "@bgapi_script \"" + c_script + "\"\n" 106 | out append "\t\t@response_message \"" + c_name + "_rsp\"" 107 | out append ";\n" 108 | 109 | out append "\tmessage " + c_name + "_rsp(" 110 | 111 | params = List[String]() 112 | c \ "returns" \ "param" foreach { a => 113 | val a_datatype = (a \ "@datatype").text 114 | var a_name = (a \ "@name").text 115 | val a_type = (a \ "@type").text 116 | 117 | if (a_datatype == "uint8array") { 118 | // Generate 2 parameters array, followed by length 119 | params ::= (a_name + "_len : uint8") 120 | params ::= (a_name + "_data : byteArray") 121 | } 122 | else { 123 | if (kwds.contains(a_name)) a_name = "_" + a_name 124 | params ::= (a_name + " : " + a_datatype) 125 | } 126 | } 127 | 128 | out append params.reverse.mkString(", ") 129 | out append ")\n" 130 | out append "\t\t@bgapi_index \"" + c_index + "\" " 131 | out append "@bgapi_script \"" + c_script + "\"\n" 132 | out append "\t\t@request_message \"" + c_name + "\"" 133 | out append ";\n" 134 | 135 | } 136 | p \ "event" foreach { e => 137 | val e_index = (e \ "@index").text 138 | val e_name = (e \ "@name").text 139 | val e_script = (e \ "@script").text 140 | 141 | out append "\tmessage " + e_name + "_evt(" 142 | 143 | var params = List[String]() 144 | e \ "params" \ "param" foreach { a => 145 | val a_datatype = (a \ "@datatype").text 146 | var a_name = (a \ "@name").text 147 | val a_type = (a \ "@type").text 148 | 149 | if (a_datatype == "uint8array") { 150 | // Generate 2 parameters array, followed by length 151 | params ::= (a_name + "_len : uint8") 152 | params ::= (a_name + "_data : byteArray") 153 | } 154 | else { 155 | if (kwds.contains(a_name)) a_name = "_" + a_name 156 | params ::= (a_name + " : " + a_datatype) 157 | } 158 | } 159 | 160 | out append params.reverse.mkString(", ") 161 | out append ")\n" 162 | out append "\t\t@bgapi_index \"" + e_index + "\" " 163 | out append "@bgapi_script \"" + e_script + "\"" 164 | out append ";\n" 165 | 166 | } 167 | } 168 | out append "}\n" 169 | } 170 | 171 | 172 | def generateCallbacks (out : StringBuilder, root: scala.xml.Elem) = { 173 | 174 | root \ "class" foreach { p => 175 | val p_index = (p \ "@index").text 176 | var p_name = (p \ "@name").text 177 | out append "\n\t// Callbacks for class " + p_name + " (index = " + p_index + ")\n" 178 | 179 | p \ "command" foreach { c => 180 | val c_index = (c \ "@index").text 181 | val c_name = (c \ "@name").text 182 | val c_script = (c \ "@script").text 183 | 184 | var params = List[String]() 185 | c \ "returns" \ "param" foreach { a => 186 | val a_datatype = (a \ "@datatype").text 187 | var a_name = (a \ "@name").text 188 | val a_type = (a \ "@type").text 189 | 190 | if (a_datatype == "uint8array") { 191 | // Generate 2 parameters array, followed by length 192 | params ::= ("'msg->" + a_name + ".len'") 193 | params ::= ("'msg->" + a_name + ".data'") 194 | } 195 | else if (a_datatype == "bd_addr") { 196 | //if (kwds.contains(a_name)) a_name = "_" + a_name 197 | params ::= ("'&msg->" + a_name + "'") 198 | } 199 | else { 200 | //if (kwds.contains(a_name)) a_name = "_" + a_name 201 | params ::= ("'msg->" + a_name + "'") 202 | } 203 | } 204 | 205 | out append "\tfunction " + c_name + "_rsp_callback()\n" 206 | //void ble_evt_gap_mode_changed(const struct ble_msg_gap_mode_changed_evt_t *msg) 207 | out append "\t@c_prototype \"" 208 | 209 | if (params.size > 0) { 210 | out append "void ble_rsp_" + p_name + "_" + c_name +"(const struct ble_msg_" 211 | out append p_name + "_" + c_name + "_rsp_t *msg)\"\n" 212 | } 213 | else { 214 | out append "void ble_rsp_" + p_name + "_" + c_name +"(const void *nul)\"\n" 215 | } 216 | out append "\t@c_instance_var_name \"_bgapi_instance\"\n" 217 | //gap!mode_changed_evt('msg->discover', 'msg->connect') 218 | out append "\t" + p_name + "!" + c_name + "_rsp(" 219 | 220 | out append params.reverse.mkString(", ") 221 | out append ")\n\n" 222 | 223 | } 224 | 225 | p \ "event" foreach { e => 226 | val e_index = (e \ "@index").text 227 | val e_name = (e \ "@name").text 228 | val e_script = (e \ "@script").text 229 | 230 | var params = List[String]() 231 | e \ "params" \ "param" foreach { a => 232 | val a_datatype = (a \ "@datatype").text 233 | var a_name = (a \ "@name").text 234 | val a_type = (a \ "@type").text 235 | 236 | if (a_datatype == "uint8array") { 237 | // Generate 2 parameters array, followed by length 238 | params ::= ("'msg->" + a_name + ".len'") 239 | params ::= ("'msg->" + a_name + ".data'") 240 | } 241 | else if (a_datatype == "bd_addr") { 242 | //if (kwds.contains(a_name)) a_name = "_" + a_name 243 | params ::= ("'&msg->" + a_name + "'") 244 | } 245 | else { 246 | //if (kwds.contains(a_name)) a_name = "_" + a_name 247 | params ::= ("'msg->" + a_name + "'") 248 | } 249 | } 250 | 251 | out append "\tfunction " + e_name + "_evt_callback()\n" 252 | //void ble_evt_gap_mode_changed(const struct ble_msg_gap_mode_changed_evt_t *msg) 253 | out append "\t@c_prototype \"" 254 | 255 | if (params.size > 0) { 256 | out append "void ble_evt_" + p_name + "_" + e_name +"(const struct ble_msg_" 257 | out append p_name + "_" + e_name + "_evt_t *msg)\"\n" 258 | } 259 | else { 260 | out append "void ble_rsp_" + p_name + "_" + e_name +"(const void *nul)\"\n" 261 | } 262 | 263 | 264 | out append "\t@c_instance_var_name \"_bgapi_instance\"\n" 265 | //gap!mode_changed_evt('msg->discover', 'msg->connect') 266 | out append "\t" + p_name + "!" + e_name + "_evt(" 267 | 268 | out append params.reverse.mkString(", ") 269 | out append ")\n\n" 270 | 271 | } 272 | } 273 | 274 | } 275 | 276 | def generatePortsFragment (out : StringBuilder, root: scala.xml.Elem) = { 277 | 278 | out append "\n// Fragment defining the ports for the BGLib\n" 279 | out append "thing fragment BGLibPorts includes BGLibMsgs, BLED112Ports {\n" 280 | 281 | root \ "class" foreach { p => 282 | val p_index = (p \ "@index").text 283 | val p_name = (p \ "@name").text 284 | 285 | out append "\n\tprovided port " + p_name + " {\n" 286 | 287 | var sends = List[String]() 288 | var receives = List[String]() 289 | var events = List[String]() 290 | 291 | p \ "command" foreach { c => 292 | val c_name = (c \ "@name").text 293 | sends ::= c_name 294 | receives ::= c_name + "_rsp" 295 | } 296 | p \ "event" foreach { e => 297 | val e_name = (e \ "@name").text 298 | events ::= e_name + "_evt" 299 | } 300 | if (sends.length > 0) 301 | out append "\t\t receives " + sends.mkString(", ") + "\n" 302 | if (receives.length > 0) 303 | out append "\t\t sends " + receives.mkString(", ") + "\n" 304 | if (events.length > 0) 305 | out append "\t\t sends " + events.mkString(", ") + "\n" 306 | out append "\t}\n" 307 | } 308 | out append "}\n" 309 | } 310 | 311 | 312 | 313 | 314 | 315 | def generateClientPortsFragment (out : StringBuilder, root: scala.xml.Elem) = { 316 | 317 | out append "\n// Fragment defining the ports for a BGLib client\n" 318 | out append "thing fragment BGLibClientPorts includes BGLibMsgs, BLED112ClientPorts {\n" 319 | 320 | root \ "class" foreach { p => 321 | val p_index = (p \ "@index").text 322 | val p_name = (p \ "@name").text 323 | 324 | out append "\n\trequired port " + p_name + " {\n" 325 | 326 | var sends = List[String]() 327 | var receives = List[String]() 328 | var events = List[String]() 329 | 330 | p \ "command" foreach { c => 331 | val c_name = (c \ "@name").text 332 | sends ::= c_name 333 | receives ::= c_name + "_rsp" 334 | } 335 | p \ "event" foreach { e => 336 | val e_name = (e \ "@name").text 337 | events ::= e_name + "_evt" 338 | } 339 | if (sends.length > 0) 340 | out append "\t\t sends " + sends.mkString(", ") + "\n" 341 | if (receives.length > 0) 342 | out append "\t\t receives " + receives.mkString(", ") + "\n" 343 | if (events.length > 0) 344 | out append "\t\t receives " + events.mkString(", ") + "\n" 345 | out append "\t}\n" 346 | } 347 | out append "}\n" 348 | } 349 | 350 | 351 | 352 | 353 | 354 | def generateImpl (out : StringBuilder, root: scala.xml.Elem) = { 355 | 356 | //out append "// Implemnatation of the API\n" 357 | //out append "thing BGLibImpl includes BGLibPorts {\n\n" 358 | 359 | 360 | out append "\tstatechart BGLibImpl init Running {\n" 361 | //out append "\t\ton entry start_receiver_process()\n" 362 | out append "\t\tstate Running {}\n\n" 363 | 364 | out append "\t\tinternal event bled112?bled112_connect action start_receiver_process()\n\n" 365 | 366 | // out append "\t\t// Forwarding all incoming messages to the API\n" 367 | 368 | root \ "class" foreach { p => 369 | val p_index = (p \ "@index").text 370 | var p_name = (p \ "@name").text 371 | out append "\n\t\t// Forward messages for port " + p_name + "\n" 372 | 373 | p \ "command" foreach { c => 374 | val c_index = (c \ "@index").text 375 | val c_name = (c \ "@name").text 376 | val c_script = (c \ "@script").text 377 | 378 | out append "\t\tinternal event m : " + p_name + "?" + c_name + " " 379 | out append "action 'ble_cmd_"+p_name+"_"+c_name+"(" 380 | 381 | var params = List[String]() 382 | c \ "params" \ "param" foreach { a => 383 | var a_name = (a \ "@name").text 384 | val a_datatype = (a \ "@datatype").text 385 | 386 | if (a_datatype == "uint8array") { 387 | // Generate 2 parameters array, followed by length 388 | params ::= ( "'& m." + a_name + "_len &'") 389 | params ::= ( "'& m." + a_name + "_data &'") 390 | } 391 | else { 392 | 393 | if (kwds.contains(a_name)) a_name = "_" + a_name 394 | params ::= ( "'& m." + a_name + " &'") 395 | } 396 | } 397 | 398 | out append params.reverse.mkString(", ") 399 | out append ");'\n" 400 | } 401 | } 402 | out append "\t}\n" 403 | //out append "}\n" 404 | } 405 | 406 | 407 | def main(args : Array[String]) { 408 | println( "Loading XML..." ); 409 | val url = getClass.getResource("/bleapi1155.xml") 410 | println( "url = " + url ); 411 | val bleapi = XML.loadFile(url.getFile) 412 | 413 | var result = SimpleCopyTemplate.copyFromClassPath("output.thingml") 414 | 415 | var builder = new StringBuilder() 416 | generateDataTypes(builder, bleapi) 417 | result = result.replace("/*TYPES*/", builder.toString()) 418 | 419 | builder = new StringBuilder() 420 | generateMessages(builder, bleapi) 421 | result = result.replace("/*MESSAGES*/", builder.toString()) 422 | 423 | builder = new StringBuilder() 424 | generatePortsFragment(builder, bleapi) 425 | result = result.replace("/*LIB_PORTS*/", builder.toString()) 426 | 427 | builder = new StringBuilder() 428 | generateClientPortsFragment(builder, bleapi) 429 | result = result.replace("/*CLIENT_PORTS*/", builder.toString()) 430 | 431 | builder = new StringBuilder() 432 | generateCallbacks(builder, bleapi) 433 | result = result.replace("/*CALLBACKS*/", builder.toString()) 434 | 435 | builder = new StringBuilder() 436 | generateImpl(builder, bleapi) 437 | result = result.replace("/*IMPL_SM*/", builder.toString()) 438 | 439 | println(result.toString) 440 | } 441 | 442 | 443 | 444 | 445 | 446 | } 447 | -------------------------------------------------------------------------------- /bglib-generator/src/main/resources/commands.c: -------------------------------------------------------------------------------- 1 | /***************************************************************************** 2 | * Copyright (C) 2000-2012 Bluegiga Technologies Inc. All rights reserved. All 3 | * unauthorized copying and distribution prohibited. 4 | ****************************************************************************/ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | #include "cmd_def.h" 11 | 12 | /** 13 | * 14 | */ 15 | void ble_default(const void*v) 16 | { 17 | } 18 | 19 | /** 20 | * 21 | */ 22 | void ble_rsp_hardware_set_txpower(const void *nul) 23 | { 24 | 25 | } 26 | 27 | /** 28 | * 29 | */ 30 | void ble_rsp_attclient_read_multiple(const struct ble_msg_attclient_read_multiple_rsp_t *msg) 31 | { 32 | 33 | } 34 | 35 | /** 36 | * 37 | */ 38 | void ble_evt_attclient_read_multiple_response(const struct ble_msg_attclient_read_multiple_response_evt_t *msg) 39 | { 40 | 41 | } 42 | 43 | /** 44 | * 45 | */ 46 | void ble_rsp_attclient_prepare_write(const struct ble_msg_attclient_prepare_write_rsp_t *msg) 47 | { 48 | 49 | } 50 | 51 | /** 52 | * 53 | */ 54 | void ble_rsp_attclient_execute_write(const struct ble_msg_attclient_execute_write_rsp_t *msg) 55 | { 56 | 57 | } 58 | 59 | /** 60 | * 61 | */ 62 | void ble_evt_attributes_user_request(const struct ble_msg_attributes_user_request_evt_t *msg) 63 | { 64 | 65 | } 66 | 67 | /** 68 | * 69 | */ 70 | void ble_rsp_attributes_user_response(const void * nul) 71 | { 72 | 73 | } 74 | 75 | /** 76 | * 77 | */ 78 | void ble_rsp_system_whitelist_clear(const void *nul) 79 | { 80 | 81 | } 82 | 83 | /** 84 | * 85 | */ 86 | void ble_rsp_attclient_write_command(const struct ble_msg_attclient_write_command_rsp_t *msg) 87 | { 88 | 89 | } 90 | 91 | /** 92 | * 93 | */ 94 | void ble_rsp_attclient_reserved(const void *nul) 95 | { 96 | 97 | } 98 | 99 | /** 100 | * 101 | */ 102 | void ble_rsp_attclient_read_long(const struct ble_msg_attclient_read_long_rsp_t *msg) 103 | { 104 | 105 | } 106 | 107 | /** 108 | * 109 | */ 110 | void ble_rsp_system_whitelist_append(const struct ble_msg_system_whitelist_append_rsp_t *msg) 111 | { 112 | 113 | } 114 | 115 | /** 116 | * 117 | */ 118 | void ble_rsp_sm_set_parameters(const void *nul) 119 | { 120 | 121 | } 122 | 123 | /** 124 | * 125 | */ 126 | void ble_rsp_sm_passkey_entry(const struct ble_msg_sm_passkey_entry_rsp_t *msg) 127 | { 128 | 129 | } 130 | 131 | /** 132 | * 133 | */ 134 | void ble_rsp_sm_get_bonds(const struct ble_msg_sm_get_bonds_rsp_t *msg) 135 | { 136 | 137 | } 138 | 139 | /** 140 | * 141 | */ 142 | void ble_rsp_sm_set_oob_data(const void *nul) 143 | { 144 | 145 | } 146 | 147 | /** 148 | * 149 | */ 150 | void ble_rsp_sm_set_security_mode(const void *nul) 151 | { 152 | 153 | } 154 | 155 | /** 156 | * 157 | */ 158 | void ble_rsp_gap_set_filtering(const struct ble_msg_gap_set_filtering_rsp_t *msg) 159 | { 160 | 161 | } 162 | 163 | /** 164 | * 165 | */ 166 | void ble_rsp_gap_set_adv_parameters(const struct ble_msg_gap_set_adv_parameters_rsp_t *msg) 167 | { 168 | 169 | } 170 | 171 | /** 172 | * 173 | */ 174 | void ble_rsp_hardware_io_port_write(const struct ble_msg_hardware_io_port_write_rsp_t *msg) 175 | { 176 | 177 | } 178 | 179 | void ble_rsp_hardware_io_port_read(const struct ble_msg_hardware_io_port_read_rsp_t *msg) 180 | { 181 | 182 | } 183 | 184 | /** 185 | * 186 | */ 187 | void ble_rsp_hardware_spi_config(const struct ble_msg_hardware_spi_config_rsp_t *msg) 188 | { 189 | 190 | } 191 | 192 | /** 193 | * 194 | */ 195 | void ble_rsp_hardware_spi_transfer(const struct ble_msg_hardware_spi_transfer_rsp_t *msg) 196 | { 197 | 198 | } 199 | 200 | /** 201 | * 202 | */ 203 | void ble_rsp_hardware_i2c_read(const struct ble_msg_hardware_i2c_read_rsp_t *msg) 204 | { 205 | 206 | } 207 | 208 | /** 209 | * 210 | */ 211 | void ble_rsp_hardware_i2c_write(const struct ble_msg_hardware_i2c_write_rsp_t *msg) 212 | { 213 | 214 | } 215 | 216 | /** 217 | * 218 | */ 219 | void ble_rsp_test_get_channel_map(const struct ble_msg_test_get_channel_map_rsp_t *msg) 220 | { 221 | 222 | } 223 | 224 | /** 225 | * 226 | */ 227 | void ble_evt_attributes_value(const struct ble_msg_attributes_value_evt_t *msg) 228 | { 229 | 230 | } 231 | 232 | /** 233 | * 234 | */ 235 | void ble_evt_sm_bonding_fail(const struct ble_msg_sm_bonding_fail_evt_t *msg) 236 | { 237 | 238 | } 239 | 240 | /** 241 | * 242 | */ 243 | void ble_evt_sm_passkey_display(const struct ble_msg_sm_passkey_display_evt_t *msg) 244 | { 245 | 246 | } 247 | 248 | void ble_evt_sm_passkey_request(const struct ble_msg_sm_passkey_request_evt_t *msg) 249 | { 250 | 251 | } 252 | 253 | /** 254 | * 255 | */ 256 | void ble_evt_sm_bond_status(const struct ble_msg_sm_bond_status_evt_t *msg) 257 | { 258 | 259 | } 260 | 261 | /** 262 | * 263 | */ 264 | void ble_rsp_gap_set_adv_data(const struct ble_msg_gap_set_adv_data_rsp_t *msg) 265 | { 266 | 267 | } 268 | 269 | /** 270 | * 271 | */ 272 | void ble_rsp_gap_set_scan_parameters(const struct ble_msg_gap_set_scan_parameters_rsp_t *msg) 273 | { 274 | 275 | } 276 | 277 | /** 278 | * 279 | */ 280 | void ble_rsp_gap_set_directed_connectable_mode(const struct ble_msg_gap_set_directed_connectable_mode_rsp_t *msg) 281 | { 282 | 283 | } 284 | 285 | /** 286 | * 287 | */ 288 | void ble_rsp_hardware_io_port_config_direction(const struct ble_msg_hardware_io_port_config_direction_rsp_t *msg) 289 | { 290 | 291 | } 292 | 293 | /** 294 | * 295 | */ 296 | void ble_rsp_hardware_io_port_config_pull(const struct ble_msg_hardware_io_port_config_pull_rsp_t *msg) 297 | { 298 | 299 | } 300 | 301 | /** 302 | * 303 | */ 304 | void ble_rsp_hardware_io_port_config_function(const struct ble_msg_hardware_io_port_config_function_rsp_t *msg) 305 | { 306 | 307 | } 308 | 309 | /** 310 | * 311 | */ 312 | void ble_rsp_gap_set_privacy_flags(const void *nul) 313 | { 314 | 315 | } 316 | 317 | /** 318 | * 319 | */ 320 | void ble_rsp_gap_connect_selective(const struct ble_msg_gap_connect_selective_rsp_t *msg) 321 | { 322 | 323 | } 324 | 325 | /** 326 | * 327 | */ 328 | void ble_rsp_system_whitelist_remove(const struct ble_msg_system_whitelist_remove_rsp_t *msg) 329 | { 330 | 331 | } 332 | 333 | /** 334 | * 335 | */ 336 | void ble_rsp_system_reset(const void* nul) 337 | { 338 | } 339 | 340 | /** 341 | * 342 | */ 343 | void ble_rsp_system_hello(const void* nul) 344 | { 345 | } 346 | 347 | /** 348 | * 349 | */ 350 | void ble_rsp_system_address_get(const struct ble_msg_system_address_get_rsp_t *msg) 351 | { 352 | } 353 | 354 | /** 355 | * 356 | */ 357 | void ble_rsp_system_reg_write(const struct ble_msg_system_reg_write_rsp_t *msg) 358 | { 359 | } 360 | 361 | /** 362 | * 363 | */ 364 | void ble_rsp_system_reg_read(const struct ble_msg_system_reg_read_rsp_t *msg) 365 | { 366 | } 367 | 368 | /** 369 | * 370 | */ 371 | void ble_rsp_system_get_counters(const struct ble_msg_system_get_counters_rsp_t *msg) 372 | { 373 | } 374 | 375 | /** 376 | * 377 | */ 378 | void ble_rsp_system_get_connections(const struct ble_msg_system_get_connections_rsp_t *msg) 379 | { 380 | } 381 | 382 | /** 383 | * 384 | */ 385 | void ble_rsp_system_read_memory(const struct ble_msg_system_read_memory_rsp_t *msg) 386 | { 387 | } 388 | 389 | /** 390 | * 391 | */ 392 | void ble_rsp_system_get_info(const struct ble_msg_system_get_info_rsp_t *msg) 393 | { 394 | } 395 | 396 | /** 397 | * 398 | */ 399 | void ble_rsp_system_endpoint_tx(const void* nul) 400 | { 401 | } 402 | 403 | /** 404 | * 405 | */ 406 | void ble_rsp_flash_ps_defrag(const void* nul) 407 | { 408 | } 409 | 410 | /** 411 | * 412 | */ 413 | void ble_rsp_flash_ps_dump(const void* nul) 414 | { 415 | } 416 | 417 | /** 418 | * 419 | */ 420 | void ble_rsp_flash_ps_erase_all(const void* nul) 421 | { 422 | } 423 | 424 | /** 425 | * 426 | */ 427 | void ble_rsp_flash_ps_save(const struct ble_msg_flash_ps_save_rsp_t *msg) 428 | { 429 | } 430 | 431 | /** 432 | * 433 | */ 434 | void ble_rsp_flash_ps_load(const struct ble_msg_flash_ps_load_rsp_t *msg) 435 | { 436 | } 437 | 438 | /** 439 | * 440 | */ 441 | void ble_rsp_flash_ps_erase(const void* nul) 442 | { 443 | } 444 | 445 | /** 446 | * 447 | */ 448 | void ble_rsp_flash_erase_page(const struct ble_msg_flash_erase_page_rsp_t *msg) 449 | { 450 | } 451 | 452 | /** 453 | * 454 | */ 455 | void ble_rsp_flash_write_words(const void* nul) 456 | { 457 | } 458 | 459 | /** 460 | * 461 | */ 462 | void ble_rsp_attributes_write(const struct ble_msg_attributes_write_rsp_t *msg) 463 | { 464 | } 465 | 466 | /** 467 | * 468 | */ 469 | void ble_rsp_attributes_read(const struct ble_msg_attributes_read_rsp_t *msg) 470 | { 471 | } 472 | 473 | /** 474 | * 475 | */ 476 | void ble_rsp_attributes_read_type(const struct ble_msg_attributes_read_type_rsp_t *msg) 477 | { 478 | } 479 | 480 | /** 481 | * 482 | */ 483 | void ble_rsp_connection_disconnect(const struct ble_msg_connection_disconnect_rsp_t *msg) 484 | { 485 | } 486 | 487 | /** 488 | * 489 | */ 490 | void ble_rsp_connection_get_rssi(const struct ble_msg_connection_get_rssi_rsp_t *msg) 491 | { 492 | } 493 | 494 | /** 495 | * 496 | */ 497 | void ble_rsp_connection_update(const struct ble_msg_connection_update_rsp_t *msg) 498 | { 499 | } 500 | 501 | /** 502 | * 503 | */ 504 | void ble_rsp_connection_version_update(const struct ble_msg_connection_version_update_rsp_t *msg) 505 | { 506 | } 507 | 508 | /** 509 | * 510 | */ 511 | void ble_rsp_connection_channel_map_get(const struct ble_msg_connection_channel_map_get_rsp_t *msg) 512 | { 513 | } 514 | 515 | /** 516 | * 517 | */ 518 | void ble_rsp_connection_channel_map_set(const struct ble_msg_connection_channel_map_set_rsp_t *msg) 519 | { 520 | } 521 | 522 | /** 523 | * 524 | */ 525 | void ble_rsp_connection_features_get(const struct ble_msg_connection_features_get_rsp_t *msg) 526 | { 527 | } 528 | 529 | /** 530 | * 531 | */ 532 | void ble_rsp_connection_get_status(const struct ble_msg_connection_get_status_rsp_t *msg) 533 | { 534 | } 535 | 536 | /** 537 | * 538 | */ 539 | void ble_rsp_connection_raw_tx(const struct ble_msg_connection_raw_tx_rsp_t *msg) 540 | { 541 | } 542 | 543 | /** 544 | * 545 | */ 546 | void ble_rsp_attclient_find_by_type_value(const struct ble_msg_attclient_find_by_type_value_rsp_t *msg) 547 | { 548 | } 549 | 550 | /** 551 | * 552 | */ 553 | void ble_rsp_attclient_read_by_group_type(const struct ble_msg_attclient_read_by_group_type_rsp_t *msg) 554 | { 555 | } 556 | 557 | /** 558 | * 559 | */ 560 | void ble_rsp_attclient_read_by_type(const struct ble_msg_attclient_read_by_type_rsp_t *msg) 561 | { 562 | } 563 | 564 | /** 565 | * 566 | */ 567 | void ble_rsp_attclient_find_information(const struct ble_msg_attclient_find_information_rsp_t *msg) 568 | { 569 | } 570 | 571 | /** 572 | * 573 | */ 574 | void ble_rsp_attclient_read_by_handle(const struct ble_msg_attclient_read_by_handle_rsp_t *msg) 575 | { 576 | } 577 | 578 | /** 579 | * 580 | */ 581 | void ble_rsp_attclient_attribute_write(const struct ble_msg_attclient_attribute_write_rsp_t *msg) 582 | { 583 | } 584 | 585 | /** 586 | * 587 | */ 588 | void ble_rsp_sm_encrypt_start(const struct ble_msg_sm_encrypt_start_rsp_t *msg) 589 | { 590 | } 591 | 592 | /** 593 | * 594 | */ 595 | void ble_rsp_sm_set_bondable_mode(const void* nul) 596 | { 597 | } 598 | 599 | /** 600 | * 601 | */ 602 | void ble_rsp_sm_delete_bonding(const struct ble_msg_sm_delete_bonding_rsp_t *msg) 603 | { 604 | } 605 | 606 | /** 607 | * 608 | */ 609 | void ble_rsp_gap_set_address_mode(const void* nul) 610 | { 611 | } 612 | 613 | /** 614 | * 615 | */ 616 | void ble_rsp_gap_set_mode(const struct ble_msg_gap_set_mode_rsp_t *msg) 617 | { 618 | } 619 | 620 | /** 621 | * 622 | */ 623 | void ble_rsp_gap_discover(const struct ble_msg_gap_discover_rsp_t *msg) 624 | { 625 | } 626 | 627 | /** 628 | * 629 | */ 630 | void ble_rsp_gap_connect_direct(const struct ble_msg_gap_connect_direct_rsp_t *msg) 631 | { 632 | } 633 | 634 | /** 635 | * 636 | */ 637 | void ble_rsp_gap_end_procedure(const struct ble_msg_gap_end_procedure_rsp_t *msg) 638 | { 639 | } 640 | 641 | /** 642 | * 643 | */ 644 | void ble_rsp_hardware_io_port_config_irq(const struct ble_msg_hardware_io_port_config_irq_rsp_t *msg) 645 | { 646 | } 647 | 648 | /** 649 | * 650 | */ 651 | void ble_rsp_hardware_set_soft_timer(const struct ble_msg_hardware_set_soft_timer_rsp_t *msg) 652 | { 653 | } 654 | 655 | /** 656 | * 657 | */ 658 | void ble_rsp_hardware_adc_read(const struct ble_msg_hardware_adc_read_rsp_t *msg) 659 | { 660 | } 661 | 662 | /** 663 | * 664 | */ 665 | void ble_rsp_test_phy_tx(const void* nul) 666 | { 667 | } 668 | 669 | /** 670 | * 671 | */ 672 | void ble_rsp_test_phy_rx(const void* nul) 673 | { 674 | } 675 | 676 | /** 677 | * 678 | */ 679 | void ble_rsp_test_phy_end(const struct ble_msg_test_phy_end_rsp_t *msg) 680 | { 681 | } 682 | 683 | /** 684 | * 685 | */ 686 | void ble_rsp_test_phy_reset(const void* nul) 687 | { 688 | } 689 | 690 | /** 691 | * 692 | */ 693 | void ble_evt_system_boot(const struct ble_msg_system_boot_evt_t *msg) 694 | { 695 | } 696 | 697 | /** 698 | * 699 | */ 700 | void ble_evt_system_debug(const struct ble_msg_system_debug_evt_t *msg) 701 | { 702 | } 703 | 704 | /** 705 | * 706 | */ 707 | void ble_evt_system_endpoint_rx(const struct ble_msg_system_endpoint_rx_evt_t *msg) 708 | { 709 | } 710 | 711 | /** 712 | * 713 | */ 714 | void ble_evt_flash_ps_key(const struct ble_msg_flash_ps_key_evt_t *msg) 715 | { 716 | } 717 | 718 | /** 719 | * 720 | */ 721 | void ble_evt_connection_status(const struct ble_msg_connection_status_evt_t *msg) 722 | { 723 | } 724 | 725 | /** 726 | * 727 | */ 728 | void ble_evt_connection_version_ind(const struct ble_msg_connection_version_ind_evt_t *msg) 729 | { 730 | } 731 | 732 | /** 733 | * 734 | */ 735 | void ble_evt_connection_feature_ind(const struct ble_msg_connection_feature_ind_evt_t *msg) 736 | { 737 | } 738 | 739 | /** 740 | * 741 | */ 742 | void ble_evt_connection_raw_rx(const struct ble_msg_connection_raw_rx_evt_t *msg) 743 | { 744 | } 745 | 746 | /** 747 | * 748 | */ 749 | void ble_evt_connection_disconnected(const struct ble_msg_connection_disconnected_evt_t *msg) 750 | { 751 | } 752 | 753 | /** 754 | * 755 | */ 756 | void ble_evt_attclient_indicated(const struct ble_msg_attclient_indicated_evt_t *msg) 757 | { 758 | } 759 | 760 | /** 761 | * 762 | */ 763 | void ble_evt_attclient_procedure_completed(const struct ble_msg_attclient_procedure_completed_evt_t *msg) 764 | { 765 | } 766 | 767 | /** 768 | * 769 | */ 770 | void ble_evt_attclient_group_found(const struct ble_msg_attclient_group_found_evt_t *msg) 771 | { 772 | } 773 | 774 | /** 775 | * 776 | */ 777 | void ble_evt_attclient_attribute_found(const struct ble_msg_attclient_attribute_found_evt_t *msg) 778 | { 779 | } 780 | 781 | /** 782 | * 783 | */ 784 | void ble_evt_attclient_find_information_found(const struct ble_msg_attclient_find_information_found_evt_t *msg) 785 | { 786 | } 787 | 788 | /** 789 | * 790 | */ 791 | void ble_evt_attclient_attribute_value(const struct ble_msg_attclient_attribute_value_evt_t *msg) 792 | { 793 | } 794 | 795 | /** 796 | * 797 | */ 798 | void ble_evt_sm_smp_data(const struct ble_msg_sm_smp_data_evt_t *msg) 799 | { 800 | } 801 | 802 | /** 803 | * 804 | */ 805 | void ble_evt_gap_scan_response(const struct ble_msg_gap_scan_response_evt_t *msg) 806 | { 807 | } 808 | 809 | /** 810 | * 811 | */ 812 | void ble_evt_gap_mode_changed(const struct ble_msg_gap_mode_changed_evt_t *msg) 813 | { 814 | } 815 | 816 | /** 817 | * 818 | */ 819 | void ble_evt_hardware_io_port_status(const struct ble_msg_hardware_io_port_status_evt_t *msg) 820 | { 821 | } 822 | 823 | /** 824 | * 825 | */ 826 | void ble_evt_hardware_soft_timer(const struct ble_msg_hardware_soft_timer_evt_t *msg) 827 | { 828 | } 829 | 830 | /** 831 | * 832 | */ 833 | void ble_evt_hardware_adc_result(const struct ble_msg_hardware_adc_result_evt_t *msg) 834 | { 835 | } 836 | 837 | -------------------------------------------------------------------------------- /bglib-gui/src/main/java/org/thingml/bglib/gui/BLEExplorerFrame.form: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | 291 | 292 | 293 | 294 | 295 | 296 | 297 | 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 |
311 | --------------------------------------------------------------------------------