mirror of
https://github.com/espressif/esp-idf.git
synced 2026-06-17 17:34:03 +02:00
Compare commits
822 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cc5440f6a2 | |||
| 43e439698d | |||
| 56f6378727 | |||
| 5ffe84bec4 | |||
| 830126a3b7 | |||
| ea7b022cdf | |||
| 91439e2c70 | |||
| 9fc4057e9e | |||
| 049f492b8a | |||
| ccab4633de | |||
| 327c22103b | |||
| 0b84dcaf13 | |||
| 3d59008788 | |||
| a4fd697a57 | |||
| 64aaaf87a7 | |||
| 485ea20eae | |||
| ab40f7ab0a | |||
| 1e02903c87 | |||
| a7fb697083 | |||
| 19f15190a2 | |||
| 002db67195 | |||
| 016a08a3bb | |||
| cd428d0346 | |||
| 30268103d5 | |||
| 53a0cbd592 | |||
| 80d5c63b36 | |||
| b67821b2a7 | |||
| 88645a97b4 | |||
| 776d24e83f | |||
| 66d7cf8db5 | |||
| 3eacc32c8c | |||
| 5408374d63 | |||
| 10db99e449 | |||
| 2c7b20ff13 | |||
| 3078e504e3 | |||
| ab6c21dd1f | |||
| 2d572e2c15 | |||
| 94bbb4185c | |||
| ccc2ce93d6 | |||
| 24a79107d7 | |||
| 2840a77b0e | |||
| 720be0f23f | |||
| cdf0e89a09 | |||
| bd5552faec | |||
| e85fc1f9c5 | |||
| 46c4842c0e | |||
| 4baf48074c | |||
| e774f217b6 | |||
| 0677774a52 | |||
| e21bfde305 | |||
| 745e7e25c8 | |||
| b6f9c4b62a | |||
| d0dd9d446c | |||
| 0755078ee6 | |||
| 63bd02b1d8 | |||
| 42fd5a948a | |||
| 86f31403e5 | |||
| a6a39dbb41 | |||
| bdcc2cb638 | |||
| 84ef653a1e | |||
| 6a18dba4cd | |||
| a132363390 | |||
| c985e5567a | |||
| c2c33ac9a5 | |||
| fb3dd453df | |||
| 6e0fae9878 | |||
| 4cc7a85701 | |||
| 7a49a131d3 | |||
| 7b5456dd27 | |||
| 20aec9c113 | |||
| 77619bafca | |||
| 0e8e3f3d28 | |||
| db313f2c00 | |||
| 95e27869f8 | |||
| ebc93210a1 | |||
| 1d5a967c4c | |||
| 37e2e7599a | |||
| cc2e952edb | |||
| 678275045f | |||
| e0e1fab0ab | |||
| 77799ec529 | |||
| c8f2193515 | |||
| ff8531b08e | |||
| 6b64edca6d | |||
| 15c97b5a58 | |||
| ab4613cadf | |||
| 2c011b6256 | |||
| a100174f47 | |||
| f4909b8ac6 | |||
| 8340d36359 | |||
| 4734765745 | |||
| e0ef3bb303 | |||
| 38d328b566 | |||
| 8a53a75ac3 | |||
| 638b7f5ff4 | |||
| 881522c9b8 | |||
| 7b271ac0ce | |||
| e72de12566 | |||
| 03fc607492 | |||
| c6106b5ac0 | |||
| 3924ca8f03 | |||
| 53d1eda84c | |||
| e742889689 | |||
| 437b215e62 | |||
| 033a596810 | |||
| b95e11939d | |||
| c571273674 | |||
| b1d235ebb5 | |||
| 2a4b854a6d | |||
| 3b30f7044c | |||
| c9033019f9 | |||
| ca87b35cf1 | |||
| 216d0777fd | |||
| 98cf27dbf8 | |||
| 63b2ca84c4 | |||
| 6f0848aa3d | |||
| f4ce4efdb8 | |||
| aafbb8f5a8 | |||
| e173e47322 | |||
| 07167c8c7b | |||
| a6c52e1924 | |||
| 873a759f48 | |||
| 6a2d7ef994 | |||
| 71fc9de66b | |||
| c631fdf33c | |||
| 44e9dd3e29 | |||
| 41a9d01ee5 | |||
| f189ba5883 | |||
| dafc6c27b7 | |||
| c406655e47 | |||
| 8c987d0f04 | |||
| c621ea7c8c | |||
| d5447f197d | |||
| 30d1564b3c | |||
| 38b0870fab | |||
| 09840aeeaa | |||
| e1374b9c7c | |||
| 8f0bcc570a | |||
| c47854f1fc | |||
| 4b07e33a12 | |||
| f69d7cafce | |||
| 5401610a4e | |||
| f1ba2b3e3a | |||
| b2a9dc283b | |||
| 30f6bbf218 | |||
| c43792e792 | |||
| a7ce9603de | |||
| cc40b77c4c | |||
| b37d504cd0 | |||
| 5f251dfc70 | |||
| 08d29e2aaa | |||
| 352fb9168a | |||
| fb3b6e0094 | |||
| e793571cc4 | |||
| b1985c2392 | |||
| 28669ca32a | |||
| cd40b05bd0 | |||
| 4b81abe053 | |||
| af8e81d18e | |||
| 700eee91ca | |||
| 41676c779c | |||
| 624eaf4d06 | |||
| fcca83efff | |||
| bcf14bca1e | |||
| 3deffb785f | |||
| bfd4f8646e | |||
| e2015eb371 | |||
| d93ad78b46 | |||
| 5b91a8173e | |||
| 04a6aae1d1 | |||
| ee3e817a93 | |||
| 9d075a728a | |||
| b59c06c107 | |||
| 789914a405 | |||
| 81befb2330 | |||
| 594d681aae | |||
| a6176fa73e | |||
| 9dd12683e6 | |||
| 69af3d2a72 | |||
| bc60eb65e2 | |||
| a130da9e79 | |||
| b403b0dbd5 | |||
| 557525eeb9 | |||
| 26d8690525 | |||
| cba17ebc0a | |||
| 1de77f5412 | |||
| 671ab9223c | |||
| ec14f20421 | |||
| 760ea137ee | |||
| 6e136860ae | |||
| 6731c9daf3 | |||
| 708b72190f | |||
| 411abfd70f | |||
| 84dd05439d | |||
| b82577168a | |||
| f5fc806588 | |||
| 35bbd1ba26 | |||
| 9d324fecb7 | |||
| b3827a4b74 | |||
| 78676e7a02 | |||
| 4f0ab9ee73 | |||
| 77c7d3be1c | |||
| 1b076b5e42 | |||
| b65a37795f | |||
| 9590db4cb6 | |||
| b2bcbd5559 | |||
| 94ca8b8917 | |||
| 85ec75b970 | |||
| a6fc744026 | |||
| 35a7462e69 | |||
| 9703c1a32f | |||
| 62359f3442 | |||
| 19636db724 | |||
| 11caa6fcf2 | |||
| ac6f6a3768 | |||
| e2d6ce553d | |||
| cce139e5bd | |||
| d7562e2b2c | |||
| c9cf530c51 | |||
| 4e64cbb576 | |||
| bb824d7a4b | |||
| 62a4a0dcaf | |||
| 22487a65ac | |||
| 906dbd262e | |||
| f656c04d12 | |||
| 504a9e178f | |||
| c7add96e64 | |||
| 4fce8182b9 | |||
| ea14555cf9 | |||
| fb55f9f397 | |||
| 5198a7a46b | |||
| 6aaddf972c | |||
| 4ec4d40af7 | |||
| 0f80b6363c | |||
| 3bc41719ae | |||
| 0fb2ff12b8 | |||
| 9f56c39630 | |||
| aacc7e07a6 | |||
| fc60e09295 | |||
| 6b263ae8cb | |||
| ea73e952a1 | |||
| d743f8502d | |||
| c4ee49edf1 | |||
| 86f4afa330 | |||
| 0c2fb10e0c | |||
| b3880ce487 | |||
| c15ecf9fcd | |||
| 3bdb0ce5c1 | |||
| c0aee61ce0 | |||
| 61a1e0d5c9 | |||
| 01cb29ba5a | |||
| f24f7ab97b | |||
| e5f496149e | |||
| fa00fd5c8a | |||
| 1a47ecbfac | |||
| 542c3e07a0 | |||
| 9772facaca | |||
| f845643608 | |||
| a040ec1eec | |||
| 6d44b690b8 | |||
| ef7ae9a3ee | |||
| e74a36da43 | |||
| dc9c0a9f6d | |||
| 70cafac4bd | |||
| c8996feebb | |||
| 8fcca01384 | |||
| da31949530 | |||
| 0982de8c05 | |||
| f11f52b72f | |||
| 648f923015 | |||
| 01fedd2b05 | |||
| 13a069f276 | |||
| aa8f1bef1e | |||
| c3678c5378 | |||
| 9ab19d7b68 | |||
| cf79bfbc5f | |||
| 65b494567b | |||
| 22502bbd38 | |||
| 067f73d4ea | |||
| a943d21126 | |||
| fab97e2405 | |||
| 94f5bc17a9 | |||
| c3e3f8b490 | |||
| eaa02c0ef8 | |||
| 5f03326833 | |||
| bc625858ae | |||
| c3251dcf29 | |||
| 6828b0fcc7 | |||
| 85be396cd3 | |||
| 63d482e162 | |||
| 600a0f841d | |||
| 9a338bc8c3 | |||
| a680159bbb | |||
| 0b0364c719 | |||
| 3c7f439d5b | |||
| 08ce445ab6 | |||
| 2b18d3c628 | |||
| 7c86027531 | |||
| 5713bb1bb8 | |||
| 9eb39ef409 | |||
| dfdf9fe4e2 | |||
| f227fc69e5 | |||
| 30c7be6542 | |||
| 12cb4243f5 | |||
| 069de99a9e | |||
| b082ed5d2b | |||
| f5acc1e446 | |||
| e16ab463d9 | |||
| 832128faf0 | |||
| 85c43024cb | |||
| 2091f4db1c | |||
| 1975d39d44 | |||
| ee2b8a65a0 | |||
| 03810c4a06 | |||
| 61a68ae95e | |||
| 343521ab1a | |||
| 8eb75313d4 | |||
| b34dee5d9e | |||
| 73117b8c94 | |||
| c43efe1502 | |||
| cd90dfa38b | |||
| 0b1bc0b5b8 | |||
| a10dac936c | |||
| 2ad908f71e | |||
| 0bfff0b25a | |||
| a1fd207aee | |||
| 1786fc9ed2 | |||
| c8915cd157 | |||
| a85b97a6f5 | |||
| 88898e2f96 | |||
| d6cafddaa3 | |||
| 716edebbbd | |||
| 47c0ce6fca | |||
| c02d5a4d85 | |||
| 7ffe2c3136 | |||
| 208c2fb0fb | |||
| 1f4d3ac30a | |||
| 928e004208 | |||
| db72885f15 | |||
| 1e4552533d | |||
| 7a85334d80 | |||
| 0aca88a6e9 | |||
| dcaaddae37 | |||
| 4936e8f86c | |||
| 6a4e69f442 | |||
| 19a578c2e0 | |||
| c505fe650f | |||
| 94e84e6c0c | |||
| 44f22150f2 | |||
| d8082b7f39 | |||
| 4005df854f | |||
| 98e17de350 | |||
| 539718735b | |||
| 92676f05fa | |||
| 664597f4ce | |||
| b9f6a5da51 | |||
| a79c9402d6 | |||
| 6418be692a | |||
| 729451ef60 | |||
| 1b0a3f8924 | |||
| 33ad4b6f84 | |||
| 36c3b8980d | |||
| 8610ce4f34 | |||
| af50ceb5e6 | |||
| a3740c97c9 | |||
| 3f15854d96 | |||
| 808f456442 | |||
| 854ccb743d | |||
| 5ee8a808c8 | |||
| 71a50021ca | |||
| 5080a23ac3 | |||
| 3590a6816f | |||
| 827bb925b7 | |||
| 2f4ef71beb | |||
| 7e63061fae | |||
| a31000dcb6 | |||
| 092dc133cc | |||
| 8cef74c151 | |||
| 675d6f26d4 | |||
| d3a27596a1 | |||
| 426736c769 | |||
| ae24692785 | |||
| 3df5b89c91 | |||
| 3a56cfc9b3 | |||
| cd59d107b2 | |||
| 66a1b39814 | |||
| 1df7be0e58 | |||
| d3bdcccd3b | |||
| 79a5037ee2 | |||
| e9caf68d6e | |||
| 60291300a2 | |||
| e9d28837ec | |||
| 6c6ad3f772 | |||
| 71df1f7422 | |||
| d8b42e565c | |||
| 509de0aac3 | |||
| f3aaa39c43 | |||
| f61f54ee67 | |||
| 6917a40294 | |||
| 25147f2560 | |||
| 29e69a12d3 | |||
| d3eb487d40 | |||
| c4aafb06ce | |||
| 777c8bbd44 | |||
| 0b84a1242e | |||
| cc8525f630 | |||
| 0713c7dbb4 | |||
| b0719d3fc6 | |||
| 8ff6e2eee5 | |||
| 6dfb8a5fc3 | |||
| 1a6530156d | |||
| 5487864df9 | |||
| d7d8857fc5 | |||
| 69cd53dbd9 | |||
| 9c252b8f22 | |||
| 56416dddda | |||
| de0d1fffcd | |||
| 46fa26b56f | |||
| 896180ec73 | |||
| 1e747edd7d | |||
| 929ad413cb | |||
| 282d234ea5 | |||
| 86de405578 | |||
| 3e6dd18075 | |||
| 1b4a46a28f | |||
| d5f9d1f748 | |||
| ed420aacc0 | |||
| ee1f925dff | |||
| 0a80c654e9 | |||
| 86dbff4297 | |||
| 857e2f0943 | |||
| a461605003 | |||
| 3cf6f36765 | |||
| 6d63c59ddb | |||
| ace26dda76 | |||
| 3ca579bc23 | |||
| fb6fb2df3b | |||
| f33381b8e8 | |||
| 6d104d49b4 | |||
| 193fcc70dd | |||
| 35d0b93ecf | |||
| 6f3478dae0 | |||
| 4767568837 | |||
| c2f5fc0c88 | |||
| e38adae62b | |||
| 54ee2f2ebc | |||
| 60ebc7f8e3 | |||
| bff66d7653 | |||
| 17ca685a15 | |||
| a36ed1c60b | |||
| 04d28bdf40 | |||
| 2711f35552 | |||
| fcbaa63c4e | |||
| 809a1ff74c | |||
| b8f061334a | |||
| c82ba10521 | |||
| 83ee0eef9e | |||
| ddab5b2a2a | |||
| 3622e29465 | |||
| 510110228c | |||
| 8744b8266b | |||
| ab41d84a2f | |||
| 720a2a113e | |||
| fca496b4b6 | |||
| 228bec2371 | |||
| 65a1e1269f | |||
| 7b245e59c4 | |||
| 42061dded1 | |||
| 1e519370dd | |||
| 022192411e | |||
| afad32da9e | |||
| 77b3ad8385 | |||
| 7a52ed2f15 | |||
| 7af26fa6d6 | |||
| 0416586dcc | |||
| a2142eae7e | |||
| fca750b4ea | |||
| 6a1cf51938 | |||
| 5490dbcaf7 | |||
| debd4ad723 | |||
| a7ec2e6503 | |||
| 24b910916a | |||
| fcabc257a5 | |||
| d96e1442b3 | |||
| a15ce322b5 | |||
| dfefe7bfd7 | |||
| ea678c3fd1 | |||
| 456d3461a1 | |||
| 1896249485 | |||
| 3e3445811a | |||
| 810e3b7d79 | |||
| b4c0751692 | |||
| d037923265 | |||
| 3574ca6156 | |||
| 35511d0e87 | |||
| 540b401e95 | |||
| aee3303084 | |||
| e456bfedd7 | |||
| b4b51f5a5e | |||
| 6d82b0a749 | |||
| d77991744f | |||
| e6bc6951af | |||
| f70a819761 | |||
| 42f4fa4de6 | |||
| 25774f41db | |||
| cbabe5bacc | |||
| 7b030c3943 | |||
| 5900f9601e | |||
| c33fc7821a | |||
| 31f5334ae1 | |||
| 7e2c75fae7 | |||
| b9bf3f7cc9 | |||
| fea21b8e44 | |||
| 025b8c3f21 | |||
| e8a0ecddd8 | |||
| dc4856e292 | |||
| a19f58355a | |||
| e846274e59 | |||
| 9da4c47e74 | |||
| cf4eba2f5d | |||
| 858c7b122e | |||
| 2c6eb0bd74 | |||
| adcab65d7d | |||
| 1a36790014 | |||
| a9ac3e87db | |||
| d2a99ec816 | |||
| 42bdf7ecc2 | |||
| f62e92c35f | |||
| 77119a793e | |||
| c8354f0231 | |||
| c6f809ec03 | |||
| 2c66a82434 | |||
| f1def7f24e | |||
| aecb897fb8 | |||
| 10a396d17c | |||
| d9ffe54991 | |||
| c90def0992 | |||
| 4c7a021acd | |||
| 841a015d6c | |||
| 09ac1b596d | |||
| bc4ebea32c | |||
| 68b237fe53 | |||
| c823b14802 | |||
| 7a08ec735f | |||
| 53bbc94ced | |||
| 330f39ee23 | |||
| 44ec7972bd | |||
| 49ace4968f | |||
| 1903c05d53 | |||
| 5d42f3075e | |||
| 8667591004 | |||
| e0a8eb60dd | |||
| 25781e7c88 | |||
| d429fd7031 | |||
| 1f78540cbb | |||
| 843889fd03 | |||
| 873aca4c0d | |||
| 81da2bae2a | |||
| d8456c621e | |||
| cc8f9cc539 | |||
| 737fce72cc | |||
| a15f77e1c7 | |||
| 652f43d9ee | |||
| 516ca4698f | |||
| 59112bbd76 | |||
| a4ad6f7547 | |||
| 71af965514 | |||
| 1960d3c700 | |||
| 3280f45259 | |||
| 66d3783c89 | |||
| ec4124676f | |||
| 3616ae4da4 | |||
| 312f100551 | |||
| 39f26cce95 | |||
| 4e71047a2a | |||
| e5cf7bc370 | |||
| 91fca12f6a | |||
| 668347e9c1 | |||
| c1b49c419d | |||
| cd06c14265 | |||
| 410d59d53d | |||
| 77486506e3 | |||
| adaed2c79d | |||
| 4a9f946278 | |||
| 632530ef3c | |||
| ef43198018 | |||
| 4a3e7bc40d | |||
| c5b23a85b8 | |||
| 35b2eeaa65 | |||
| fc6f480e89 | |||
| 394d0ecb65 | |||
| 2e3dfd23e7 | |||
| 83809a37a7 | |||
| d61459e692 | |||
| 5543b6a85b | |||
| d25b00bd5e | |||
| 5a287c3a31 | |||
| a1c57aa022 | |||
| b097435596 | |||
| 2a0dc304c0 | |||
| b94c309fd9 | |||
| 495ffcc899 | |||
| 3901f38de6 | |||
| 58c5b7a1bf | |||
| 0d92639439 | |||
| 23a21f92be | |||
| aa329b08ce | |||
| 7d8d841659 | |||
| a5b5467dca | |||
| 18cc96d188 | |||
| 3e61d519c1 | |||
| ad0b1ac8d7 | |||
| 651dc8788f | |||
| 31d272e460 | |||
| b4338b61a2 | |||
| 5d1da96e3e | |||
| 542b6bdbc1 | |||
| 733aaa4af0 | |||
| 0b42900063 | |||
| 22ce545187 | |||
| 4a1016411b | |||
| a9f6748de9 | |||
| b4c3c87c75 | |||
| 3940ab80a3 | |||
| d7c2d66d55 | |||
| 4fc62b7983 | |||
| de15e502a7 | |||
| d51431fff5 | |||
| d4651bbb30 | |||
| e202225bd1 | |||
| 1a3515ab76 | |||
| a662d14a4e | |||
| 4dcbe2bd7a | |||
| 22d01ba674 | |||
| 4782dde73a | |||
| 151e4e156f | |||
| 1aa40de934 | |||
| 471d79edae | |||
| 1ffeff5948 | |||
| 0f6b7ad3cf | |||
| 111e0361c9 | |||
| 6c2bffe53c | |||
| 0167a5e96d | |||
| 021e1189c5 | |||
| 936c803ccb | |||
| 85d63af301 | |||
| 02893a2038 | |||
| cd86bc9d8d | |||
| 9401c59f89 | |||
| 67edd0c10e | |||
| abf6cecde1 | |||
| 67276f5d26 | |||
| 3c0aee8595 | |||
| 2233b5d25e | |||
| a55f0ebbd5 | |||
| e49a6b95ed | |||
| 4a037fa911 | |||
| 0b792c44eb | |||
| 81354cf24f | |||
| fcadbaf97c | |||
| 186ad2f6aa | |||
| 4f3ddbb299 | |||
| 9debc7248a | |||
| fb18b12efe | |||
| 251676181a | |||
| e12593a79f | |||
| 7f9a4d25ef | |||
| 4afc8facde | |||
| c73a00e073 | |||
| f2f13eb8e8 | |||
| c9f4b0aba8 | |||
| 6e284ea84b | |||
| 34961db9c1 | |||
| b64b375234 | |||
| 315cbe05cf | |||
| f54f776905 | |||
| c7a9851de0 | |||
| 1f32a8d95e | |||
| c3e8fb73c7 | |||
| 9dda741a99 | |||
| 5d45705ca1 | |||
| a7e1c144e2 | |||
| 8a79415c2e | |||
| 1d8bf5356b | |||
| d7ea1b0a08 | |||
| 65d829826e | |||
| bca1beb3f0 | |||
| 4f11ecebbc | |||
| 64adabfd3a | |||
| cbcb218418 | |||
| cec88e11ed | |||
| 34f30a878e | |||
| 908938bc3c | |||
| 518e1da637 | |||
| cccdd13937 | |||
| 6c5fc42114 | |||
| 7514850962 | |||
| fa24dd7f6d | |||
| e1fd76a11f | |||
| 9b70ddbb77 | |||
| 1090c12acd | |||
| d79e95e6e0 | |||
| a3ef2bbe33 | |||
| a571bc0d0a | |||
| 3b79b6b5da | |||
| 7e6572a34d | |||
| 93ad53c09d | |||
| 10d40d1448 | |||
| 0af1da4416 | |||
| 77e3b100eb | |||
| 073542063c | |||
| b5ac1871de | |||
| 2ad0565e3a | |||
| ad75a51f43 | |||
| 6552aef2e7 | |||
| 468c30843c | |||
| f8bf6b1f91 | |||
| 5725cb9342 | |||
| b2b47b4465 | |||
| ad2a05a391 | |||
| fee489e770 | |||
| 173c76cb04 | |||
| c30a264d21 | |||
| 31060cf42b | |||
| 8a19d03a1c | |||
| d5e9fc092c | |||
| 8ae06fde5f | |||
| 90e2bbe330 | |||
| 9aa33c344a | |||
| 7cb6b85ec9 | |||
| f11e347e2e | |||
| ba47806b8d | |||
| cfcc189a89 | |||
| 41debcfbd2 | |||
| 726c74ff39 | |||
| 6a2652c685 | |||
| c7cb56b507 | |||
| ff1132d2e4 | |||
| 6ea6de8d42 | |||
| 7e26c8ddda | |||
| f043a3da97 | |||
| f6cc9afaa9 | |||
| 55489bb41a | |||
| 43ffec0bd7 | |||
| c1c4990f75 | |||
| 72f029abc3 | |||
| c902b1fa24 | |||
| 78003e9437 | |||
| 2a6b0d68ce | |||
| da068a639f | |||
| df8b2c5f3a | |||
| a194c415a8 | |||
| 33546a0094 | |||
| 8fb47ab0c2 | |||
| 09113e163b | |||
| 85ca89ee4a | |||
| 9825d0004f | |||
| c7f33524b4 | |||
| c2ead692aa | |||
| 01a2ab9329 | |||
| a293dfea7a | |||
| 9ff108dcd0 | |||
| 0a75f2d5f8 | |||
| fbdcfc8e4a | |||
| 22e3c00b48 | |||
| 7952bed766 | |||
| ab63b48f6f | |||
| 8ab3cb0b12 | |||
| cb78c1083f | |||
| 7e1c529b00 | |||
| f538307629 | |||
| 68ecc44d34 | |||
| b244afc208 | |||
| bfaa14bfdd | |||
| 12d476427f | |||
| debda4a63f | |||
| b76f5b2ef2 | |||
| d674016d64 | |||
| 9ce137139b | |||
| 52c089fba7 | |||
| 035783039b | |||
| 2e89f963d7 | |||
| b1990352bb | |||
| aa6730f0e2 | |||
| 593ca2255c | |||
| dc5eeb8e4b | |||
| 62fea80a01 | |||
| 44791067ec | |||
| 55bb42dc63 | |||
| fc8ba15b33 | |||
| 6bbb75f219 | |||
| 4f5577446b | |||
| 7aab15f33d | |||
| b64f4bced8 | |||
| bf02206096 | |||
| e5066c9969 | |||
| 07942e3991 | |||
| 62a187b55b | |||
| 858e12a040 | |||
| bfb7757feb | |||
| de82bd5d19 | |||
| 9a205c654d | |||
| ff2fef7e91 | |||
| 83fdac780c | |||
| 7c95474f6c | |||
| 28c0673376 | |||
| 9eb66d49e4 | |||
| b45e2699b2 | |||
| e84ad136b9 | |||
| 22926742be | |||
| a3ef357b8d | |||
| 44887f5fde | |||
| 095098da0f | |||
| 58feea1a0e | |||
| 048fd80450 | |||
| 6ac7ceef9e | |||
| 07830df4d3 | |||
| d497c4babd | |||
| 2d28fd2563 | |||
| 1592f338a6 | |||
| 0ee287cd32 | |||
| 58cf509495 |
@@ -0,0 +1,17 @@
|
||||
name: Create zip file with recursive source clone for release
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
|
||||
jobs:
|
||||
release_zips:
|
||||
name: Create release zip file
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Create a recursive clone source zip
|
||||
uses: espressif/github-actions/release_zips@master
|
||||
env:
|
||||
RELEASE_PROJECT_NAME: ESP-IDF
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
+205
-138
@@ -7,6 +7,12 @@ stages:
|
||||
- deploy
|
||||
- post_check
|
||||
|
||||
default:
|
||||
retry:
|
||||
max: 2
|
||||
# In case of a runner failure we could hop to another one, or a network error could go away.
|
||||
when: runner_system_failure
|
||||
|
||||
variables:
|
||||
# System environment
|
||||
|
||||
@@ -19,10 +25,19 @@ variables:
|
||||
GET_SOURCES_ATTEMPTS: "10"
|
||||
ARTIFACT_DOWNLOAD_ATTEMPTS: "10"
|
||||
|
||||
# We use get-full-sources.sh script to fetch the submodules and/or re-fetch the repo
|
||||
# if it was corrupted (if submodule update fails this can happen)
|
||||
GIT_STRATEGY: fetch
|
||||
# GIT_STRATEGY is not defined here.
|
||||
# Use an option from "CI / CD Settings" - "General pipelines".
|
||||
|
||||
# we will download archive for each submodule instead of clone.
|
||||
# we don't do "recursive" when fetch submodule as they're not used in CI now.
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
|
||||
# by default we will fetch all submodules
|
||||
# jobs can overwrite this variable to only fetch submodules they required
|
||||
# set to "none" if don't need to fetch submodules
|
||||
SUBMODULES_TO_FETCH: "all"
|
||||
# tell build system do not check submodule update as we download archive instead of clone
|
||||
IDF_SKIP_CHECK_SUBMODULES: 1
|
||||
|
||||
UNIT_TEST_BUILD_SYSTEM: make
|
||||
# IDF environment
|
||||
@@ -33,21 +48,17 @@ variables:
|
||||
APPLY_BOT_FILTER_SCRIPT: "$CI_PROJECT_DIR/tools/ci/apply_bot_filter.py"
|
||||
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
|
||||
|
||||
# Docker images
|
||||
# Docker images
|
||||
BOT_DOCKER_IMAGE_TAG: ":latest"
|
||||
# target test repo parameters
|
||||
TEST_ENV_CONFIG_REPO: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/ci-test-runner-configs.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_URL: "https://gitlab-ci-token:${BOT_TOKEN}@${CI_SERVER_HOST}:${CI_SERVER_PORT}/qa/auto_test_script.git"
|
||||
CI_AUTO_TEST_SCRIPT_REPO_BRANCH: "ci/v3.1"
|
||||
|
||||
# Versioned esp-idf-doc env image to use for all document building jobs
|
||||
ESP_IDF_DOC_ENV_IMAGE: "$CI_DOCKER_REGISTRY/esp-idf-doc-env:v7"
|
||||
|
||||
|
||||
# When 'fetch' strategy is used, Gitlab removes untracked files before checking out
|
||||
# new revision. However if the new revision doesn't include some of the submodules
|
||||
# which were present in the old revision, such submodule directories would not be
|
||||
# removed by the checkout. This extra step ensures that these stale submodules
|
||||
# are removed.
|
||||
.git_clean_stale_submodules: &git_clean_stale_submodules >
|
||||
find . -name '.git' -not -path './.git' -printf '%P\n'
|
||||
| sed 's|/.git||'
|
||||
| xargs -I {} sh -c '
|
||||
grep -q {} .gitmodules
|
||||
|| (echo "Removing {}, has .git directory but not in .gitmodules file"
|
||||
&& rm -rf {});'
|
||||
|
||||
# before each job, we need to check if this job is filtered by bot stage/job filter
|
||||
.apply_bot_filter: &apply_bot_filter
|
||||
@@ -58,9 +69,14 @@ variables:
|
||||
tools/idf_tools.py --non-interactive install && eval "$(tools/idf_tools.py --non-interactive export)" || exit 1
|
||||
fi
|
||||
|
||||
.show_submodule_urls: &show_submodule_urls |
|
||||
git config --get-regexp '^submodule\..*\.url$' || true
|
||||
|
||||
.fetch_submodules: &fetch_submodules |
|
||||
python $SUBMODULE_FETCH_TOOL -s $SUBMODULES_TO_FETCH
|
||||
|
||||
before_script:
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
# add gitlab ssh key
|
||||
@@ -70,48 +86,33 @@ before_script:
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
- if [ "${LOCAL_GITLAB_SSH_SERVER:-}" ]; then SRV=${LOCAL_GITLAB_SSH_SERVER##*@};SRV=${SRV%%:*};printf "Host %s\n\tStrictHostKeyChecking no\n" "${SRV}" >> ~/.ssh/config; fi
|
||||
# Download and install tools, if needed
|
||||
- *setup_tools_unless_target_test
|
||||
|
||||
# Set IS_PRIVATE or IS_PUBLIC depending on if our branch is public or not
|
||||
#
|
||||
# (the same regular expressions are used to set these are used in 'only:' sections below
|
||||
# Set some options and environment for CI
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
|
||||
# fetch the submodules (& if necessary re-fetch repo) from gitlab
|
||||
- time ./tools/ci/get-full-sources.sh
|
||||
- export PYTHONPATH="${PYTHONPATH}:${CI_PROJECT_DIR}/tools/ci/python_packages"
|
||||
- *fetch_submodules
|
||||
|
||||
# used for check scripts which we want to run unconditionally
|
||||
.do_nothing_before_no_filter:
|
||||
before_script: &do_nothing_before_no_filter
|
||||
.before_script_lesser_nofilter: &before_script_lesser_nofilter
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
before_script:
|
||||
- echo "Not setting up GitLab key, not fetching submodules, not applying bot filter"
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
|
||||
# used for everything else where we want to do no prep, except for bot filter
|
||||
.do_nothing_before:
|
||||
before_script: &do_nothing_before
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
.before_script_lesser: &before_script_lesser
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
before_script:
|
||||
- echo "Not setting up GitLab key, not fetching submodules"
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
|
||||
.add_gitlab_key_before:
|
||||
before_script: &add_gitlab_key_before
|
||||
- source tools/ci/setup_python.sh
|
||||
- *git_clean_stale_submodules
|
||||
# apply bot filter in before script
|
||||
- *apply_bot_filter
|
||||
- echo "Not fetching submodules"
|
||||
- source tools/ci/configure_ci_environment.sh
|
||||
# add gitlab ssh key
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $GITLAB_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host gitlab.espressif.cn\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
|
||||
|
||||
build_template_app:
|
||||
stage: build
|
||||
@@ -291,25 +292,18 @@ build_examples_cmake:
|
||||
- mkdir -p ${LOG_PATH}
|
||||
- ${IDF_PATH}/tools/ci/build_examples_cmake.sh
|
||||
|
||||
build_docs:
|
||||
|
||||
.build_docs_template: &build_docs_template
|
||||
stage: build
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
image: $ESP_IDF_DOC_ENV_IMAGE
|
||||
tags:
|
||||
- build_docs
|
||||
artifacts:
|
||||
when: always
|
||||
paths:
|
||||
# English version of documentation
|
||||
- docs/en/doxygen-warning-log.txt
|
||||
- docs/en/sphinx-warning-log.txt
|
||||
- docs/en/sphinx-warning-log-sanitized.txt
|
||||
- docs/en/_build/html
|
||||
- docs/sphinx-err-*
|
||||
# Chinese version of documentation
|
||||
- docs/zh_CN/doxygen-warning-log.txt
|
||||
- docs/zh_CN/sphinx-warning-log.txt
|
||||
- docs/zh_CN/sphinx-warning-log-sanitized.txt
|
||||
- docs/zh_CN/_build/html
|
||||
- docs/*/*.txt
|
||||
- docs/_build/*/html/*
|
||||
- docs/_build/*/latex/*
|
||||
expire_in: 4 days
|
||||
only:
|
||||
variables:
|
||||
@@ -317,17 +311,32 @@ build_docs:
|
||||
- $BOT_LABEL_BUILD
|
||||
- $BOT_LABEL_BUILD_DOCS
|
||||
- $BOT_LABEL_REGULAR_TEST
|
||||
dependencies: []
|
||||
script:
|
||||
# Active python 3.6.10 env as this is where Sphinx is installed
|
||||
- source /opt/pyenv/activate && pyenv global 3.6.10
|
||||
# Setup a build dir with both languages to simplify deployment
|
||||
- cd docs
|
||||
- mkdir -p _build/$DOCLANG
|
||||
- ./check_lang_folder_sync.sh
|
||||
- cd en
|
||||
- cd $DOCLANG
|
||||
- make gh-linkcheck
|
||||
- make html
|
||||
- ../check_doc_warnings.sh
|
||||
- cd ../zh_CN
|
||||
- make gh-linkcheck
|
||||
- make html
|
||||
- make latexpdf LATEXMKOPTS="--f --interaction=nonstopmode --quiet --outdir=build"
|
||||
- ../check_doc_warnings.sh
|
||||
- mv -f _build/* ../_build/$DOCLANG
|
||||
|
||||
build_docs_en:
|
||||
extends: .build_docs_template
|
||||
variables:
|
||||
DOCLANG: "en"
|
||||
|
||||
build_docs_zh_CN:
|
||||
extends: .build_docs_template
|
||||
variables:
|
||||
DOCLANG: "zh_CN"
|
||||
|
||||
|
||||
.check_job_template: &check_job_template
|
||||
stage: check
|
||||
@@ -335,7 +344,7 @@ build_docs:
|
||||
tags:
|
||||
- host_test
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before_no_filter
|
||||
<<: *before_script_lesser_nofilter
|
||||
|
||||
verify_cmake_style:
|
||||
<<: *check_job_template
|
||||
@@ -363,7 +372,12 @@ build_docker:
|
||||
DOCKER_TMP_IMAGE_NAME: "idf_tmp_image"
|
||||
before_script: []
|
||||
script:
|
||||
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||
- export LOCAL_CI_REPOSITORY_URL=$CI_REPOSITORY_URL
|
||||
- if [ -n "$LOCAL_GITLAB_HTTPS_HOST" ]; then export LOCAL_CI_REPOSITORY_URL="https://gitlab-ci-token:${CI_JOB_TOKEN}@${LOCAL_GITLAB_HTTPS_HOST}/${CI_PROJECT_PATH}"; fi
|
||||
- if [ -n "$LOCAL_GIT_MIRROR" ]; then export LOCAL_CI_REPOSITORY_URL="${LOCAL_GIT_MIRROR}/${CI_PROJECT_PATH}"; fi
|
||||
- echo "Using repository at $LOCAL_CI_REPOSITORY_URL"
|
||||
- export DOCKER_BUILD_ARGS="--build-arg IDF_CLONE_URL=${LOCAL_CI_REPOSITORY_URL} --build-arg IDF_CLONE_BRANCH_OR_TAG=${CI_COMMIT_REF_NAME} --build-arg IDF_CHECKOUT_REF=${CI_COMMIT_TAG:-$CI_COMMIT_SHA}"
|
||||
|
||||
# Build
|
||||
- docker build --tag ${DOCKER_TMP_IMAGE_NAME} ${DOCKER_BUILD_ARGS} tools/docker/
|
||||
# We can't mount $PWD/examples/get-started/blink into the container, see https://gitlab.com/gitlab-org/gitlab-ce/issues/41227.
|
||||
@@ -605,7 +619,7 @@ push_to_github:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
when: on_success
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
<<: *before_script_lesser
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
@@ -617,45 +631,67 @@ push_to_github:
|
||||
- git remote add github git@github.com:espressif/esp-idf.git
|
||||
- tools/ci/push_to_github.sh
|
||||
|
||||
deploy_docs:
|
||||
.deploy_docs_template:
|
||||
extends: .before_script_lesser
|
||||
stage: deploy
|
||||
image: $CI_DOCKER_REGISTRY/esp32-ci-env$BOT_DOCKER_IMAGE_TAG
|
||||
image: $ESP_IDF_DOC_ENV_IMAGE
|
||||
tags:
|
||||
- deploy
|
||||
- shiny
|
||||
dependencies:
|
||||
- build_docs_en
|
||||
- build_docs_zh_CN
|
||||
variables:
|
||||
DOCS_BUILD_DIR: "${IDF_PATH}/docs/_build/"
|
||||
PYTHONUNBUFFERED: 1
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $DOCS_DEPLOY_PRIVATEKEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host $DOCS_DEPLOY_SERVER\n\tStrictHostKeyChecking no\n\tUser $DOCS_DEPLOY_SERVER_USER\n" >> ~/.ssh/config
|
||||
- export GIT_VER=$(git describe --always)
|
||||
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.6.10 ${IDF_PATH}/tools/ci/deploy_docs.py
|
||||
|
||||
|
||||
# deploys docs to CI_DOCKER_REGISTRY webserver, for internal review
|
||||
deploy_docs_preview:
|
||||
extends: .deploy_docs_template
|
||||
only:
|
||||
refs:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
- triggers
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
- $BOT_LABEL_BUILD_DOCS
|
||||
dependencies:
|
||||
- build_docs
|
||||
before_script: *do_nothing_before
|
||||
script:
|
||||
- mkdir -p ~/.ssh
|
||||
- chmod 700 ~/.ssh
|
||||
- echo -n $DOCS_DEPLOY_KEY > ~/.ssh/id_rsa_base64
|
||||
- base64 --decode --ignore-garbage ~/.ssh/id_rsa_base64 > ~/.ssh/id_rsa
|
||||
- chmod 600 ~/.ssh/id_rsa
|
||||
- echo -e "Host $DOCS_SERVER\n\tStrictHostKeyChecking no\n\tUser $DOCS_SERVER_USER\n" >> ~/.ssh/config
|
||||
- export GIT_VER=$(git describe --always)
|
||||
- cd docs/en/_build/
|
||||
- mv html $GIT_VER
|
||||
- tar czvf $GIT_VER.tar.gz $GIT_VER
|
||||
- scp $GIT_VER.tar.gz $DOCS_SERVER:$DOCS_PATH/en
|
||||
- ssh $DOCS_SERVER -x "cd $DOCS_PATH/en && tar xzvf $GIT_VER.tar.gz && rm -f latest && ln -s $GIT_VER latest"
|
||||
- cd ../../zh_CN/_build/
|
||||
- mv html $GIT_VER
|
||||
- tar czvf $GIT_VER.tar.gz $GIT_VER
|
||||
- scp $GIT_VER.tar.gz $DOCS_SERVER:$DOCS_PATH/zh_CN
|
||||
- ssh $DOCS_SERVER -x "cd $DOCS_PATH/zh_CN && tar xzvf $GIT_VER.tar.gz && rm -f latest && ln -s $GIT_VER latest"
|
||||
# add link to preview doc
|
||||
- echo "[document preview][en] $CI_DOCKER_REGISTRY/docs/esp-idf/en/${GIT_VER}/index.html"
|
||||
- echo "[document preview][zh_CN] $CI_DOCKER_REGISTRY/docs/esp-idf/zh_CN/${GIT_VER}/index.html"
|
||||
variables:
|
||||
TYPE: "preview"
|
||||
# older branches use DOCS_DEPLOY_KEY, DOCS_SERVER, DOCS_SERVER_USER, DOCS_PATH for preview server so we keep these names for 'preview'
|
||||
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_DEPLOY_KEY"
|
||||
DOCS_DEPLOY_SERVER: "$DOCS_SERVER"
|
||||
DOCS_DEPLOY_SERVER_USER: "$DOCS_SERVER_USER"
|
||||
DOCS_DEPLOY_PATH: "$DOCS_PATH"
|
||||
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PREVIEW_SERVER_URL/docs/esp-idf"
|
||||
|
||||
# deploy docs to production webserver
|
||||
deploy_docs_production:
|
||||
extends: .deploy_docs_template
|
||||
only:
|
||||
refs:
|
||||
# The DOCS_PROD_* variables used by this job are "Protected" so these branches must all be marked "Protected" in Gitlab settings
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
variables:
|
||||
TYPE: "preview"
|
||||
DOCS_DEPLOY_PRIVATEKEY: "$DOCS_PROD_DEPLOY_KEY"
|
||||
DOCS_DEPLOY_SERVER: "$DOCS_PROD_SERVER"
|
||||
DOCS_DEPLOY_SERVER_USER: "$DOCS_PROD_SERVER_USER"
|
||||
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
|
||||
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esp-idf"
|
||||
|
||||
check_doc_links:
|
||||
stage: host_test
|
||||
@@ -717,7 +753,7 @@ check_examples_cmake_make:
|
||||
- master
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
before_script: *do_nothing_before
|
||||
<<: *before_script_lesser
|
||||
script:
|
||||
- tools/ci/check_examples_cmake_make.sh
|
||||
|
||||
@@ -728,14 +764,13 @@ check_python_style:
|
||||
paths:
|
||||
- flake8_output.txt
|
||||
expire_in: 1 week
|
||||
before_script: *do_nothing_before
|
||||
<<: *before_script_lesser
|
||||
script:
|
||||
# run it only under Python 3 (it is very slow under Python 2)
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh -p 3.4.8 python -m flake8 --config=$IDF_PATH/.flake8 --output-file=flake8_output.txt --tee --benchmark $IDF_PATH
|
||||
|
||||
check_kconfigs:
|
||||
<<: *check_job_template
|
||||
before_script: *do_nothing_before
|
||||
artifacts:
|
||||
when: on_failure
|
||||
paths:
|
||||
@@ -746,6 +781,7 @@ check_kconfigs:
|
||||
- tools/*/*/Kconfig*.new
|
||||
- tools/*/*/*/Kconfig*.new
|
||||
expire_in: 1 week
|
||||
<<: *before_script_lesser
|
||||
script:
|
||||
- ${IDF_PATH}/tools/ci/multirun_with_pyenv.sh ${IDF_PATH}/tools/test_check_kconfigs.py
|
||||
- ${IDF_PATH}/tools/check_kconfigs.py
|
||||
@@ -760,7 +796,7 @@ check_ut_cmake_make:
|
||||
- /^release\/v/
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
dependencies: []
|
||||
before_script: *do_nothing_before
|
||||
<<: *before_script_lesser
|
||||
script:
|
||||
- tools/ci/check_ut_cmake_make.sh
|
||||
|
||||
@@ -768,12 +804,22 @@ check_submodule_sync:
|
||||
<<: *check_job_template
|
||||
tags:
|
||||
- github_sync
|
||||
retry: 2
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
retry: 2
|
||||
GIT_SUBMODULE_STRATEGY: none
|
||||
PUBLIC_IDF_URL: "https://github.com/espressif/esp-idf.git"
|
||||
before_script: []
|
||||
after_script: []
|
||||
script:
|
||||
- git submodule deinit --force .
|
||||
# setting the default remote URL to the public one, to resolve relative location URLs
|
||||
- git config remote.origin.url ${PUBLIC_IDF_URL}
|
||||
# check if all submodules are correctly synced to public repostory
|
||||
- git submodule update --init --recursive
|
||||
- git submodule init
|
||||
- *show_submodule_urls
|
||||
- git submodule update --recursive
|
||||
- echo "IDF was cloned from ${PUBLIC_IDF_URL} completely"
|
||||
|
||||
check_artifacts_expire_time:
|
||||
<<: *check_job_template
|
||||
@@ -792,6 +838,18 @@ check_pipeline_triggered_by_label:
|
||||
# We want to make sure some jobs are always executed to detect regression.
|
||||
- test "$BOT_LABEL_REGULAR_TEST" = "true" || exit -1
|
||||
|
||||
# For release tag pipelines only, make sure the tag was created with 'git tag -a' so it will update
|
||||
# the version returned by 'git describe'
|
||||
check_version_tag:
|
||||
extends: .check_job_template
|
||||
only:
|
||||
refs:
|
||||
- /^v\d+\.\d+(\.\d+)?($|-)/
|
||||
variables:
|
||||
- $BOT_TRIGGER_WITH_LABEL == null
|
||||
script:
|
||||
- (git cat-file -t $CI_COMMIT_REF_NAME | grep tag) || (echo "ESP-IDF versions must be annotated tags." && exit 1)
|
||||
|
||||
assign_test:
|
||||
tags:
|
||||
- assign_test
|
||||
@@ -806,6 +864,11 @@ assign_test:
|
||||
variables:
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
EXAMPLE_CONFIG_OUTPUT_PATH: "$CI_PROJECT_DIR/examples/test_configs"
|
||||
INTEGRATION_CONFIG_OUTPUT_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
ASSIGN_TEST_CASE_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIAssignTestCases.py"
|
||||
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
|
||||
PYTHON_VER: 3.7.7
|
||||
artifacts:
|
||||
paths:
|
||||
- components/idf_test/*/CIConfigs
|
||||
@@ -824,11 +887,11 @@ assign_test:
|
||||
# assign unit test cases
|
||||
- python $TEST_FW_PATH/CIAssignUnitTest.py $IDF_PATH/components/idf_test/unit_test/TestCaseAll.yml $IDF_PATH/.gitlab-ci.yml $IDF_PATH/components/idf_test/unit_test/CIConfigs
|
||||
# clone test script to assign tests
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
# assgin integration test cases
|
||||
- python CIAssignTestCases.py -t $IDF_PATH/components/idf_test/integration_test -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin
|
||||
- python ${ASSIGN_TEST_CASE_SCRIPT} -t $TEST_CASE_FILE_PATH -c $IDF_PATH/.gitlab-ci.yml -b $IDF_PATH/SSC/ssc_bin -o $INTEGRATION_CONFIG_OUTPUT_PATH
|
||||
|
||||
.define_config_file_name: &define_config_file_name |
|
||||
JOB_NAME_PREFIX=$(echo ${CI_JOB_NAME} | awk '{print $1}')
|
||||
@@ -860,21 +923,25 @@ assign_test:
|
||||
reports:
|
||||
junit: $LOG_PATH/*/XUNIT_RESULT.xml
|
||||
variables:
|
||||
SUBMODULES_TO_FETCH: "components/esptool_py/esptool"
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
|
||||
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/examples/test_configs"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/TEST_LOGS"
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
PYTHON_VER: 3
|
||||
script:
|
||||
- *define_config_file_name
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd $TEST_FW_PATH
|
||||
# git clone the known failure cases repo, run test
|
||||
- ./tools/ci/retry_failed.sh git clone $KNOWN_FAILURE_CASES_REPO known_failure_cases
|
||||
# run test
|
||||
- python Runner.py $TEST_CASE_PATH -c $CONFIG_FILE -e $ENV_FILE
|
||||
- cd $TEST_FW_PATH
|
||||
- python Runner.py $TEST_CASE_PATH -c $CONFIG_FILE -e $ENV_FILE --known_failure_cases_file $CI_PROJECT_DIR/known_failure_cases/known_failure_cases.txt
|
||||
|
||||
.unit_test_template: &unit_test_template
|
||||
<<: *example_test_template
|
||||
@@ -922,26 +989,30 @@ assign_test:
|
||||
- $LOG_PATH
|
||||
expire_in: 1 week
|
||||
variables:
|
||||
SUBMODULES_TO_FETCH: "none"
|
||||
LOCAL_ENV_CONFIG_PATH: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/ESP32_IDF"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/$CI_COMMIT_SHA"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/components/idf_test/integration_test"
|
||||
LOG_PATH: "${CI_PROJECT_DIR}/TEST_LOGS"
|
||||
TEST_CASE_FILE_PATH: "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
MODULE_UPDATE_FILE: "$CI_PROJECT_DIR/components/idf_test/ModuleDefinition.yml"
|
||||
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/components/idf_test/integration_test/CIConfigs"
|
||||
before_script: *add_gitlab_key_before
|
||||
KNOWN_ISSUE_FILE: "${CI_PROJECT_DIR}/components/idf_test/integration_test/KnownIssues"
|
||||
PYTHONPATH: "${CI_PROJECT_DIR}/auto_test_script/packages"
|
||||
CI_RUNNER_SCRIPT: "${CI_PROJECT_DIR}/auto_test_script/bin/CIRunner.py"
|
||||
PYTHON_VER: 3.7.7
|
||||
script:
|
||||
- *define_config_file_name
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- cat ${KNOWN_ISSUE_FILE} >> ${TEST_CASE_FILE_PATH}/KnownIssues
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
nvs_compatible_test:
|
||||
<<: *test_template
|
||||
@@ -959,17 +1030,17 @@ nvs_compatible_test:
|
||||
# first test if config file exists, if not exist, exit 0
|
||||
- test -e $CONFIG_FILE || exit 0
|
||||
# clone local test env configs
|
||||
- git clone $TEST_ENV_CONFIG_REPOSITORY
|
||||
- ./tools/ci/retry_failed.sh git clone $TEST_ENV_CONFIG_REPO
|
||||
- python $CHECKOUT_REF_SCRIPT ci-test-runner-configs ci-test-runner-configs
|
||||
- cd ci-test-runner-configs
|
||||
# clone test bench
|
||||
- git clone $TEST_SCRIPT_REPOSITORY
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script auto_test_script
|
||||
- cd auto_test_script
|
||||
- ./tools/ci/retry_failed.sh git clone ${CI_AUTO_TEST_SCRIPT_REPO_URL} -b empty_branch
|
||||
- ./tools/ci/retry_failed.sh git -C auto_test_script checkout -f ${CI_AUTO_TEST_SCRIPT_REPO_BRANCH}
|
||||
- python $CHECKOUT_REF_SCRIPT auto_test_script "$CI_PROJECT_DIR/auto_test_script/TestCaseFiles"
|
||||
# prepare nvs bins
|
||||
- ./Tools/prepare_nvs_bin.sh
|
||||
- cd auto_test_script
|
||||
- ./tools/prepare_nvs_bin.sh
|
||||
# run test
|
||||
- python CIRunner.py -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
- python ${CI_RUNNER_SCRIPT} -l "$LOG_PATH/$JOG_FULL_NAME" -c $CONFIG_FILE -e $LOCAL_ENV_CONFIG_PATH -t $TEST_CASE_FILE_PATH
|
||||
|
||||
example_test_001:
|
||||
<<: *example_test_template
|
||||
@@ -984,6 +1055,14 @@ example_test_002:
|
||||
tags:
|
||||
- ESP32
|
||||
- Example_ShieldBox_Basic
|
||||
variables:
|
||||
SUBMODULES_TO_FETCH: "all"
|
||||
TEST_FW_PATH: "$CI_PROJECT_DIR/tools/tiny-test-fw"
|
||||
TEST_CASE_PATH: "$CI_PROJECT_DIR/examples"
|
||||
CONFIG_FILE_PATH: "${CI_PROJECT_DIR}/examples/test_configs"
|
||||
LOG_PATH: "$CI_PROJECT_DIR/TEST_LOGS"
|
||||
ENV_FILE: "$CI_PROJECT_DIR/ci-test-runner-configs/$CI_RUNNER_DESCRIPTION/EnvConfig.yml"
|
||||
PYTHON_VER: 3
|
||||
|
||||
.example_test_003:
|
||||
<<: *example_test_template
|
||||
@@ -1234,12 +1313,7 @@ UT_029:
|
||||
|
||||
UT_030:
|
||||
<<: *unit_test_template
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
|
||||
UT_031:
|
||||
<<: *unit_test_template
|
||||
parallel: 3
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- UT_T1_1
|
||||
@@ -1324,7 +1398,7 @@ IT_002:
|
||||
|
||||
IT_003:
|
||||
<<: *test_template
|
||||
parallel: 13
|
||||
parallel: 14
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T2_5
|
||||
@@ -1344,7 +1418,7 @@ IT_005:
|
||||
|
||||
IT_006:
|
||||
<<: *test_template
|
||||
parallel: 8
|
||||
parallel: 13
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_6
|
||||
@@ -1368,13 +1442,6 @@ IT_009:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_3
|
||||
|
||||
IT_010:
|
||||
<<: *test_template
|
||||
parallel: 4
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T5_1
|
||||
|
||||
IT_011:
|
||||
<<: *test_template
|
||||
tags:
|
||||
@@ -1414,6 +1481,7 @@ IT_015:
|
||||
|
||||
IT_016:
|
||||
<<: *test_template
|
||||
allow_failure: true
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T50_MESH1
|
||||
@@ -1426,7 +1494,6 @@ IT_017:
|
||||
|
||||
IT_018:
|
||||
<<: *test_template
|
||||
parallel: 2
|
||||
tags:
|
||||
- ESP32_IDF
|
||||
- SSC_T1_9
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
# For the syntax of this file, see:
|
||||
#
|
||||
# https://docs.gitlab.com/ee/user/project/code_owners.html#the-syntax-of-code-owners-files
|
||||
#
|
||||
|
||||
* @esp-idf-codeowners/all-maintainers
|
||||
+24
-19
@@ -1,75 +1,80 @@
|
||||
#
|
||||
# All the relative URL paths are intended to be GitHub ones
|
||||
# For Espressif's public projects please use '../../espressif/proj', not a '../proj'
|
||||
#
|
||||
|
||||
[submodule "components/esp32/lib"]
|
||||
path = components/esp32/lib
|
||||
url = https://github.com/espressif/esp32-wifi-lib.git
|
||||
url = ../../espressif/esp32-wifi-lib.git
|
||||
|
||||
[submodule "components/esptool_py/esptool"]
|
||||
path = components/esptool_py/esptool
|
||||
url = https://github.com/espressif/esptool.git
|
||||
url = ../../espressif/esptool.git
|
||||
|
||||
[submodule "components/bt/lib"]
|
||||
path = components/bt/lib
|
||||
url = https://github.com/espressif/esp32-bt-lib.git
|
||||
url = ../../espressif/esp32-bt-lib.git
|
||||
|
||||
[submodule "components/micro-ecc/micro-ecc"]
|
||||
path = components/micro-ecc/micro-ecc
|
||||
url = https://github.com/kmackay/micro-ecc.git
|
||||
url = ../../kmackay/micro-ecc.git
|
||||
|
||||
[submodule "components/coap/libcoap"]
|
||||
path = components/coap/libcoap
|
||||
url = https://github.com/obgm/libcoap.git
|
||||
url = ../../obgm/libcoap.git
|
||||
|
||||
[submodule "components/aws_iot/aws-iot-device-sdk-embedded-C"]
|
||||
path = components/aws_iot/aws-iot-device-sdk-embedded-C
|
||||
url = https://github.com/espressif/aws-iot-device-sdk-embedded-C.git
|
||||
url = ../../espressif/aws-iot-device-sdk-embedded-C.git
|
||||
|
||||
[submodule "components/nghttp/nghttp2"]
|
||||
path = components/nghttp/nghttp2
|
||||
url = https://github.com/nghttp2/nghttp2.git
|
||||
url = ../../nghttp2/nghttp2.git
|
||||
|
||||
[submodule "components/libsodium/libsodium"]
|
||||
path = components/libsodium/libsodium
|
||||
url = https://github.com/jedisct1/libsodium.git
|
||||
url = ../../jedisct1/libsodium.git
|
||||
|
||||
[submodule "components/spiffs/spiffs"]
|
||||
path = components/spiffs/spiffs
|
||||
url = https://github.com/pellepl/spiffs.git
|
||||
url = ../../pellepl/spiffs.git
|
||||
|
||||
[submodule "components/json/cJSON"]
|
||||
path = components/json/cJSON
|
||||
url = https://github.com/DaveGamble/cJSON.git
|
||||
url = ../../DaveGamble/cJSON.git
|
||||
|
||||
[submodule "components/mbedtls/mbedtls"]
|
||||
path = components/mbedtls/mbedtls
|
||||
url = https://github.com/espressif/mbedtls.git
|
||||
url = ../../espressif/mbedtls.git
|
||||
|
||||
[submodule "components/asio/asio"]
|
||||
path = components/asio/asio
|
||||
url = https://github.com/espressif/asio.git
|
||||
url = ../../espressif/asio.git
|
||||
|
||||
[submodule "components/expat/expat"]
|
||||
path = components/expat/expat
|
||||
url = https://github.com/libexpat/libexpat.git
|
||||
url = ../../libexpat/libexpat.git
|
||||
|
||||
[submodule "components/lwip/lwip"]
|
||||
path = components/lwip/lwip
|
||||
url = https://github.com/espressif/esp-lwip.git
|
||||
url = ../../espressif/esp-lwip.git
|
||||
|
||||
[submodule "components/mqtt/esp-mqtt"]
|
||||
path = components/mqtt/esp-mqtt
|
||||
url = https://github.com/espressif/esp-mqtt.git
|
||||
url = ../../espressif/esp-mqtt.git
|
||||
|
||||
[submodule "components/protobuf-c/protobuf-c"]
|
||||
path = components/protobuf-c/protobuf-c
|
||||
url = https://github.com/protobuf-c/protobuf-c
|
||||
url = ../../protobuf-c/protobuf-c.git
|
||||
|
||||
[submodule "components/unity/unity"]
|
||||
path = components/unity/unity
|
||||
url = https://github.com/ThrowTheSwitch/Unity
|
||||
url = ../../ThrowTheSwitch/Unity.git
|
||||
|
||||
[submodule "examples/build_system/cmake/import_lib/main/lib/tinyxml2"]
|
||||
path = examples/build_system/cmake/import_lib/main/lib/tinyxml2
|
||||
url = https://github.com/leethomason/tinyxml2
|
||||
url = ../../leethomason/tinyxml2.git
|
||||
|
||||
[submodule "components/nimble/nimble"]
|
||||
path = components/nimble/nimble
|
||||
url = https://github.com/espressif/esp-nimble.git
|
||||
url = ../../espressif/esp-nimble.git
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
# Espressif IoT Development Framework
|
||||
|
||||
[](https://docs.espressif.com/projects/esp-idf/en/latest/?badge=latest)
|
||||
|
||||
ESP-IDF is the official development framework for the [ESP32](https://espressif.com/en/products/hardware/esp32/overview) chip.
|
||||
|
||||
# Developing With ESP-IDF
|
||||
@@ -13,6 +11,14 @@ See setup guides for detailed instructions to set up the ESP-IDF:
|
||||
* [Getting Started Guide for the stable ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/stable/get-started/)
|
||||
* [Getting Started Guide for the latest (master branch) ESP-IDF version](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/)
|
||||
|
||||
### Non-GitHub forks
|
||||
|
||||
ESP-IDF uses relative locations as its submodules URLs ([.gitmodules](.gitmodules)). So they link to GitHub.
|
||||
If ESP-IDF is forked to a Git repository which is not on GitHub, you will need to run the script
|
||||
[tools/set-submodules-to-github.sh](tools/set-submodules-to-github.sh) after git clone.
|
||||
The script sets absolute URLs for all submodules, allowing `git submodule update --init --recursive` to complete.
|
||||
If cloning ESP-IDF from GitHub, this step is not needed.
|
||||
|
||||
## Finding a Project
|
||||
|
||||
As well as the [esp-idf-template](https://github.com/espressif/esp-idf-template) project mentioned in Getting Started, ESP-IDF comes with some example projects in the [examples](examples) directory.
|
||||
|
||||
@@ -276,6 +276,10 @@ def erase_ota_partition(args):
|
||||
|
||||
|
||||
def main():
|
||||
if sys.version_info[0] < 3:
|
||||
print("WARNING: Support for Python 2 is deprecated and will be removed in future versions.")
|
||||
elif sys.version_info[0] == 3 and sys.version_info[1] < 6:
|
||||
print("WARNING: Python 3 versions older than 3.6 are not supported.")
|
||||
global quiet
|
||||
|
||||
parser = argparse.ArgumentParser("ESP-IDF OTA Partitions Tool")
|
||||
|
||||
@@ -28,20 +28,34 @@ menu "Bootloader config"
|
||||
default 4 if LOG_BOOTLOADER_LEVEL_DEBUG
|
||||
default 5 if LOG_BOOTLOADER_LEVEL_VERBOSE
|
||||
|
||||
config BOOTLOADER_SPI_CUSTOM_WP_PIN
|
||||
bool "Use custom SPI Flash WP Pin when flash pins set in eFuse (read help)"
|
||||
depends on FLASHMODE_QIO || FLASHMODE_QOUT
|
||||
default y if BOOTLOADER_SPI_WP_PIN != 7 # backwards compatibility, can remove in IDF 5
|
||||
default n
|
||||
help
|
||||
This setting is only used if the SPI flash pins have been overridden by setting the eFuses
|
||||
SPI_PAD_CONFIG_xxx, and the SPI flash mode is QIO or QOUT.
|
||||
|
||||
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka
|
||||
ESP32 pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. The same pin is also used
|
||||
for external SPIRAM if it is enabled.
|
||||
|
||||
If this config item is set to N (default), the correct WP pin will be automatically used for any
|
||||
Espressif chip or module with integrated flash. If a custom setting is needed, set this config item to
|
||||
Y and specify the GPIO number connected to the WP.
|
||||
|
||||
config BOOTLOADER_SPI_WP_PIN
|
||||
int "SPI Flash WP Pin when customising pins via eFuse (read help)"
|
||||
int "Custom SPI Flash WP Pin"
|
||||
range 0 33
|
||||
default 7
|
||||
depends on FLASHMODE_QIO || FLASHMODE_QOUT
|
||||
#depends on BOOTLOADER_SPI_CUSTOM_WP_PIN # backwards compatibility, can uncomment in IDF 5
|
||||
help
|
||||
This value is ignored unless flash mode is set to QIO or QOUT *and* the SPI flash pins have been
|
||||
overriden by setting the eFuses SPI_PAD_CONFIG_xxx.
|
||||
The option "Use custom SPI Flash WP Pin" must be set or this value is ignored
|
||||
|
||||
When this is the case, the eFuse config only defines 3 of the 4 Quad I/O data pins. The WP pin (aka ESP32
|
||||
pin "SD_DATA_3" or SPI flash pin "IO2") is not specified in eFuse. That pin number is compiled into the
|
||||
bootloader instead.
|
||||
|
||||
The default value (GPIO 7) is correct for WP pin on ESP32-D2WD integrated flash.
|
||||
If burning a customized set of SPI flash pins in eFuse and using QIO or QOUT mode for flash, set this
|
||||
value to the GPIO number of the SPI flash WP pin.
|
||||
|
||||
choice BOOTLOADER_VDDSDIO_BOOST
|
||||
bool "VDDSDIO LDO voltage"
|
||||
@@ -219,6 +233,16 @@ menu "Bootloader config"
|
||||
It allow to test anti-rollback implemention without permanent write eFuse bits.
|
||||
In partition table should be exist this partition `emul_efuse, data, 5, , 0x2000`.
|
||||
|
||||
config BOOTLOADER_FLASH_XMC_SUPPORT_ENA
|
||||
bool "Enable the support for flash chips of XMC (READ HELP FIRST)"
|
||||
default n
|
||||
help
|
||||
Perform the startup flow recommended by XMC. Please consult XMC for the details of this flow.
|
||||
XMC chips will be forbidden to be used, when this option is disabled.
|
||||
|
||||
Due to the limitation of Flash size, this flow is disabled by default on IDF v3.3. You may need to disable
|
||||
some bootloader features to enable it.
|
||||
|
||||
endmenu # Bootloader
|
||||
|
||||
|
||||
@@ -403,6 +427,7 @@ menu "Security features"
|
||||
config FLASH_ENCRYPTION_ENABLED
|
||||
bool "Enable flash encryption on boot (READ DOCS FIRST)"
|
||||
default N
|
||||
select PARTITION_TABLE_MD5 if !ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS
|
||||
help
|
||||
If this option is set, flash contents will be encrypted by the bootloader on first boot.
|
||||
|
||||
@@ -524,4 +549,21 @@ menu "Security features"
|
||||
Reflashable mode so that a new Secure Boot digest can be flashed at the same time as plaintext firmware.
|
||||
This combination is not secure and should not be used for a production system.
|
||||
|
||||
config SECURE_DISABLE_ROM_DL_MODE
|
||||
bool "Permanently disable ROM Download Mode"
|
||||
depends on ESP32_REV_MIN_3
|
||||
default n
|
||||
help
|
||||
If set, during startup the app will burn an eFuse bit to permanently disable the UART ROM
|
||||
Download Mode. This prevents any future use of esptool.py, espefuse.py and similar tools.
|
||||
|
||||
Once disabled, if the SoC is booted with strapping pins set for ROM Download Mode
|
||||
then an error is printed instead.
|
||||
|
||||
It is recommended to enable this option in any production application where Flash
|
||||
Encryption and/or Secure Boot is enabled and access to Download Mode is not required.
|
||||
|
||||
It is also possible to permanently disable Download Mode by calling
|
||||
esp_efuse_disable_rom_download_mode() at runtime.
|
||||
|
||||
endmenu # Security features
|
||||
|
||||
@@ -75,6 +75,7 @@ SECTIONS
|
||||
.dram0.bss (NOLOAD) :
|
||||
{
|
||||
. = ALIGN (8);
|
||||
_dram_start = ABSOLUTE(.);
|
||||
_bss_start = ABSOLUTE(.);
|
||||
*(.dynsbss)
|
||||
*(.sbss)
|
||||
@@ -151,7 +152,7 @@ SECTIONS
|
||||
*(.gnu.linkonce.lit4.*)
|
||||
_lit4_end = ABSOLUTE(.);
|
||||
. = ALIGN(4);
|
||||
_heap_start = ABSOLUTE(.);
|
||||
_dram_end = ABSOLUTE(.);
|
||||
} >dram_seg
|
||||
|
||||
.iram.text :
|
||||
@@ -163,6 +164,14 @@ SECTIONS
|
||||
*(.fini.literal)
|
||||
*(.fini)
|
||||
*(.gnu.version)
|
||||
|
||||
/** CPU will try to prefetch up to 16 bytes of
|
||||
* of instructions. This means that any configuration (e.g. MMU, PMS) must allow
|
||||
* safe access to up to 16 bytes after the last real instruction, add
|
||||
* dummy bytes to ensure this
|
||||
*/
|
||||
. += 16;
|
||||
|
||||
_text_end = ABSOLUTE(.);
|
||||
_etext = .;
|
||||
} > iram_seg
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_image_format.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -66,6 +67,20 @@ void bootloader_flash_gpio_config(const esp_image_header_t* pfhdr);
|
||||
*/
|
||||
void bootloader_flash_dummy_config(const esp_image_header_t* pfhdr);
|
||||
|
||||
/**
|
||||
* @brief Return the pin number used for custom SPI flash and/or SPIRAM WP pin
|
||||
*
|
||||
* Can be determined by eFuse values in most cases, or overriden in configuration
|
||||
*
|
||||
* This value is only meaningful if the other SPI flash pins are overriden via eFuse.
|
||||
*
|
||||
* This value is only meaningful if flash is set to QIO or QOUT mode, or if
|
||||
* SPIRAM is enabled.
|
||||
*
|
||||
* @return Pin number to use, or -1 if the default should be kept
|
||||
*/
|
||||
int bootloader_flash_get_wp_pin(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -110,7 +110,11 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length);
|
||||
* is enabled but secure boot is not used. This should protect against
|
||||
* serial re-flashing of an unauthorised code in absence of secure boot.
|
||||
*
|
||||
* @return
|
||||
* @note To support disabling UART Download Mode on ESP32 V3 only, this function
|
||||
* doesn't write protect FLASH_CRYPT_CNT but instead sets it to the max value
|
||||
* (effectively the same result but allows burning the UART_DL_DIS efuse later on,
|
||||
* as this is otherwise also disabled if FLASH_CRYPT_CNT is write protected.)
|
||||
*
|
||||
*/
|
||||
void esp_flash_write_protect_crypt_cnt();
|
||||
|
||||
|
||||
@@ -123,6 +123,19 @@ typedef struct {
|
||||
|
||||
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest);
|
||||
|
||||
/** @brief Verify the ECDSA secure boot signature block for Secure Boot.
|
||||
*
|
||||
* Calculates Deterministic ECDSA w/ SHA256 based on the SHA256 hash of the image. ECDSA signature
|
||||
* verification must be enabled in project configuration to use this function.
|
||||
*
|
||||
* Similar to esp_secure_boot_verify_signature(), but can be used when the digest is precalculated.
|
||||
* @param sig_block Pointer to ECDSA signature block data
|
||||
* @param image_digest Pointer to 32 byte buffer holding SHA-256 hash.
|
||||
* @param verified_digest Pointer to 32 byte buffer that will receive verified digest if verification completes. (Used during bootloader implementation only, result is invalid otherwise.)
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest);
|
||||
|
||||
#define FLASH_OFFS_SECURE_BOOT_IV_DIGEST 0
|
||||
|
||||
/** @brief Secure boot IV+digest header */
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#define FLASH_SECTOR_SIZE 0x1000
|
||||
#define FLASH_BLOCK_SIZE 0x10000
|
||||
#define MMAP_ALIGNED_MASK 0x0000FFFF
|
||||
|
||||
/* Provide a Flash API for bootloader_support code,
|
||||
that can be used from bootloader or app code.
|
||||
@@ -35,7 +36,7 @@
|
||||
*
|
||||
* @return Number of free pages
|
||||
*/
|
||||
uint32_t bootloader_mmap_get_free_pages();
|
||||
uint32_t bootloader_mmap_get_free_pages(void);
|
||||
|
||||
/**
|
||||
* @brief Map a region of flash to data memory
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
typedef void *bootloader_sha256_handle_t;
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start();
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void);
|
||||
|
||||
void bootloader_sha256_data(bootloader_sha256_handle_t handle, const void *data, size_t data_len);
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "esp_image_format.h"
|
||||
#include "bootloader_config.h"
|
||||
|
||||
/**
|
||||
* @brief Load partition table.
|
||||
@@ -62,3 +63,17 @@ __attribute__((noreturn)) void bootloader_utility_load_boot_image(const bootload
|
||||
* It is not recommended to call this function from an app (if called, the app will abort).
|
||||
*/
|
||||
__attribute__((noreturn)) void bootloader_reset(void);
|
||||
|
||||
/** @brief Generates the digest of the data between offset & offset+length.
|
||||
*
|
||||
* This function should be used when the size of the data is larger than 3.2MB.
|
||||
* The MMU capacity is 3.2MB (50 pages - 64KB each). This function generates the SHA-256
|
||||
* of the data in chunks of 3.2MB, considering the MMU capacity.
|
||||
*
|
||||
* @param[in] flash_offset Offset of the data in flash.
|
||||
* @param[in] len Length of data in bytes.
|
||||
* @param[out] digest Pointer to buffer where the digest is written, if ESP_OK is returned.
|
||||
*
|
||||
* @return ESP_OK if secure boot digest is generated successfully.
|
||||
*/
|
||||
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest);
|
||||
@@ -32,6 +32,22 @@ void bootloader_enable_qio_mode(void);
|
||||
*/
|
||||
uint32_t bootloader_read_flash_id();
|
||||
|
||||
/**
|
||||
* @brief Read the SFDP of the flash
|
||||
*
|
||||
* @param sfdp_addr Address of the parameter to read
|
||||
* @param miso_byte_num Bytes to read
|
||||
* @return The read SFDP, little endian, 4 bytes at most
|
||||
*/
|
||||
uint32_t bootloader_flash_read_sfdp(uint32_t sfdp_addr, unsigned int miso_byte_num);
|
||||
|
||||
/**
|
||||
* @brief Startup flow recommended by XMC. Call at startup before any erase/write operation.
|
||||
*
|
||||
* @return ESP_OK When startup successfully, otherwise ESP_FAIL (indiciating you should reboot before erase/write).
|
||||
*/
|
||||
esp_err_t bootloader_flash_xmc_startup(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#include "esp_flash_partitions.h"
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_config.h"
|
||||
#include "bootloader_utility.h"
|
||||
#include "soc/gpio_periph.h"
|
||||
#include "soc/efuse_reg.h"
|
||||
#include "soc/rtc.h"
|
||||
@@ -186,22 +188,7 @@ esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t
|
||||
size = data.image_len;
|
||||
}
|
||||
// If image is type by data then hash is calculated for entire image.
|
||||
const void *partition_bin = bootloader_mmap(address, size);
|
||||
if (partition_bin == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", address, size);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_handle_t sha_handle = bootloader_sha256_start();
|
||||
if (sha_handle == NULL) {
|
||||
bootloader_munmap(partition_bin);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
bootloader_sha256_data(sha_handle, partition_bin, size);
|
||||
bootloader_sha256_finish(sha_handle, out_sha_256);
|
||||
|
||||
bootloader_munmap(partition_bin);
|
||||
|
||||
return ESP_OK;
|
||||
return bootloader_sha256_flash_contents(address, size, out_sha_256);
|
||||
}
|
||||
|
||||
int bootloader_common_select_otadata(const esp_ota_select_entry_t *two_otadata, bool *valid_two_otadata, bool max)
|
||||
@@ -247,13 +234,15 @@ esp_err_t bootloader_common_get_partition_description(const esp_partition_pos_t
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
const uint8_t *image = bootloader_mmap(partition->offset, partition->size);
|
||||
const uint32_t app_desc_offset = sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t);
|
||||
const uint32_t mmap_size = app_desc_offset + sizeof(esp_app_desc_t);
|
||||
const uint8_t *image = bootloader_mmap(partition->offset, mmap_size);
|
||||
if (image == NULL) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, partition->size);
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", partition->offset, mmap_size);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
memcpy(app_desc, image + sizeof(esp_image_header_t) + sizeof(esp_image_segment_header_t), sizeof(esp_app_desc_t));
|
||||
memcpy(app_desc, image + app_desc_offset, sizeof(esp_app_desc_t));
|
||||
bootloader_munmap(image);
|
||||
|
||||
if (app_desc->magic_word != ESP_APP_DESC_MAGIC_WORD) {
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "soc/spi_reg.h"
|
||||
#include "soc/spi_pins.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "bootloader_flash_config.h"
|
||||
|
||||
void bootloader_flash_update_id()
|
||||
@@ -75,18 +76,11 @@ void IRAM_ATTR bootloader_flash_gpio_config(const esp_image_header_t* pfhdr)
|
||||
uint32_t chip_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
uint32_t pkg_ver = chip_ver & 0x7;
|
||||
|
||||
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5) {
|
||||
// For ESP32D2WD the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2) {
|
||||
// For ESP32PICOD2 the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
} else if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4) {
|
||||
// For ESP32PICOD4 the SPI pins are already configured
|
||||
if (pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302) {
|
||||
// For ESP32D2WD or ESP32-PICO series,the SPI pins are already configured
|
||||
// flash clock signal should come from IO MUX.
|
||||
PIN_FUNC_SELECT(PERIPHS_IO_MUX_SD_CLK_U, FUNC_SD_CLK_SPICLK);
|
||||
SET_PERI_REG_BITS(PERIPHS_IO_MUX_SD_CLK_U, FUN_DRV, drv, FUN_DRV_S);
|
||||
@@ -163,4 +157,33 @@ void IRAM_ATTR bootloader_flash_dummy_config(const esp_image_header_t* pfhdr)
|
||||
|
||||
SET_PERI_REG_BITS(SPI_USER1_REG(0), SPI_USR_DUMMY_CYCLELEN_V, spi_cache_dummy + g_rom_spiflash_dummy_len_plus[0],
|
||||
SPI_USR_DUMMY_CYCLELEN_S);
|
||||
}
|
||||
|
||||
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD & ESP32-PICO-D4 has this GPIO wired to WP pin of flash */
|
||||
#define ESP32_PICO_V3_GPIO 18 /* ESP32-PICO-V3* use this GPIO for WP pin of flash */
|
||||
|
||||
int bootloader_flash_get_wp_pin(void)
|
||||
{
|
||||
#if CONFIG_BOOTLOADER_SPI_CUSTOM_WP_PIN
|
||||
return CONFIG_BOOTLOADER_SPI_WP_PIN; // can be set for bootloader when QIO or QOUT config in use
|
||||
#elif CONFIG_SPIRAM_CUSTOM_SPIWP_SD3_PIN
|
||||
return CONFIG_SPIRAM_SPIWP_SD3_PIN; // can be set for app when DIO or DOUT config used for PSRAM only
|
||||
#else
|
||||
// no custom value, find it based on the package eFuse value
|
||||
uint8_t chip_ver;
|
||||
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
switch(pkg_ver) {
|
||||
case EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5:
|
||||
return ESP32_D2WD_WP_GPIO;
|
||||
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2:
|
||||
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4:
|
||||
/* Same package IDs are used for ESP32-PICO-V3 and ESP32-PICO-D4, silicon version differentiates */
|
||||
chip_ver = bootloader_common_get_chip_revision();
|
||||
return (chip_ver < 3) ? ESP32_D2WD_WP_GPIO : ESP32_PICO_V3_GPIO;
|
||||
case EFUSE_RD_CHIP_VER_PKG_ESP32PICOV302:
|
||||
return ESP32_PICO_V3_GPIO;
|
||||
default:
|
||||
return SPI_IOMUX_PIN_NUM_WP;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -145,6 +145,16 @@ static esp_err_t bootloader_main()
|
||||
#endif
|
||||
bootloader_clock_configure();
|
||||
uart_console_configure();
|
||||
|
||||
#if CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT_ENA
|
||||
/* Check and run XMC startup flow. The function depends on the clock and console, so it's run right after these stuff
|
||||
* are initialized. */
|
||||
if (bootloader_flash_xmc_startup() != ESP_OK) {
|
||||
ESP_LOGE(TAG, "failed when running XMC startup flow, reboot!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
#endif
|
||||
|
||||
wdt_reset_check();
|
||||
ESP_LOGI(TAG, "ESP-IDF %s 2nd stage bootloader", IDF_VER);
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
// App version is a wrapper around mbedTLS SHA API
|
||||
#include <mbedtls/sha256.h>
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
mbedtls_sha256_context *ctx = (mbedtls_sha256_context *)malloc(sizeof(mbedtls_sha256_context));
|
||||
if (!ctx) {
|
||||
@@ -53,6 +53,7 @@ void bootloader_sha256_finish(bootloader_sha256_handle_t handle, uint8_t *digest
|
||||
}
|
||||
mbedtls_sha256_free(ctx);
|
||||
free(handle);
|
||||
handle = NULL;
|
||||
}
|
||||
|
||||
#else // Bootloader version
|
||||
@@ -70,7 +71,7 @@ static const size_t BLOCK_WORDS = (64/sizeof(uint32_t));
|
||||
// Words in final SHA256 digest
|
||||
static const size_t DIGEST_WORDS = (32/sizeof(uint32_t));
|
||||
|
||||
bootloader_sha256_handle_t bootloader_sha256_start()
|
||||
bootloader_sha256_handle_t bootloader_sha256_start(void)
|
||||
{
|
||||
// Enable SHA hardware
|
||||
ets_sha_enable();
|
||||
|
||||
@@ -703,3 +703,39 @@ void bootloader_reset(void)
|
||||
abort(); /* This function should really not be called from application code */
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
esp_err_t bootloader_sha256_flash_contents(uint32_t flash_offset, uint32_t len, uint8_t *digest)
|
||||
{
|
||||
|
||||
if (digest == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
/* Handling firmware images larger than MMU capacity */
|
||||
uint32_t mmu_free_pages_count = bootloader_mmap_get_free_pages();
|
||||
bootloader_sha256_handle_t sha_handle = NULL;
|
||||
|
||||
sha_handle = bootloader_sha256_start();
|
||||
if (sha_handle == NULL) {
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
while (len > 0) {
|
||||
uint32_t mmu_page_offset = ((flash_offset & MMAP_ALIGNED_MASK) != 0) ? 1 : 0; /* Skip 1st MMU Page if it is already populated */
|
||||
uint32_t partial_image_len = MIN(len, ((mmu_free_pages_count - mmu_page_offset) * SPI_FLASH_MMU_PAGE_SIZE)); /* Read the image that fits in the free MMU pages */
|
||||
|
||||
const void * image = bootloader_mmap(flash_offset, partial_image_len);
|
||||
if (image == NULL) {
|
||||
bootloader_sha256_finish(sha_handle, NULL);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_data(sha_handle, image, partial_image_len);
|
||||
bootloader_munmap(image);
|
||||
|
||||
flash_offset += partial_image_len;
|
||||
len -= partial_image_len;
|
||||
}
|
||||
bootloader_sha256_finish(sha_handle, digest);
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <soc/cpu.h>
|
||||
#include <esp_image_format.h>
|
||||
#include <esp_secure_boot.h>
|
||||
#include <esp_fault.h>
|
||||
#include <esp_log.h>
|
||||
#include <esp_spi_flash.h>
|
||||
#include <bootloader_flash.h>
|
||||
@@ -25,6 +26,7 @@
|
||||
#include <bootloader_sha.h>
|
||||
#include "bootloader_util.h"
|
||||
#include "bootloader_common.h"
|
||||
#include "soc/soc_memory_layout.h"
|
||||
|
||||
/* Checking signatures as part of verifying images is necessary:
|
||||
- Always if secure boot is enabled
|
||||
@@ -92,7 +94,7 @@ static esp_err_t verify_segment_header(int index, const esp_image_segment_header
|
||||
|
||||
static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t checksum_word, esp_image_metadata_t *data);
|
||||
|
||||
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
||||
static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data,uint8_t *image_digest, uint8_t *verified_digest);
|
||||
static esp_err_t __attribute__((unused)) verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data);
|
||||
|
||||
static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data)
|
||||
@@ -108,6 +110,12 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
uint32_t checksum_word = ESP_ROM_CHECKSUM_INITIAL;
|
||||
bootloader_sha256_handle_t sha_handle = NULL;
|
||||
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
/* used for anti-FI checks */
|
||||
uint8_t image_digest[HASH_LEN] = { [ 0 ... 31] = 0xEE };
|
||||
uint8_t verified_digest[HASH_LEN] = { [ 0 ... 31 ] = 0x01 };
|
||||
#endif
|
||||
|
||||
if (data == NULL || part == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
@@ -196,7 +204,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
if (!is_bootloader) {
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
// secure boot images have a signature appended
|
||||
err = verify_secure_boot_signature(sha_handle, data);
|
||||
err = verify_secure_boot_signature(sha_handle, data, image_digest, verified_digest);
|
||||
#else
|
||||
// No secure boot, but SHA-256 can be appended for basic corruption detection
|
||||
if (sha_handle != NULL && !esp_cpu_in_ocd_debug_mode()) {
|
||||
@@ -226,7 +234,22 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
if (do_load) { // Need to deobfuscate RAM
|
||||
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
/* If signature was checked in bootloader build, verified_digest should equal image_digest
|
||||
|
||||
This is to detect any fault injection that caused signature verification to not complete normally.
|
||||
|
||||
Any attack which bypasses this check should be of limited use as the RAM contents are still obfuscated, therefore we do the check
|
||||
immediately before we deobfuscate.
|
||||
|
||||
Note: the conditions for making this check are the same as for setting verify_sha above, but on ESP32 SB V1 we move the test for
|
||||
"only verify signature in bootloader" into the macro so it's tested multiple times.
|
||||
*/
|
||||
ESP_FAULT_ASSERT(data->start_addr == ESP_BOOTLOADER_OFFSET || memcmp(image_digest, verified_digest, HASH_LEN) == 0);
|
||||
#endif // SECURE_BOOT_CHECK_SIGNATURE
|
||||
|
||||
if (do_load && ram_obfs_value[0] != 0 && ram_obfs_value[1] != 0) { // Need to deobfuscate RAM
|
||||
for (int i = 0; i < data->image.segment_count; i++) {
|
||||
uint32_t load_addr = data->segments[i].load_addr;
|
||||
if (should_load(load_addr)) {
|
||||
@@ -298,6 +321,127 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
/* Check the region load_addr - load_end doesn't overlap any memory used by the bootloader, registers, or other invalid memory
|
||||
*/
|
||||
static bool verify_load_addresses(int segment_index, intptr_t load_addr, intptr_t load_end, bool print_error, bool no_recurse)
|
||||
{
|
||||
/* Addresses of static data and the "loader" section of bootloader IRAM, all defined in ld script */
|
||||
const char *reason = NULL;
|
||||
extern int _dram_start, _dram_end, _loader_text_start, _loader_text_end;
|
||||
void *load_addr_p = (void *)load_addr;
|
||||
void *load_end_p = (void *)load_end;
|
||||
|
||||
if (load_end == load_addr) {
|
||||
return true; // zero-length segments are fine
|
||||
}
|
||||
assert(load_end > load_addr); // data_len<16MB is checked in verify_segment_header() which is called before this, so this should always be true
|
||||
|
||||
if (esp_ptr_in_dram(load_addr_p) && esp_ptr_in_dram(load_end_p)) { /* Writing to DRAM */
|
||||
/* Check if we're clobbering the stack */
|
||||
intptr_t sp = (intptr_t)get_sp();
|
||||
if (bootloader_util_regions_overlap(sp - STACK_LOAD_HEADROOM, SOC_ROM_STACK_START,
|
||||
load_addr, load_end)) {
|
||||
reason = "overlaps bootloader stack";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* Check if we're clobbering static data
|
||||
|
||||
(_dram_start.._dram_end includes bss, data, rodata sections in DRAM)
|
||||
*/
|
||||
if (bootloader_util_regions_overlap((intptr_t)&_dram_start, (intptr_t)&_dram_end, load_addr, load_end)) {
|
||||
reason = "overlaps bootloader data";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* LAST DRAM CHECK (recursive): for D/IRAM, check the equivalent IRAM addresses if needed
|
||||
|
||||
Allow for the possibility that even though both pointers are IRAM, only part of the region is in a D/IRAM
|
||||
section. In which case we recurse to check the part which falls in D/IRAM.
|
||||
|
||||
Note: We start with SOC_DIRAM_DRAM_LOW/HIGH and convert that address to IRAM to account for any reversing of word order
|
||||
(chip-specific).
|
||||
*/
|
||||
if (!no_recurse && bootloader_util_regions_overlap(SOC_DIRAM_DRAM_LOW, SOC_DIRAM_DRAM_HIGH, load_addr, load_end)) {
|
||||
intptr_t iram_load_addr, iram_load_end;
|
||||
|
||||
if (esp_ptr_in_diram_dram(load_addr_p)) {
|
||||
iram_load_addr = (intptr_t)esp_ptr_diram_dram_to_iram(load_addr_p);
|
||||
} else {
|
||||
iram_load_addr = (intptr_t)esp_ptr_diram_dram_to_iram((void *)SOC_DIRAM_DRAM_LOW);
|
||||
}
|
||||
|
||||
if (esp_ptr_in_diram_dram(load_end_p)) {
|
||||
iram_load_end = (intptr_t)esp_ptr_diram_dram_to_iram(load_end_p);
|
||||
} else {
|
||||
iram_load_end = (intptr_t)esp_ptr_diram_dram_to_iram((void *)SOC_DIRAM_DRAM_HIGH);
|
||||
}
|
||||
|
||||
if (iram_load_end < iram_load_addr) {
|
||||
return verify_load_addresses(segment_index, iram_load_end, iram_load_addr, print_error, true);
|
||||
} else {
|
||||
return verify_load_addresses(segment_index, iram_load_addr, iram_load_end, print_error, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (esp_ptr_in_iram(load_addr_p) && esp_ptr_in_iram(load_end_p)) { /* Writing to IRAM */
|
||||
/* Check for overlap of 'loader' section of IRAM */
|
||||
if (bootloader_util_regions_overlap((intptr_t)&_loader_text_start, (intptr_t)&_loader_text_end,
|
||||
load_addr, load_end)) {
|
||||
reason = "overlaps loader IRAM";
|
||||
goto invalid;
|
||||
}
|
||||
|
||||
/* LAST IRAM CHECK (recursive): for D/IRAM, check the equivalent DRAM address if needed
|
||||
|
||||
Allow for the possibility that even though both pointers are IRAM, only part of the region is in a D/IRAM
|
||||
section. In which case we recurse to check the part which falls in D/IRAM.
|
||||
Note: We start with SOC_DIRAM_IRAM_LOW/HIGH and convert that address to DRAM to account for any reversing of word order
|
||||
(chip-specific).
|
||||
*/
|
||||
if (!no_recurse && bootloader_util_regions_overlap(SOC_DIRAM_IRAM_LOW, SOC_DIRAM_IRAM_HIGH, load_addr, load_end)) {
|
||||
intptr_t dram_load_addr, dram_load_end;
|
||||
|
||||
if (esp_ptr_in_diram_iram(load_addr_p)) {
|
||||
dram_load_addr = (intptr_t)esp_ptr_diram_iram_to_dram(load_addr_p);
|
||||
} else {
|
||||
dram_load_addr = (intptr_t)esp_ptr_diram_iram_to_dram((void *)SOC_DIRAM_IRAM_LOW);
|
||||
}
|
||||
|
||||
if (esp_ptr_in_diram_iram(load_end_p)) {
|
||||
dram_load_end = (intptr_t)esp_ptr_diram_iram_to_dram(load_end_p);
|
||||
} else {
|
||||
dram_load_end = (intptr_t)esp_ptr_diram_iram_to_dram((void *)SOC_DIRAM_IRAM_HIGH);
|
||||
}
|
||||
|
||||
if (dram_load_end < dram_load_addr) {
|
||||
return verify_load_addresses(segment_index, dram_load_end, dram_load_addr, print_error, true);
|
||||
} else {
|
||||
return verify_load_addresses(segment_index, dram_load_addr, dram_load_end, print_error, true);
|
||||
}
|
||||
}
|
||||
/* Sections entirely in RTC memory won't overlap with a vanilla bootloader but are valid load addresses, thus skipping them from the check */
|
||||
} else if (esp_ptr_in_rtc_iram_fast(load_addr_p) && esp_ptr_in_rtc_iram_fast(load_end_p)){
|
||||
return true;
|
||||
} else if (esp_ptr_in_rtc_dram_fast(load_addr_p) && esp_ptr_in_rtc_dram_fast(load_end_p)){
|
||||
return true;
|
||||
} else if (esp_ptr_in_rtc_slow(load_addr_p) && esp_ptr_in_rtc_slow(load_end_p)) {
|
||||
return true;
|
||||
} else { /* Not a DRAM or an IRAM or RTC Fast IRAM, RTC Fast DRAM or RTC Slow address */
|
||||
reason = "bad load address range";
|
||||
goto invalid;
|
||||
}
|
||||
return true;
|
||||
|
||||
invalid:
|
||||
if (print_error) {
|
||||
ESP_LOGE(TAG, "Segment %d 0x%08x-0x%08x invalid: %s", segment_index, load_addr, load_end, reason);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segment_header_t *header, bool silent, bool do_load, bootloader_sha256_handle_t sha_handle, uint32_t *checksum)
|
||||
{
|
||||
esp_err_t err;
|
||||
@@ -337,37 +481,11 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
(do_load)?"load":(is_mapping)?"map":"");
|
||||
}
|
||||
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
/* Before loading segment, check it doesn't clobber bootloader RAM. */
|
||||
if (do_load) {
|
||||
const intptr_t load_end = load_addr + data_len;
|
||||
if (load_end <= (intptr_t) SOC_DIRAM_DRAM_HIGH) {
|
||||
/* Writing to DRAM */
|
||||
intptr_t sp = (intptr_t)get_sp();
|
||||
if (load_end > sp - STACK_LOAD_HEADROOM) {
|
||||
/* Bootloader .data/.rodata/.bss is above the stack, so this
|
||||
* also checks that we aren't overwriting these segments.
|
||||
*
|
||||
* TODO: This assumes specific arrangement of sections we have
|
||||
* in the ESP32. Rewrite this in a generic way to support other
|
||||
* layouts.
|
||||
*/
|
||||
ESP_LOGE(TAG, "Segment %d end address 0x%08x too high (bootloader stack 0x%08x limit 0x%08x)",
|
||||
index, load_end, sp, sp - STACK_LOAD_HEADROOM);
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
} else {
|
||||
/* Writing to IRAM */
|
||||
const intptr_t loader_iram_start = (intptr_t) &_loader_text_start;
|
||||
const intptr_t loader_iram_end = (intptr_t) &_loader_text_end;
|
||||
|
||||
if (bootloader_util_regions_overlap(loader_iram_start, loader_iram_end,
|
||||
load_addr, load_end)) {
|
||||
ESP_LOGE(TAG, "Segment %d (0x%08x-0x%08x) overlaps bootloader IRAM (0x%08x-0x%08x)",
|
||||
index, load_addr, load_end, loader_iram_start, loader_iram_end);
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
if (do_load && data_len > 0) {
|
||||
if (!verify_load_addresses(index, load_addr, load_addr + data_len, true, false)) {
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
}
|
||||
#endif // BOOTLOADER_BUILD
|
||||
@@ -377,6 +495,10 @@ static esp_err_t process_segment(int index, uint32_t flash_addr, esp_image_segme
|
||||
|
||||
int32_t data_len_remain = data_len;
|
||||
while (data_len_remain > 0) {
|
||||
#if defined(SECURE_BOOT_CHECK_SIGNATURE) && defined(BOOTLOADER_BUILD)
|
||||
/* Double check the address verification done above */
|
||||
ESP_FAULT_ASSERT(!do_load || verify_load_addresses(0, load_addr, load_addr + data_len_remain, false, false));
|
||||
#endif
|
||||
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
|
||||
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
|
||||
data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
|
||||
@@ -572,28 +694,33 @@ static esp_err_t verify_checksum(bootloader_sha256_handle_t sha_handle, uint32_t
|
||||
|
||||
static void debug_log_hash(const uint8_t *image_hash, const char *caption);
|
||||
|
||||
static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data)
|
||||
static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data, uint8_t *image_digest, uint8_t *verified_digest)
|
||||
{
|
||||
uint8_t image_hash[HASH_LEN] = { 0 };
|
||||
#ifdef SECURE_BOOT_CHECK_SIGNATURE
|
||||
uint32_t end = data->start_addr + data->image_len;
|
||||
|
||||
ESP_LOGI(TAG, "Verifying image signature...");
|
||||
|
||||
// For secure boot, we calculate the signature hash over the whole file, which includes any "simple" hash
|
||||
// appended to the image for corruption detection
|
||||
if (data->image.hash_appended) {
|
||||
const void *simple_hash = bootloader_mmap(data->start_addr + data->image_len - HASH_LEN, HASH_LEN);
|
||||
const void *simple_hash = bootloader_mmap(end - HASH_LEN, HASH_LEN);
|
||||
bootloader_sha256_data(sha_handle, simple_hash, HASH_LEN);
|
||||
bootloader_munmap(simple_hash);
|
||||
}
|
||||
|
||||
bootloader_sha256_finish(sha_handle, image_hash);
|
||||
bootloader_sha256_finish(sha_handle, image_digest);
|
||||
|
||||
// Log the hash for debugging
|
||||
debug_log_hash(image_hash, "Calculated secure boot hash");
|
||||
debug_log_hash(image_digest, "Calculated secure boot hash");
|
||||
|
||||
// Use hash to verify signature block
|
||||
const esp_secure_boot_sig_block_t *sig_block = bootloader_mmap(data->start_addr + data->image_len, sizeof(esp_secure_boot_sig_block_t));
|
||||
esp_err_t err = esp_secure_boot_verify_signature_block(sig_block, image_hash);
|
||||
esp_err_t err = ESP_ERR_IMAGE_INVALID;
|
||||
const void *sig_block;
|
||||
ESP_FAULT_ASSERT(memcmp(image_digest, verified_digest, HASH_LEN) != 0); /* sanity check that these values start differently */
|
||||
sig_block = bootloader_mmap(data->start_addr + data->image_len, sizeof(esp_secure_boot_sig_block_t));
|
||||
err = esp_secure_boot_verify_ecdsa_signature_block(sig_block, image_digest, verified_digest);
|
||||
|
||||
bootloader_munmap(sig_block);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Secure boot signature verification failed");
|
||||
@@ -614,6 +741,7 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han
|
||||
return ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
|
||||
#endif // SECURE_BOOT_CHECK_SIGNATURE
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -199,19 +199,22 @@ static esp_err_t encrypt_flash_contents(uint32_t flash_crypt_cnt, bool flash_cry
|
||||
|
||||
ESP_LOGD(TAG, "All flash regions checked for encryption pass");
|
||||
|
||||
uint32_t new_flash_crypt_cnt;
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_DISABLE_PLAINTEXT
|
||||
ESP_LOGI(TAG, "Setting FLASH_CRYPT_CNT efuse to max...");
|
||||
new_flash_crypt_cnt = EFUSE_FLASH_CRYPT_CNT;
|
||||
#else
|
||||
/* Set least significant 0-bit in flash_crypt_cnt */
|
||||
int ffs_inv = __builtin_ffs((~flash_crypt_cnt) & EFUSE_RD_FLASH_CRYPT_CNT);
|
||||
/* ffs_inv shouldn't be zero, as zero implies flash_crypt_cnt == EFUSE_RD_FLASH_CRYPT_CNT (0x7F) */
|
||||
uint32_t new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
|
||||
new_flash_crypt_cnt = flash_crypt_cnt + (1 << (ffs_inv - 1));
|
||||
if (new_flash_crypt_cnt != EFUSE_FLASH_CRYPT_CNT) {
|
||||
ESP_LOGW(TAG, "Not disabling FLASH_CRYPT_CNT - plaintext flashing is still possible");
|
||||
}
|
||||
#endif
|
||||
ESP_LOGD(TAG, "FLASH_CRYPT_CNT 0x%x -> 0x%x", flash_crypt_cnt, new_flash_crypt_cnt);
|
||||
REG_SET_FIELD(EFUSE_BLK0_WDATA0_REG, EFUSE_FLASH_CRYPT_CNT, new_flash_crypt_cnt);
|
||||
|
||||
#ifdef CONFIG_FLASH_ENCRYPTION_DISABLE_PLAINTEXT
|
||||
ESP_LOGI(TAG, "Write protecting FLASH_CRYPT_CNT efuse...");
|
||||
REG_SET_BIT(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_FLASH_CRYPT_CNT);
|
||||
#else
|
||||
ESP_LOGW(TAG, "Not disabling FLASH_CRYPT_CNT - plaintext flashing is still possible");
|
||||
#endif
|
||||
|
||||
esp_efuse_burn_new_values();
|
||||
|
||||
@@ -348,12 +351,19 @@ esp_err_t esp_flash_encrypt_region(uint32_t src_addr, size_t data_length)
|
||||
return err;
|
||||
}
|
||||
|
||||
void esp_flash_write_protect_crypt_cnt()
|
||||
void esp_flash_write_protect_crypt_cnt()
|
||||
{
|
||||
if (!esp_flash_encryption_enabled()) {
|
||||
ESP_LOGE(TAG, "flash encryption not enabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t efuse_blk0 = REG_READ(EFUSE_BLK0_RDATA0_REG);
|
||||
bool flash_crypt_wr_dis = efuse_blk0 & EFUSE_WR_DIS_FLASH_CRYPT_CNT;
|
||||
if(!flash_crypt_wr_dis) {
|
||||
REG_WRITE(EFUSE_BLK0_WDATA0_REG, EFUSE_WR_DIS_FLASH_CRYPT_CNT);
|
||||
unsigned flash_crypt_cnt = REG_GET_FIELD(EFUSE_BLK0_RDATA0_REG, EFUSE_FLASH_CRYPT_CNT);
|
||||
if(!flash_crypt_wr_dis && flash_crypt_cnt != EFUSE_FLASH_CRYPT_CNT) {
|
||||
/* Disable by setting flash_crypt_cnt to max, to still allow disabling UART DL mode on ESP32 rev 3 */
|
||||
REG_SET_FIELD(EFUSE_BLK0_WDATA0_REG, EFUSE_FLASH_CRYPT_CNT, EFUSE_FLASH_CRYPT_CNT);
|
||||
esp_efuse_burn_new_values();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,9 +13,12 @@
|
||||
// limitations under the License.
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "bootloader_flash_config.h"
|
||||
#include "esp_attr.h"
|
||||
#include "flash_qio_mode.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "rom/ets_sys.h"
|
||||
#include "rom/spi_flash.h"
|
||||
#include "rom/efuse.h"
|
||||
#include "soc/spi_struct.h"
|
||||
@@ -36,8 +39,12 @@
|
||||
#define CMD_RDSR 0x05
|
||||
#define CMD_RDSR2 0x35 /* Not all SPI flash uses this command */
|
||||
#define CMD_OTPEN 0x3A /* Enable OTP mode, not all SPI flash uses this command */
|
||||
#define CMD_RDSFDP 0x5A /* Read the SFDP of the flash */
|
||||
|
||||
static const char *TAG = "qio_mode";
|
||||
#define BYTESHIFT(VAR, IDX) (((VAR) >> ((IDX) * 8)) & 0xFF)
|
||||
|
||||
|
||||
static DRAM_ATTR char TAG[] = "qio_mode";
|
||||
|
||||
typedef unsigned (*read_status_fn_t)();
|
||||
typedef void (*write_status_fn_t)(unsigned);
|
||||
@@ -71,12 +78,6 @@ static unsigned read_status_8b_xmc25qu64a();
|
||||
/* Write 8 bit status of XM25QU64A */
|
||||
static void write_status_8b_xmc25qu64a(unsigned new_status);
|
||||
|
||||
#define ESP32_D2WD_WP_GPIO 7 /* ESP32-D2WD has this GPIO wired to WP pin of flash */
|
||||
|
||||
#ifndef CONFIG_BOOTLOADER_SPI_WP_PIN // Set in menuconfig if SPI flasher config is set to a quad mode
|
||||
#define CONFIG_BOOTLOADER_SPI_WP_PIN ESP32_D2WD_WP_GPIO
|
||||
#endif
|
||||
|
||||
/* Array of known flash chips and data to enable Quad I/O mode
|
||||
|
||||
Manufacturer & flash ID can be tested by running "esptool.py
|
||||
@@ -121,7 +122,7 @@ static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8
|
||||
|
||||
/* dummy_len_plus values defined in ROM for SPI flash configuration */
|
||||
extern uint8_t g_rom_spiflash_dummy_len_plus[];
|
||||
uint32_t bootloader_read_flash_id()
|
||||
uint32_t IRAM_ATTR bootloader_read_flash_id(void)
|
||||
{
|
||||
uint32_t id = execute_flash_command(CMD_RDID, 0, 0, 24);
|
||||
id = ((id & 0xff) << 16) | ((id >> 16) & 0xff) | (id & 0xff00);
|
||||
@@ -169,22 +170,6 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
uint32_t status;
|
||||
const uint32_t spiconfig = ets_efuse_get_spiconfig();
|
||||
|
||||
if (spiconfig != EFUSE_SPICONFIG_SPI_DEFAULTS && spiconfig != EFUSE_SPICONFIG_HSPI_DEFAULTS) {
|
||||
// spiconfig specifies a custom efuse pin configuration. This config defines all pins -except- WP,
|
||||
// which is compiled into the bootloader instead.
|
||||
//
|
||||
// Most commonly an overriden pin mapping means ESP32-D2WD or ESP32-PICOD4.
|
||||
//Warn if chip is ESP32-D2WD/ESP32-PICOD4 but someone has changed the WP pin
|
||||
//assignment from that chip's WP pin.
|
||||
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_BLK0_RDATA3_REG, EFUSE_RD_CHIP_VER_PKG);
|
||||
if (CONFIG_BOOTLOADER_SPI_WP_PIN != ESP32_D2WD_WP_GPIO &&
|
||||
(pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32D2WDQ5 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD2 ||
|
||||
pkg_ver == EFUSE_RD_CHIP_VER_PKG_ESP32PICOD4)) {
|
||||
ESP_LOGW(TAG, "Chip is ESP32-D2WD/ESP32-PICOD4 but flash WP pin is different value to internal flash");
|
||||
}
|
||||
}
|
||||
|
||||
esp_rom_spiflash_wait_idle(&g_rom_flashchip);
|
||||
|
||||
status = read_status_fn();
|
||||
@@ -218,7 +203,8 @@ static esp_err_t enable_qio_mode(read_status_fn_t read_status_fn,
|
||||
|
||||
esp_rom_spiflash_config_readmode(mode);
|
||||
|
||||
esp_rom_spiflash_select_qio_pins(CONFIG_BOOTLOADER_SPI_WP_PIN, spiconfig);
|
||||
int wp_pin = bootloader_flash_get_wp_pin();
|
||||
esp_rom_spiflash_select_qio_pins(wp_pin, spiconfig);
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
@@ -271,37 +257,171 @@ static void write_status_8b_xmc25qu64a(unsigned new_status)
|
||||
execute_flash_command(CMD_WRDI, 0, 0, 0); /* Exit OTP mode */
|
||||
}
|
||||
|
||||
static uint32_t execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
IRAM_ATTR static uint32_t bootloader_flash_execute_command_common(
|
||||
uint8_t command,
|
||||
uint32_t addr_len, uint32_t address,
|
||||
uint8_t dummy_len,
|
||||
uint8_t mosi_len, uint32_t mosi_data,
|
||||
uint8_t miso_len)
|
||||
{
|
||||
uint32_t old_ctrl_reg = SPIFLASH.ctrl.val;
|
||||
uint32_t old_user_reg = SPIFLASH.user.val;
|
||||
uint32_t old_user1_reg = SPIFLASH.user1.val;
|
||||
SPIFLASH.ctrl.val = SPI_WP_REG_M; // keep WP high while idle, otherwise leave DIO mode
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user.usr_addr = 0;
|
||||
//command phase
|
||||
SPIFLASH.user.usr_command = 1;
|
||||
SPIFLASH.user2.usr_command_bitlen = 7;
|
||||
|
||||
SPIFLASH.user2.usr_command_value = command;
|
||||
SPIFLASH.user.usr_miso = miso_len > 0;
|
||||
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
|
||||
//addr phase
|
||||
SPIFLASH.user.usr_addr = addr_len > 0;
|
||||
SPIFLASH.user1.usr_addr_bitlen = addr_len - 1;
|
||||
SPIFLASH.addr = (addr_len > 0)? (address << (32-addr_len)) : 0;
|
||||
//dummy phase
|
||||
if (miso_len > 0) {
|
||||
uint32_t total_dummy = dummy_len + g_rom_spiflash_dummy_len_plus[1];
|
||||
SPIFLASH.user.usr_dummy = total_dummy > 0;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = total_dummy - 1;
|
||||
} else {
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = 0;
|
||||
}
|
||||
//output data
|
||||
SPIFLASH.user.usr_mosi = mosi_len > 0;
|
||||
SPIFLASH.mosi_dlen.usr_mosi_dbitlen = mosi_len ? (mosi_len - 1) : 0;
|
||||
SPIFLASH.data_buf[0] = mosi_data;
|
||||
|
||||
if (g_rom_spiflash_dummy_len_plus[1]) {
|
||||
/* When flash pins are mapped via GPIO matrix, need a dummy cycle before reading via MISO */
|
||||
if (miso_len > 0) {
|
||||
SPIFLASH.user.usr_dummy = 1;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = g_rom_spiflash_dummy_len_plus[1] - 1;
|
||||
} else {
|
||||
SPIFLASH.user.usr_dummy = 0;
|
||||
SPIFLASH.user1.usr_dummy_cyclelen = 0;
|
||||
}
|
||||
}
|
||||
//input data
|
||||
SPIFLASH.user.usr_miso = miso_len > 0;
|
||||
SPIFLASH.miso_dlen.usr_miso_dbitlen = miso_len ? (miso_len - 1) : 0;
|
||||
|
||||
SPIFLASH.cmd.usr = 1;
|
||||
while(SPIFLASH.cmd.usr != 0)
|
||||
{ }
|
||||
|
||||
SPIFLASH.ctrl.val = old_ctrl_reg;
|
||||
return SPIFLASH.data_buf[0];
|
||||
SPIFLASH.user.val = old_user_reg;
|
||||
SPIFLASH.user1.val = old_user1_reg;
|
||||
|
||||
uint32_t ret = SPIFLASH.data_buf[0];
|
||||
if (miso_len < 32) {
|
||||
//set unused bits to 0
|
||||
ret &= ~(UINT32_MAX << miso_len);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static uint32_t IRAM_ATTR execute_flash_command(uint8_t command, uint32_t mosi_data, uint8_t mosi_len, uint8_t miso_len)
|
||||
{
|
||||
const uint8_t addr_len = 0;
|
||||
const uint8_t address = 0;
|
||||
const uint8_t dummy_len = 0;
|
||||
|
||||
return bootloader_flash_execute_command_common(command, addr_len, address,
|
||||
dummy_len, mosi_len, mosi_data, miso_len);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* XMC startup flow
|
||||
******************************************************************************/
|
||||
|
||||
#define XMC_SUPPORT CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT_ENA
|
||||
#define XMC_VENDOR_ID 0x20
|
||||
|
||||
#if BOOTLOADER_BUILD
|
||||
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_LOG##level(TAG, ##__VA_ARGS__)
|
||||
#else
|
||||
#define BOOTLOADER_FLASH_LOG(level, ...) ESP_DRAM_LOG##level(TAG, ##__VA_ARGS__)
|
||||
|
||||
#define ESP_DRAM_LOGE( tag, format, ... ) ESP_DRAM_LOG_IMPL(tag, format, ESP_LOG_ERROR, E, ##__VA_ARGS__)
|
||||
#define ESP_DRAM_LOGW( tag, format, ... ) ESP_DRAM_LOG_IMPL(tag, format, ESP_LOG_WARN, E, ##__VA_ARGS__)
|
||||
#define ESP_DRAM_LOGI( tag, format, ... ) ESP_DRAM_LOG_IMPL(tag, format, ESP_LOG_INFO, E, ##__VA_ARGS__)
|
||||
#define ESP_DRAM_LOGD( tag, format, ... ) ESP_DRAM_LOG_IMPL(tag, format, ESP_LOG_DEBUG, E, ##__VA_ARGS__)
|
||||
#define ESP_DRAM_LOGV( tag, format, ... ) ESP_DRAM_LOG_IMPL(tag, format, ESP_LOG_VERBOSE, E, ##__VA_ARGS__)
|
||||
|
||||
#define ESP_DRAM_LOG_IMPL(tag, format, log_level, log_tag_letter, ...) do { \
|
||||
if (LOG_LOCAL_LEVEL >= (log_level)) { \
|
||||
ets_printf(DRAM_STR(#log_tag_letter " %s: " format "\n"), tag, ##__VA_ARGS__); \
|
||||
}} while(0)
|
||||
|
||||
#endif
|
||||
|
||||
#if XMC_SUPPORT || !BOOTLOADER_BUILD
|
||||
// cmd(0x5A) + 24bit address + 8 cycles dummy
|
||||
uint32_t IRAM_ATTR bootloader_flash_read_sfdp(uint32_t sfdp_addr, unsigned int miso_byte_num)
|
||||
{
|
||||
const uint8_t command = CMD_RDSFDP;
|
||||
const uint8_t addr_len = 24;
|
||||
const uint8_t dummy_len = 8;
|
||||
const uint8_t mosi_len = 0;
|
||||
const uint32_t mosi_data = 0;
|
||||
const uint8_t miso_len = miso_byte_num * 8;
|
||||
|
||||
return bootloader_flash_execute_command_common(command, addr_len, sfdp_addr,
|
||||
dummy_len, mosi_len, mosi_data, miso_len);
|
||||
}
|
||||
|
||||
//strictly check the model
|
||||
static IRAM_ATTR bool is_xmc_chip_strict(uint32_t rdid)
|
||||
{
|
||||
uint32_t vendor_id = BYTESHIFT(rdid, 2);
|
||||
uint32_t mfid = BYTESHIFT(rdid, 1);
|
||||
uint32_t cpid = BYTESHIFT(rdid, 0);
|
||||
|
||||
if (vendor_id != XMC_VENDOR_ID) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool matched = false;
|
||||
if (mfid == 0x40) {
|
||||
if (cpid >= 0x13 && cpid <= 0x20) {
|
||||
matched = true;
|
||||
}
|
||||
} else if (mfid == 0x41) {
|
||||
if (cpid >= 0x17 && cpid <= 0x20) {
|
||||
matched = true;
|
||||
}
|
||||
} else if (mfid == 0x50) {
|
||||
if (cpid >= 0x15 && cpid <= 0x16) {
|
||||
matched = true;
|
||||
}
|
||||
}
|
||||
return matched;
|
||||
}
|
||||
|
||||
esp_err_t IRAM_ATTR bootloader_flash_xmc_startup(void)
|
||||
{
|
||||
// If the RDID value is a valid XMC one, may skip the flow
|
||||
const bool fast_check = true;
|
||||
if (fast_check && is_xmc_chip_strict(g_rom_flashchip.device_id)) {
|
||||
BOOTLOADER_FLASH_LOG(D, "XMC chip detected by RDID (%08X), skip.", g_rom_flashchip.device_id);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
// Check the Manufacturer ID in SFDP registers (JEDEC standard). If not XMC chip, no need to run the flow
|
||||
const int sfdp_mfid_addr = 0x10;
|
||||
uint8_t mf_id = (bootloader_flash_read_sfdp(sfdp_mfid_addr, 1) & 0xff);
|
||||
if (mf_id != XMC_VENDOR_ID) {
|
||||
BOOTLOADER_FLASH_LOG(D, "non-XMC chip detected by SFDP Read (%02X), skip.", mf_id);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
BOOTLOADER_FLASH_LOG(I, "XM25QHxxC startup flow");
|
||||
// Enter DPD
|
||||
execute_flash_command(0xB9, 0, 0, 0);
|
||||
// Enter UDPD
|
||||
execute_flash_command(0x79, 0, 0, 0);
|
||||
// Exit UDPD
|
||||
execute_flash_command(0xFF, 0, 0, 0);
|
||||
// Delay tXUDPD
|
||||
ets_delay_us(2000);
|
||||
// Release Power-down
|
||||
execute_flash_command(0xAB, 0, 0, 0);
|
||||
ets_delay_us(20);
|
||||
// Read flash ID and check again
|
||||
g_rom_flashchip.device_id = bootloader_read_flash_id();
|
||||
if (!is_xmc_chip_strict(g_rom_flashchip.device_id)) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
#endif //XMC_SUPPORT
|
||||
|
||||
@@ -15,11 +15,22 @@
|
||||
|
||||
#include "bootloader_flash.h"
|
||||
#include "bootloader_sha.h"
|
||||
#include "bootloader_utility.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_image_format.h"
|
||||
#include "esp_secure_boot.h"
|
||||
|
||||
#include "uECC.h"
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
#include "uECC_verify_antifault.h"
|
||||
#else
|
||||
#include "mbedtls/sha256.h"
|
||||
#include "mbedtls/x509.h"
|
||||
#include "mbedtls/md.h"
|
||||
#include "mbedtls/platform.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include <string.h>
|
||||
#endif
|
||||
|
||||
#include <sys/param.h>
|
||||
|
||||
@@ -38,38 +49,17 @@ extern const uint8_t signature_verification_key_end[] asm("_binary_signature_ver
|
||||
esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
|
||||
{
|
||||
uint8_t digest[DIGEST_LEN];
|
||||
const uint8_t *data;
|
||||
uint8_t verified_digest[DIGEST_LEN] = { 0 }; /* ignored in this function */
|
||||
const esp_secure_boot_sig_block_t *sigblock;
|
||||
|
||||
ESP_LOGD(TAG, "verifying signature src_addr 0x%x length 0x%x", src_addr, length);
|
||||
|
||||
bootloader_sha256_handle_t handle = bootloader_sha256_start();
|
||||
esp_err_t err = bootloader_sha256_flash_contents(src_addr, length, digest);
|
||||
|
||||
uint32_t free_page_count = bootloader_mmap_get_free_pages();
|
||||
ESP_LOGD(TAG, "free data page_count 0x%08x", free_page_count);
|
||||
|
||||
int32_t data_len_remain = length;
|
||||
uint32_t data_addr = src_addr;
|
||||
while (data_len_remain > 0) {
|
||||
uint32_t offset_page = ((data_addr & MMAP_ALIGNED_MASK) != 0) ? 1 : 0;
|
||||
/* Data we could map in case we are not aligned to PAGE boundary is one page size lesser. */
|
||||
uint32_t data_len = MIN(data_len_remain, ((free_page_count - offset_page) * SPI_FLASH_MMU_PAGE_SIZE));
|
||||
data = (const uint8_t *) bootloader_mmap(data_addr, data_len);
|
||||
if(!data) {
|
||||
ESP_LOGE(TAG, "bootloader_mmap(0x%x, 0x%x) failed", data_addr, data_len);
|
||||
bootloader_sha256_finish(handle, NULL);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
bootloader_sha256_data(handle, data, data_len);
|
||||
bootloader_munmap(data);
|
||||
|
||||
data_addr += data_len;
|
||||
data_len_remain -= data_len;
|
||||
if (err != ESP_OK) {
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Done! Get the digest */
|
||||
bootloader_sha256_finish(handle, digest);
|
||||
|
||||
// Map the signature block
|
||||
sigblock = (const esp_secure_boot_sig_block_t *) bootloader_mmap(src_addr + length, sizeof(esp_secure_boot_sig_block_t));
|
||||
if(!sigblock) {
|
||||
@@ -77,20 +67,27 @@ esp_err_t esp_secure_boot_verify_signature(uint32_t src_addr, uint32_t length)
|
||||
return ESP_FAIL;
|
||||
}
|
||||
// Verify the signature
|
||||
esp_err_t err = esp_secure_boot_verify_signature_block(sigblock, digest);
|
||||
err = esp_secure_boot_verify_ecdsa_signature_block(sigblock, digest, verified_digest);
|
||||
// Unmap
|
||||
bootloader_munmap(sigblock);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
#ifdef BOOTLOADER_BUILD
|
||||
esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest)
|
||||
{
|
||||
uint8_t verified_digest[DIGEST_LEN] = { 0 };
|
||||
return esp_secure_boot_verify_ecdsa_signature_block(sig_block, image_digest, verified_digest);
|
||||
}
|
||||
|
||||
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
|
||||
{
|
||||
ptrdiff_t keylen;
|
||||
bool is_valid;
|
||||
|
||||
keylen = signature_verification_key_end - signature_verification_key_start;
|
||||
if(keylen != SIGNATURE_VERIFICATION_KEYLEN) {
|
||||
if (keylen != SIGNATURE_VERIFICATION_KEYLEN) {
|
||||
ESP_LOGE(TAG, "Embedded public verification key has wrong length %d", keylen);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -102,11 +99,88 @@ esp_err_t esp_secure_boot_verify_signature_block(const esp_secure_boot_sig_block
|
||||
|
||||
ESP_LOGD(TAG, "Verifying secure boot signature");
|
||||
|
||||
is_valid = uECC_verify(signature_verification_key_start,
|
||||
is_valid = uECC_verify_antifault(signature_verification_key_start,
|
||||
image_digest,
|
||||
DIGEST_LEN,
|
||||
sig_block->signature,
|
||||
uECC_secp256r1());
|
||||
uECC_secp256r1(),
|
||||
verified_digest);
|
||||
ESP_LOGD(TAG, "Verification result %d", is_valid);
|
||||
return is_valid ? ESP_OK : ESP_ERR_IMAGE_INVALID;
|
||||
}
|
||||
|
||||
#else // BOOTLOADER_BUILD
|
||||
|
||||
esp_err_t esp_secure_boot_verify_ecdsa_signature_block(const esp_secure_boot_sig_block_t *sig_block, const uint8_t *image_digest, uint8_t *verified_digest)
|
||||
{
|
||||
#if !(defined(CONFIG_MBEDTLS_ECDSA_C) && defined(CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED))
|
||||
ESP_LOGE(TAG, "Signature verification requires ECDSA & SECP256R1 curve enabled");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#else
|
||||
ptrdiff_t keylen;
|
||||
|
||||
/* Note: in IDF app image verification we don't add any fault injection resistance, boot-time checks only */
|
||||
memset(verified_digest, 0, DIGEST_LEN);
|
||||
|
||||
keylen = signature_verification_key_end - signature_verification_key_start;
|
||||
if (keylen != SIGNATURE_VERIFICATION_KEYLEN) {
|
||||
ESP_LOGE(TAG, "Embedded public verification key has wrong length %d", keylen);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (sig_block->version != 0) {
|
||||
ESP_LOGE(TAG, "image has invalid signature version field 0x%08x", sig_block->version);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ESP_LOGD(TAG, "Verifying secure boot signature");
|
||||
|
||||
int ret;
|
||||
mbedtls_mpi r, s;
|
||||
|
||||
mbedtls_mpi_init(&r);
|
||||
mbedtls_mpi_init(&s);
|
||||
|
||||
/* Extract r and s components from RAW ECDSA signature of 64 bytes */
|
||||
#define ECDSA_INTEGER_LEN 32
|
||||
ret = mbedtls_mpi_read_binary(&r, &sig_block->signature[0], ECDSA_INTEGER_LEN);
|
||||
if (ret != 0) {
|
||||
ESP_LOGE(TAG, "Failed mbedtls_mpi_read_binary(1), err:%d", ret);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ret = mbedtls_mpi_read_binary(&s, &sig_block->signature[ECDSA_INTEGER_LEN], ECDSA_INTEGER_LEN);
|
||||
if (ret != 0) {
|
||||
ESP_LOGE(TAG, "Failed mbedtls_mpi_read_binary(2), err:%d", ret);
|
||||
mbedtls_mpi_free(&r);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
/* Initialise ECDSA context */
|
||||
mbedtls_ecdsa_context ecdsa_context;
|
||||
mbedtls_ecdsa_init(&ecdsa_context);
|
||||
|
||||
mbedtls_ecp_group_load(&ecdsa_context.grp, MBEDTLS_ECP_DP_SECP256R1);
|
||||
size_t plen = mbedtls_mpi_size(&ecdsa_context.grp.P);
|
||||
if (keylen != 2 * plen) {
|
||||
ESP_LOGE(TAG, "Incorrect ECDSA key length %d", keylen);
|
||||
ret = ESP_FAIL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* Extract X and Y components from ECDSA public key */
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ecdsa_context.Q.X, signature_verification_key_start, plen));
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_read_binary(&ecdsa_context.Q.Y, signature_verification_key_start + plen, plen));
|
||||
MBEDTLS_MPI_CHK(mbedtls_mpi_lset(&ecdsa_context.Q.Z, 1));
|
||||
|
||||
ret = mbedtls_ecdsa_verify(&ecdsa_context.grp, image_digest, DIGEST_LEN, &ecdsa_context.Q, &r, &s);
|
||||
ESP_LOGD(TAG, "Verification result %d", ret);
|
||||
|
||||
cleanup:
|
||||
mbedtls_mpi_free(&r);
|
||||
mbedtls_mpi_free(&s);
|
||||
mbedtls_ecdsa_free(&ecdsa_context);
|
||||
return ret == 0 ? ESP_OK : ESP_ERR_IMAGE_INVALID;
|
||||
#endif // CONFIG_MBEDTLS_ECDSA_C && CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||
}
|
||||
#endif // BOOTLOADER_BUILD
|
||||
|
||||
@@ -319,6 +319,7 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_lighting_model_api.c"
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_sensor_model_api.c"
|
||||
"esp_ble_mesh/api/models/esp_ble_mesh_time_scene_model_api.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_ble.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_config_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_generic_model.c"
|
||||
"esp_ble_mesh/btc/btc_ble_mesh_health_model.c"
|
||||
@@ -368,15 +369,17 @@ if(CONFIG_BT_ENABLED)
|
||||
"esp_ble_mesh/mesh_core/provisioner_prov.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_client.c"
|
||||
"esp_ble_mesh/mesh_core/proxy_server.c"
|
||||
"esp_ble_mesh/mesh_core/settings_uid.c"
|
||||
"esp_ble_mesh/mesh_core/settings.c"
|
||||
"esp_ble_mesh/mesh_core/scan.c"
|
||||
"esp_ble_mesh/mesh_core/test.c"
|
||||
"esp_ble_mesh/mesh_core/transport.c"
|
||||
"esp_ble_mesh/mesh_models/common/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/client/client_common.c"
|
||||
"esp_ble_mesh/mesh_models/client/generic_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/lighting_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/sensor_client.c"
|
||||
"esp_ble_mesh/mesh_models/client/time_scene_client.c"
|
||||
"esp_ble_mesh/mesh_models/server/device_property.c"
|
||||
"esp_ble_mesh/mesh_models/server/generic_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/lighting_server.c"
|
||||
"esp_ble_mesh/mesh_models/server/sensor_server.c"
|
||||
|
||||
+256
-102
@@ -342,21 +342,6 @@ menu Bluetooth
|
||||
If you set `BLE_ADV_REPORT_DISCARD_THRSHOLD` to a small value or printf every adv lost event, it
|
||||
may cause adv packets lost more.
|
||||
|
||||
menuconfig BTDM_COEX_BT_OPTIONS
|
||||
bool "Coexistence Bluetooth Side Options"
|
||||
depends on SW_COEXIST_ENABLE
|
||||
default n
|
||||
help
|
||||
Options of Bluetooth Side of WiFi and bluetooth coexistence.
|
||||
|
||||
config BTDM_COEX_BLE_ADV_HIGH_PRIORITY
|
||||
bool "Improve BLE ADV priority for WiFi & BLE coexistence"
|
||||
depends on BTDM_COEX_BT_OPTIONS
|
||||
default n
|
||||
help
|
||||
Improve BLE ADV coexistence priority to make it better performance.
|
||||
For example, BLE mesh need to enable this option to improve BLE adv performance.
|
||||
|
||||
endmenu
|
||||
|
||||
menuconfig BLUEDROID_ENABLED
|
||||
@@ -480,6 +465,13 @@ menu Bluetooth
|
||||
help
|
||||
This option can be disabled when the app work only on gatt client mode
|
||||
|
||||
config GATTS_BLUFI_ENABLE
|
||||
bool "Include blufi function"
|
||||
depends on GATTS_ENABLE
|
||||
default y
|
||||
help
|
||||
This option can be close when the app does not require blufi function.
|
||||
|
||||
choice GATTS_SEND_SERVICE_CHANGE_MODE
|
||||
prompt "GATTS Service Change Mode"
|
||||
default GATTS_SEND_SERVICE_CHANGE_AUTO
|
||||
@@ -1738,12 +1730,101 @@ if BLE_MESH
|
||||
option in the Bluetooth Controller section in menuconfig, which is
|
||||
"Scan Duplicate By Device Address and Advertising Data".
|
||||
|
||||
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
bool "BLE Mesh will first allocate memory from PSRAM"
|
||||
choice BLE_MESH_MEM_ALLOC_MODE
|
||||
prompt "Memory allocation strategy"
|
||||
default BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
help
|
||||
Allocation strategy for BLE Mesh stack, essentially provides ability to
|
||||
allocate all required dynamic allocations from,
|
||||
|
||||
- Internal DRAM memory only
|
||||
- External SPIRAM memory only
|
||||
- Either internal or external memory based on default malloc()
|
||||
behavior in ESP-IDF
|
||||
|
||||
Recommended mode here is always internal, since that is most preferred
|
||||
from security perspective. But if application requirement does not allow
|
||||
sufficient free internal memory then alternate mode can be selected.
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_INTERNAL
|
||||
bool "Internal DRAM"
|
||||
|
||||
config BLE_MESH_ALLOC_FROM_PSRAM_FIRST
|
||||
bool "External SPIRAM"
|
||||
depends on SPIRAM_SUPPORT
|
||||
|
||||
config BLE_MESH_MEM_ALLOC_MODE_DEFAULT
|
||||
bool "Default alloc mode"
|
||||
depends on SPIRAM_SUPPORT
|
||||
help
|
||||
Enable this option to use the default memory allocation strategy when
|
||||
external SPIRAM is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_MEM_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
bool "Enable FreeRTOS static allocation"
|
||||
depends on SUPPORT_STATIC_ALLOCATION && SPIRAM_SUPPORT
|
||||
default n
|
||||
help
|
||||
When this option is enabled, BLE Mesh stack will try to allocate memory
|
||||
from PSRAM firstly. This will save the internal RAM if PSRAM exists.
|
||||
Enable this option to use FreeRTOS static allocation APIs for BLE Mesh,
|
||||
which provides the ability to use different dynamic memory (i.e. SPIRAM)
|
||||
for FreeRTOS objects.
|
||||
If this option is disabled, the FreeRTOS static allocation APIs will not
|
||||
be used, and internal DRAM will be allocated for FreeRTOS objects.
|
||||
|
||||
choice BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
prompt "Memory allocation for FreeRTOS objects"
|
||||
depends on BLE_MESH_FREERTOS_STATIC_ALLOC
|
||||
help
|
||||
Choose the memory to be used for FreeRTOS objects.
|
||||
|
||||
config BLE_MESH_FREERTOS_STATIC_ALLOC_EXTERNAL
|
||||
bool "External SPIRAM"
|
||||
depends on SPIRAM_SUPPORT
|
||||
help
|
||||
If enabled, BLE Mesh allocates dynamic memory from external SPIRAM for
|
||||
FreeRTOS objects, i.e. mutex, queue, and task stack. External SPIRAM
|
||||
can only be used for task stack when SPIRAM_ALLOW_STACK_EXTERNAL_MEMORY
|
||||
is enabled. See the SPIRAM options for more details.
|
||||
|
||||
endchoice # BLE_MESH_FREERTOS_STATIC_ALLOC_MODE
|
||||
|
||||
config BLE_MESH_DEINIT
|
||||
bool "Support de-initialize BLE Mesh stack"
|
||||
default y
|
||||
help
|
||||
If enabled, users can use the function esp_ble_mesh_deinit() to de-initialize
|
||||
the whole BLE Mesh stack.
|
||||
|
||||
menu "BLE Mesh and BLE coexistence support"
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_ADV
|
||||
bool "Support sending normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can send normal BLE advertising packets
|
||||
with specific API.
|
||||
|
||||
if BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_BLE_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers for BLE advertising packets"
|
||||
default 3
|
||||
range 1 255
|
||||
help
|
||||
Number of advertising buffers for BLE packets available.
|
||||
|
||||
endif # BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_SCAN
|
||||
bool "Support scanning normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can register a callback and receive normal BLE
|
||||
advertising packets in the application layer.
|
||||
|
||||
endmenu # BLE Mesh and BLE coexistence support
|
||||
|
||||
config BLE_MESH_FAST_PROV
|
||||
bool "Enable BLE Mesh Fast Provisioning"
|
||||
@@ -1838,6 +1919,28 @@ if BLE_MESH
|
||||
This option specifies how many application keys the Provisioner can have.
|
||||
Indeed, this value decides the number of the application keys which can be added by a Provisioner.
|
||||
|
||||
config BLE_MESH_PROVISIONER_RECV_HB
|
||||
bool "Support receiving Heartbeat messages"
|
||||
default n
|
||||
help
|
||||
When this option is enabled, Provisioner can call specific functions to enable
|
||||
or disable receiving Heartbeat messages and notify them to the application layer.
|
||||
|
||||
if BLE_MESH_PROVISIONER_RECV_HB
|
||||
|
||||
config BLE_MESH_PROVISIONER_RECV_HB_FILTER_SIZE
|
||||
int "Maximum number of filter entries for receiving Heartbeat messages"
|
||||
default 3
|
||||
range 1 1000
|
||||
help
|
||||
This option specifies how many heartbeat filter entries Provisioner supports.
|
||||
The heartbeat filter (acceptlist or rejectlist) entries are used to store a
|
||||
list of SRC and DST which can be used to decide if a heartbeat message will
|
||||
be processed and notified to the application layer by Provisioner.
|
||||
Note: The filter is an empty rejectlist by default.
|
||||
|
||||
endif # BLE_MESH_PROVISIONER_RECV_HB
|
||||
|
||||
endif # BLE_MESH_PROVISIONER
|
||||
|
||||
# Virtual option enabled whenever Generic Provisioning layer is needed
|
||||
@@ -1857,6 +1960,19 @@ if BLE_MESH
|
||||
advertising bearer. This option should be enabled if PB-ADV is
|
||||
going to be used during provisioning procedure.
|
||||
|
||||
config BLE_MESH_UNPROVISIONED_BEACON_INTERVAL
|
||||
int "Interval between two consecutive Unprovisioned Device Beacon"
|
||||
depends on BLE_MESH_NODE && BLE_MESH_PB_ADV
|
||||
default 5
|
||||
default 3 if BLE_MESH_FAST_PROV
|
||||
range 1 100
|
||||
help
|
||||
This option specifies the interval of sending two consecutive unprovisioned
|
||||
device beacon, users can use this option to change the frequency of sending
|
||||
unprovisioned device beacon. For example, if the value is 5, it means the
|
||||
unprovisioned device beacon will send every 5 seconds. When the option of
|
||||
BLE_MESH_FAST_PROV is selected, the value is better to be 3 seconds, or less.
|
||||
|
||||
config BLE_MESH_PB_GATT
|
||||
bool "Provisioning support using GATT (PB-GATT)"
|
||||
select BLE_MESH_PROXY
|
||||
@@ -1919,7 +2035,7 @@ if BLE_MESH
|
||||
advertising bearer.
|
||||
|
||||
config BLE_MESH_NET_BUF_POOL_USAGE
|
||||
bool "BLE Mesh net buffer pool usage tracking"
|
||||
bool
|
||||
default y
|
||||
help
|
||||
Enable BLE Mesh net buffer pool tracking. This option is used to introduce another
|
||||
@@ -1941,28 +2057,6 @@ if BLE_MESH
|
||||
|
||||
if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SPECIFIC_PARTITION
|
||||
bool "Use a specific NVS partition for BLE Mesh"
|
||||
default n
|
||||
help
|
||||
When selected, the mesh stack will use a specified NVS partition instead of
|
||||
default NVS partition. Note that the specified partition must be registered
|
||||
with NVS using nvs_flash_init_partition() API, and the partition must exists
|
||||
in the csv file.
|
||||
When Provisioner needs to store a large amount of nodes' information in the
|
||||
flash (e.g. more than 20), this option is recommended to be enabled.
|
||||
|
||||
if BLE_MESH_SPECIFIC_PARTITION
|
||||
|
||||
config BLE_MESH_PARTITION_NAME
|
||||
string "Name of the NVS partition for BLE Mesh"
|
||||
default "ble_mesh"
|
||||
help
|
||||
This value defines the name of the specified NVS partition used by the
|
||||
mesh stack.
|
||||
|
||||
endif # BLE_MESH_SPECIFIC_PARTITION
|
||||
|
||||
config BLE_MESH_STORE_TIMEOUT
|
||||
int "Delay (in seconds) before storing anything persistently"
|
||||
range 0 1000000
|
||||
@@ -1977,7 +2071,7 @@ if BLE_MESH
|
||||
config BLE_MESH_SEQ_STORE_RATE
|
||||
int "How often the sequence number gets updated in storage"
|
||||
range 0 1000000
|
||||
default 6
|
||||
default 0
|
||||
help
|
||||
This value defines how often the local sequence number gets updated in
|
||||
persistent storage (i.e. flash). e.g. a value of 100 means that the
|
||||
@@ -1992,7 +2086,7 @@ if BLE_MESH
|
||||
config BLE_MESH_RPL_STORE_TIMEOUT
|
||||
int "Minimum frequency that the RPL gets updated in storage"
|
||||
range 0 1000000
|
||||
default 5
|
||||
default 0
|
||||
help
|
||||
This value defines in seconds how soon the RPL (Replay Protection List)
|
||||
gets written to persistent storage after a change occurs. If the node
|
||||
@@ -2028,6 +2122,50 @@ if BLE_MESH
|
||||
in advance before recovering node information and make sure the node
|
||||
information recovering could work as expected.
|
||||
|
||||
config BLE_MESH_SPECIFIC_PARTITION
|
||||
bool "Use a specific NVS partition for BLE Mesh"
|
||||
default n
|
||||
help
|
||||
When selected, the mesh stack will use a specified NVS partition instead of
|
||||
default NVS partition. Note that the specified partition must be registered
|
||||
with NVS using nvs_flash_init_partition() API, and the partition must exists
|
||||
in the csv file.
|
||||
When Provisioner needs to store a large amount of nodes' information in the
|
||||
flash (e.g. more than 20), this option is recommended to be enabled.
|
||||
|
||||
config BLE_MESH_PARTITION_NAME
|
||||
string "Name of the NVS partition for BLE Mesh"
|
||||
depends on BLE_MESH_SPECIFIC_PARTITION
|
||||
default "ble_mesh"
|
||||
help
|
||||
This value defines the name of the specified NVS partition used by the
|
||||
mesh stack.
|
||||
|
||||
config BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
bool "Support using multiple NVS namespaces by Provisioner"
|
||||
depends on BLE_MESH_PROVISIONER
|
||||
default n
|
||||
help
|
||||
When selected, Provisioner can use different NVS namespaces to store
|
||||
different instances of mesh information.
|
||||
For example, if in the first room, Provisioner uses NetKey A, AppKey
|
||||
A and provisions three devices, these information will be treated as
|
||||
mesh information instance A. When the Provisioner moves to the second
|
||||
room, it uses NetKey B, AppKey B and provisions two devices, then the
|
||||
information will be treated as mesh information instance B.
|
||||
Here instance A and instance B will be stored in different namespaces.
|
||||
With this option enabled, Provisioner needs to use specific functions
|
||||
to open the corresponding NVS namespace, restore the mesh information,
|
||||
release the mesh information or erase the mesh information.
|
||||
|
||||
config BLE_MESH_MAX_NVS_NAMESPACE
|
||||
int "Maximum number of NVS namespaces"
|
||||
depends on BLE_MESH_USE_MULTIPLE_NAMESPACE
|
||||
default 2
|
||||
range 1 255
|
||||
help
|
||||
This option specifies the maximum NVS namespaces supported by Provisioner.
|
||||
|
||||
endif # if BLE_MESH_SETTINGS
|
||||
|
||||
config BLE_MESH_SUBNET_COUNT
|
||||
@@ -2109,24 +2247,6 @@ if BLE_MESH
|
||||
SDU size is 60 bytes, which leaves 56 bytes for application layer data
|
||||
using a 4-byte MIC, or 52 bytes using an 8-byte MIC.
|
||||
|
||||
config BLE_MESH_SUPPORT_BLE_ADV
|
||||
bool "Support sending normal BLE advertising packets"
|
||||
default n
|
||||
help
|
||||
When selected, users can send normal BLE advertising packets
|
||||
with specific API.
|
||||
|
||||
if BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_BLE_ADV_BUF_COUNT
|
||||
int "Number of advertising buffers for BLE advertising packets"
|
||||
default 3
|
||||
range 1 255
|
||||
help
|
||||
Number of advertising buffers for BLE packets available.
|
||||
|
||||
endif # BLE_MESH_SUPPORT_BLE_ADV
|
||||
|
||||
config BLE_MESH_IVU_DIVIDER
|
||||
int "Divider for IV Update state refresh timer"
|
||||
default 4
|
||||
@@ -2521,104 +2641,138 @@ if BLE_MESH
|
||||
uses 0 as the timeout value when sending acknowledged messages, then
|
||||
the default value will be used which is four seconds.
|
||||
|
||||
menu "Support for BLE Mesh Client Models"
|
||||
menu "Support for BLE Mesh Foundation models"
|
||||
|
||||
config BLE_MESH_CFG_CLI
|
||||
bool "Configuration Client Model"
|
||||
bool "Configuration Client model"
|
||||
help
|
||||
Enable support for Configuration client model.
|
||||
Enable support for Configuration Client model.
|
||||
|
||||
config BLE_MESH_HEALTH_CLI
|
||||
bool "Health Client Model"
|
||||
bool "Health Client model"
|
||||
help
|
||||
Enable support for Health client model.
|
||||
Enable support for Health Client model.
|
||||
|
||||
config BLE_MESH_HEALTH_SRV
|
||||
bool "Health Server model"
|
||||
default y
|
||||
help
|
||||
Enable support for Health Server model.
|
||||
|
||||
endmenu #Support for BLE Mesh Foundation models
|
||||
|
||||
menu "Support for BLE Mesh Client/Server models"
|
||||
|
||||
config BLE_MESH_GENERIC_ONOFF_CLI
|
||||
bool "Generic OnOff Client Model"
|
||||
bool "Generic OnOff Client model"
|
||||
help
|
||||
Enable support for Generic OnOff client model.
|
||||
Enable support for Generic OnOff Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_LEVEL_CLI
|
||||
bool "Generic Level Client Model"
|
||||
bool "Generic Level Client model"
|
||||
help
|
||||
Enable support for Generic Level client model.
|
||||
Enable support for Generic Level Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_DEF_TRANS_TIME_CLI
|
||||
bool "Generic Default Transition Time Client Model"
|
||||
bool "Generic Default Transition Time Client model"
|
||||
help
|
||||
Enable support for Generic Default Transition Time client model.
|
||||
Enable support for Generic Default Transition Time Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_POWER_ONOFF_CLI
|
||||
bool "Generic Power OnOff Client Model"
|
||||
bool "Generic Power OnOff Client model"
|
||||
help
|
||||
Enable support for Generic Power OnOff client model.
|
||||
Enable support for Generic Power OnOff Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_POWER_LEVEL_CLI
|
||||
bool "Generic Power Level Client Model"
|
||||
bool "Generic Power Level Client model"
|
||||
help
|
||||
Enable support for Generic Power Level client model.
|
||||
Enable support for Generic Power Level Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_BATTERY_CLI
|
||||
bool "Generic Battery Client Model"
|
||||
bool "Generic Battery Client model"
|
||||
help
|
||||
Enable support for Generic Battery client model.
|
||||
Enable support for Generic Battery Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_LOCATION_CLI
|
||||
bool "Generic Location Client Model"
|
||||
bool "Generic Location Client model"
|
||||
help
|
||||
Enable support for Generic Location client model.
|
||||
Enable support for Generic Location Client model.
|
||||
|
||||
config BLE_MESH_GENERIC_PROPERTY_CLI
|
||||
bool "Generic Property Client Model"
|
||||
bool "Generic Property Client model"
|
||||
help
|
||||
Enable support for Generic Property client model.
|
||||
Enable support for Generic Property Client model.
|
||||
|
||||
config BLE_MESH_SENSOR_CLI
|
||||
bool "Sensor Client Model"
|
||||
bool "Sensor Client model"
|
||||
help
|
||||
Enable support for Sensor client model.
|
||||
Enable support for Sensor Client model.
|
||||
|
||||
config BLE_MESH_TIME_CLI
|
||||
bool "Time Client Model"
|
||||
bool "Time Client model"
|
||||
help
|
||||
Enable support for Time client model.
|
||||
Enable support for Time Client model.
|
||||
|
||||
config BLE_MESH_SCENE_CLI
|
||||
bool "Scene Client Model"
|
||||
bool "Scene Client model"
|
||||
help
|
||||
Enable support for Scene client model.
|
||||
Enable support for Scene Client model.
|
||||
|
||||
config BLE_MESH_SCHEDULER_CLI
|
||||
bool "Scheduler Client Model"
|
||||
bool "Scheduler Client model"
|
||||
help
|
||||
Enable support for Scheduler client model.
|
||||
Enable support for Scheduler Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_LIGHTNESS_CLI
|
||||
bool "Light Lightness Client Model"
|
||||
bool "Light Lightness Client model"
|
||||
help
|
||||
Enable support for Light Lightness client model.
|
||||
Enable support for Light Lightness Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_CTL_CLI
|
||||
bool "Light CTL Client Model"
|
||||
bool "Light CTL Client model"
|
||||
help
|
||||
Enable support for Light CTL client model.
|
||||
Enable support for Light CTL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_HSL_CLI
|
||||
bool "Light HSL Client Model"
|
||||
bool "Light HSL Client model"
|
||||
help
|
||||
Enable support for Light HSL client model.
|
||||
Enable support for Light HSL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_XYL_CLI
|
||||
bool "Light XYL Client Model"
|
||||
bool "Light XYL Client model"
|
||||
help
|
||||
Enable support for Light XYL client model.
|
||||
Enable support for Light XYL Client model.
|
||||
|
||||
config BLE_MESH_LIGHT_LC_CLI
|
||||
bool "Light LC Client Model"
|
||||
bool "Light LC Client model"
|
||||
help
|
||||
Enable support for Light LC client model.
|
||||
Enable support for Light LC Client model.
|
||||
|
||||
endmenu
|
||||
config BLE_MESH_GENERIC_SERVER
|
||||
bool "Generic server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Generic server models.
|
||||
|
||||
config BLE_MESH_SENSOR_SERVER
|
||||
bool "Sensor server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Sensor server models.
|
||||
|
||||
config BLE_MESH_TIME_SCENE_SERVER
|
||||
bool "Time and Scenes server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Time and Scenes server models.
|
||||
|
||||
config BLE_MESH_LIGHTING_SERVER
|
||||
bool "Lighting server models"
|
||||
default y
|
||||
help
|
||||
Enable support for Lighting server models.
|
||||
|
||||
endmenu #Support for BLE Mesh Client/Server models
|
||||
|
||||
config BLE_MESH_IV_UPDATE_TEST
|
||||
bool "Test the IV Update Procedure"
|
||||
|
||||
@@ -29,6 +29,10 @@ esp_err_t esp_a2d_sink_init(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_init || g_a2dp_sink_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -46,6 +50,10 @@ esp_err_t esp_a2d_sink_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -63,6 +71,10 @@ esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_sink_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
@@ -83,6 +95,10 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
@@ -105,15 +121,21 @@ esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_msg_t msg;
|
||||
btc_av_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SINK_API_DISCONNECT_EVT;
|
||||
|
||||
/* Switch to BTC context */
|
||||
stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
memcpy(&(arg.disconn), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -125,6 +147,10 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_sink_ongoing_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (callback == NULL) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
@@ -139,6 +165,10 @@ esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
@@ -162,6 +192,10 @@ esp_err_t esp_a2d_source_init(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_init || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -179,6 +213,10 @@ esp_err_t esp_a2d_source_deinit(void)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
@@ -196,6 +234,10 @@ esp_err_t esp_a2d_source_connect(esp_bd_addr_t remote_bda)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
@@ -218,15 +260,23 @@ esp_err_t esp_a2d_source_disconnect(esp_bd_addr_t remote_bda)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
bt_status_t stat;
|
||||
btc_av_args_t arg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
msg.act = BTC_AV_SRC_API_DISCONNECT_EVT;
|
||||
|
||||
memset(&arg, 0, sizeof(btc_av_args_t));
|
||||
|
||||
/* Switch to BTC context */
|
||||
stat = btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
memcpy(&(arg.src_disconn), remote_bda, sizeof(bt_bdaddr_t));
|
||||
stat = btc_transfer_context(&msg, &arg, sizeof(btc_av_args_t), NULL);
|
||||
return (stat == BT_STATUS_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
@@ -236,6 +286,10 @@ esp_err_t esp_a2d_source_register_data_callback(esp_a2d_source_data_cb_t callbac
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
if (g_a2dp_source_ongoing_deinit) {
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_A2DP;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "osi/future.h"
|
||||
#include "btc_gatts.h"
|
||||
#include "btc_gatt_util.h"
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
esp_err_t esp_blufi_register_callbacks(esp_blufi_callbacks_t *callbacks)
|
||||
{
|
||||
if (esp_bluedroid_get_status() == ESP_BLUEDROID_STATUS_UNINITIALIZED) {
|
||||
@@ -162,3 +162,4 @@ esp_err_t esp_blufi_send_custom_data(uint8_t *data, uint32_t data_len)
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), btc_blufi_call_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
@@ -30,7 +30,7 @@ const uint8_t *esp_bt_dev_get_address(void)
|
||||
|
||||
esp_err_t esp_bt_dev_set_device_name(const char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_dev_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
|
||||
@@ -117,6 +117,7 @@ esp_err_t esp_bluedroid_init(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
bt_status_t ret;
|
||||
|
||||
if (esp_bt_controller_get_status() != ESP_BT_CONTROLLER_STATUS_ENABLED) {
|
||||
LOG_ERROR("Controller not initialised\n");
|
||||
@@ -135,23 +136,30 @@ esp_err_t esp_bluedroid_init(void)
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_INIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("Bluedroid initialise failed\n");
|
||||
LOG_ERROR("Bluedroid Initialize Fail!");
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
btc_init();
|
||||
/*
|
||||
* BTC Init
|
||||
*/
|
||||
ret = btc_init();
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid Initialize Fail");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_INIT;
|
||||
|
||||
if (btc_transfer_context(&msg, NULL, 0, NULL) != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("Bluedroid initialise failed\n");
|
||||
LOG_ERROR("Bluedroid Initialize Fail!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("Bluedroid initialise failed\n");
|
||||
LOG_ERROR("Bluedroid Initialize Fail!");
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ esp_err_t esp_ble_gap_register_callback(esp_gap_ble_cb_t callback)
|
||||
|
||||
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -58,7 +58,7 @@ esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
|
||||
esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -77,7 +77,7 @@ esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
|
||||
|
||||
esp_err_t esp_ble_gap_start_scanning(uint32_t duration)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -93,7 +93,7 @@ esp_err_t esp_ble_gap_start_scanning(uint32_t duration)
|
||||
|
||||
esp_err_t esp_ble_gap_stop_scanning(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -105,7 +105,7 @@ esp_err_t esp_ble_gap_stop_scanning(void)
|
||||
|
||||
esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -120,7 +120,7 @@ esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
|
||||
|
||||
esp_err_t esp_ble_gap_stop_advertising(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -134,22 +134,37 @@ esp_err_t esp_ble_gap_stop_advertising(void)
|
||||
|
||||
esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
if(!params) {
|
||||
LOG_ERROR("%s,params is NULL", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
if (ESP_BLE_IS_VALID_PARAM(params->min_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
|
||||
ESP_BLE_IS_VALID_PARAM(params->max_int, ESP_BLE_CONN_INT_MIN, ESP_BLE_CONN_INT_MAX) &&
|
||||
ESP_BLE_IS_VALID_PARAM(params->timeout, ESP_BLE_CONN_SUP_TOUT_MIN, ESP_BLE_CONN_SUP_TOUT_MAX) &&
|
||||
(params->latency <= ESP_BLE_CONN_LATENCY_MAX || params->latency == ESP_BLE_CONN_PARAM_UNDEF) &&
|
||||
((params->timeout * 10) >= ((1 + params->latency) * ((params->max_int * 5) >> 1))) && params->min_int <= params->max_int) {
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
} else {
|
||||
LOG_ERROR("%s,invalid connection params:min_int = %d, max_int = %d, latency = %d, timeout = %d",\
|
||||
__func__, params->min_int, params->max_int, params->latency, params->timeout);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -166,7 +181,7 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -181,7 +196,7 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
|
||||
esp_err_t esp_ble_gap_clear_rand_addr(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -194,7 +209,7 @@ esp_err_t esp_ble_gap_clear_rand_addr(void)
|
||||
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -210,7 +225,7 @@ esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
{
|
||||
esp_err_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -289,7 +304,7 @@ esp_err_t esp_ble_gap_config_local_icon (uint16_t icon)
|
||||
|
||||
esp_err_t esp_ble_gap_update_whitelist(bool add_remove, esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -322,7 +337,7 @@ esp_err_t esp_ble_gap_set_prefer_conn_params(esp_bd_addr_t bd_addr,
|
||||
uint16_t min_conn_int, uint16_t max_conn_int,
|
||||
uint16_t slave_latency, uint16_t supervision_tout)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -390,7 +405,7 @@ uint8_t *esp_ble_resolve_adv_data( uint8_t *adv_data, uint8_t type, uint8_t *len
|
||||
|
||||
esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -412,7 +427,7 @@ esp_err_t esp_ble_gap_config_adv_data_raw(uint8_t *raw_data, uint32_t raw_data_l
|
||||
|
||||
esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -429,7 +444,7 @@ esp_err_t esp_ble_gap_read_rssi(esp_bd_addr_t remote_addr)
|
||||
|
||||
esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_data_len)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -451,7 +466,7 @@ esp_err_t esp_ble_gap_config_scan_rsp_data_raw(uint8_t *raw_data, uint32_t raw_d
|
||||
|
||||
esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -475,7 +490,7 @@ esp_err_t esp_ble_gap_add_duplicate_scan_exceptional_device(esp_ble_duplicate_ex
|
||||
|
||||
esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate_exceptional_info_type_t type, esp_duplicate_info_t device_info)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -499,7 +514,7 @@ esp_err_t esp_ble_gap_remove_duplicate_scan_exceptional_device(esp_ble_duplicate
|
||||
|
||||
esp_err_t esp_ble_gap_clean_duplicate_scan_exceptional_list(esp_duplicate_scan_exceptional_list_type_t list_type)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
@@ -537,7 +552,7 @@ esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
||||
}
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -555,7 +570,7 @@ esp_err_t esp_ble_gap_set_security_param(esp_ble_sm_param_t param_type,
|
||||
|
||||
esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_act)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -572,7 +587,7 @@ esp_err_t esp_ble_set_encryption(esp_bd_addr_t bd_addr, esp_ble_sec_act_t sec_ac
|
||||
|
||||
esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -590,7 +605,7 @@ esp_err_t esp_ble_gap_security_rsp(esp_bd_addr_t bd_addr, bool accept)
|
||||
|
||||
esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t passkey)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -608,7 +623,7 @@ esp_err_t esp_ble_passkey_reply(esp_bd_addr_t bd_addr, bool accept, uint32_t pas
|
||||
|
||||
esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -625,7 +640,7 @@ esp_err_t esp_ble_confirm_reply(esp_bd_addr_t bd_addr, bool accept)
|
||||
|
||||
esp_err_t esp_ble_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -672,7 +687,7 @@ esp_err_t esp_ble_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t *TK, uint8_t len)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -692,7 +707,7 @@ esp_err_t esp_ble_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t *TK, uint8_t len)
|
||||
|
||||
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -705,6 +720,27 @@ esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device)
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize)
|
||||
{
|
||||
if (!bd_addr) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (BTM_Ble_Authorization(bd_addr, authorize)) {
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_FAIL;
|
||||
}
|
||||
esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_params_t *conn_params)
|
||||
{
|
||||
if(!bd_addr || !conn_params) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if(BTM_GetCurrentConnParams(bd_addr, &conn_params->interval, &conn_params->latency, &conn_params->timeout)) {
|
||||
return ESP_OK;
|
||||
}
|
||||
return ESP_ERR_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -213,7 +213,7 @@ esp_err_t esp_bt_gap_remove_bond_device(esp_bd_addr_t bd_addr)
|
||||
int esp_bt_gap_get_bond_device_num(void)
|
||||
{
|
||||
if (esp_bluedroid_get_status() != ESP_BLUEDROID_STATUS_ENABLED) {
|
||||
return ESP_FAIL;
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
return btc_storage_get_num_bt_bond_devices();
|
||||
}
|
||||
@@ -221,7 +221,6 @@ int esp_bt_gap_get_bond_device_num(void)
|
||||
esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
{
|
||||
int ret;
|
||||
int dev_num_total;
|
||||
|
||||
if (dev_num == NULL || dev_list == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
@@ -231,12 +230,7 @@ esp_err_t esp_bt_gap_get_bond_device_list(int *dev_num, esp_bd_addr_t *dev_list)
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
dev_num_total = btc_storage_get_num_bt_bond_devices();
|
||||
if (*dev_num > dev_num_total) {
|
||||
*dev_num = dev_num_total;
|
||||
}
|
||||
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, *dev_num);
|
||||
ret = btc_storage_get_bonded_bt_devices_list((bt_bdaddr_t *)dev_list, dev_num);
|
||||
|
||||
return (ret == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
*/
|
||||
esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatt_com_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -50,9 +50,33 @@ esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu)
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern uint16_t L2CA_GetFreePktBufferNum_LE(void);
|
||||
/**
|
||||
* @brief This function is called to get currently sendable packets number on controller,
|
||||
* the function is called only in BLE running core and single connection now.
|
||||
*
|
||||
* @return
|
||||
* sendable packets number on controller
|
||||
*
|
||||
*/
|
||||
|
||||
uint16_t esp_ble_get_sendable_packets_num ()
|
||||
uint16_t esp_ble_get_sendable_packets_num (void)
|
||||
{
|
||||
return L2CA_GetFreePktBufferNum_LE();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function is used to query the number of available buffers for the current connection.
|
||||
* When you need to query the current available buffer number, it is recommended to use this API.
|
||||
* @param[in] conn_id: current connection id.
|
||||
*
|
||||
* @return
|
||||
* Number of available buffers for the current connection
|
||||
*
|
||||
*/
|
||||
extern UINT16 L2CA_GetCurFreePktBufferNum_LE(UINT16 conn_id);
|
||||
uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid)
|
||||
{
|
||||
return L2CA_GetCurFreePktBufferNum_LE(connid);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -38,7 +38,7 @@ esp_err_t esp_ble_gattc_register_callback(esp_gattc_cb_t callback)
|
||||
|
||||
esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -57,7 +57,7 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
|
||||
esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -72,7 +72,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gattc_if)
|
||||
|
||||
esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, esp_ble_addr_type_t remote_addr_type, bool is_direct)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -90,7 +90,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gattc_if, esp_bd_addr_t remote_bda, e
|
||||
|
||||
esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -105,7 +105,7 @@ esp_err_t esp_ble_gattc_close (esp_gatt_if_t gattc_if, uint16_t conn_id)
|
||||
|
||||
esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -120,7 +120,7 @@ esp_err_t esp_ble_gattc_send_mtu_req (esp_gatt_if_t gattc_if, uint16_t conn_id)
|
||||
|
||||
esp_err_t esp_ble_gattc_search_service(esp_gatt_if_t gattc_if, uint16_t conn_id, esp_bt_uuid_t *filter_uuid)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -330,7 +330,7 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id, uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -350,11 +350,44 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t *uuid,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (uuid == NULL) {
|
||||
return ESP_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
if (L2CA_CheckIsCongest(L2CAP_ATT_CID, conn_id)) {
|
||||
LOG_DEBUG("%s, the l2cap chanel is congest.", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_READ_BY_TYPE;
|
||||
arg.read_by_type.conn_id = BTC_GATT_CREATE_CONN_ID(gattc_if, conn_id);
|
||||
arg.read_by_type.s_handle = start_handle;
|
||||
arg.read_by_type.e_handle = end_handle;
|
||||
arg.read_by_type.auth_req = auth_req;
|
||||
memcpy(&(arg.read_by_type.uuid), uuid, sizeof(esp_bt_uuid_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gattc_read_multiple(esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id, esp_gattc_multi_t *read_multi,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -385,7 +418,7 @@ esp_err_t esp_ble_gattc_read_char_descr (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id, uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -412,7 +445,7 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -431,6 +464,9 @@ esp_err_t esp_ble_gattc_write_char(esp_gatt_if_t gattc_if,
|
||||
arg.write_char.value = value;
|
||||
arg.write_char.write_type = write_type;
|
||||
arg.write_char.auth_req = auth_req;
|
||||
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@@ -442,7 +478,7 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
esp_gatt_write_type_t write_type,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -462,6 +498,10 @@ esp_err_t esp_ble_gattc_write_char_descr (esp_gatt_if_t gattc_if,
|
||||
arg.write_descr.write_type = write_type;
|
||||
arg.write_descr.auth_req = auth_req;
|
||||
|
||||
if(write_type == ESP_GATT_WRITE_TYPE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), btc_gattc_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@@ -472,7 +512,7 @@ esp_err_t esp_ble_gattc_prepare_write(esp_gatt_if_t gattc_if,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -502,7 +542,7 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -527,7 +567,7 @@ esp_err_t esp_ble_gattc_prepare_write_char_descr(esp_gatt_if_t gattc_if,
|
||||
|
||||
esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id, bool is_execute)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -544,7 +584,7 @@ esp_err_t esp_ble_gattc_execute_write (esp_gatt_if_t gattc_if, uint16_t conn_id,
|
||||
esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda, uint16_t handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -562,7 +602,7 @@ esp_err_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
esp_bd_addr_t server_bda, uint16_t handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -578,7 +618,7 @@ esp_err_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gattc_if,
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -593,7 +633,7 @@ esp_err_t esp_ble_gattc_cache_refresh(esp_bd_addr_t remote_bda)
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_addr, esp_bd_addr_t assoc_addr, bool is_assoc)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -611,7 +651,7 @@ esp_err_t esp_ble_gattc_cache_assoc(esp_gatt_if_t gattc_if, esp_bd_addr_t src_ad
|
||||
|
||||
esp_err_t esp_ble_gattc_cache_get_addr_list(esp_gatt_if_t gattc_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -38,7 +38,7 @@ esp_err_t esp_ble_gatts_register_callback(esp_gatts_cb_t callback)
|
||||
|
||||
esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -59,7 +59,7 @@ esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
|
||||
|
||||
esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -75,7 +75,7 @@ esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatts_if)
|
||||
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatts_if,
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -95,7 +95,7 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
||||
uint8_t max_nb_attr,
|
||||
uint8_t srvc_inst_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -115,7 +115,7 @@ esp_err_t esp_ble_gatts_create_attr_tab(const esp_gatts_attr_db_t *gatts_attr_db
|
||||
|
||||
esp_err_t esp_ble_gatts_add_included_service(uint16_t service_handle, uint16_t included_service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -134,7 +134,7 @@ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property, esp_attr_value_t *char_val,
|
||||
esp_attr_control_t *control)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
esp_err_t status;
|
||||
|
||||
@@ -173,7 +173,7 @@ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
esp_gatt_perm_t perm, esp_attr_value_t *char_descr_val,
|
||||
esp_attr_control_t *control)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
esp_err_t status;
|
||||
|
||||
@@ -208,7 +208,7 @@ esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
|
||||
esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -223,7 +223,7 @@ esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle)
|
||||
|
||||
esp_err_t esp_ble_gatts_start_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -238,7 +238,7 @@ esp_err_t esp_ble_gatts_start_service(uint16_t service_handle)
|
||||
|
||||
esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -255,7 +255,7 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
|
||||
esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id, uint16_t attr_handle,
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -274,6 +274,9 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
arg.send_ind.value_len = value_len;
|
||||
arg.send_ind.value = value;
|
||||
|
||||
if(need_confirm == false){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTC_NUM, NULL);
|
||||
}
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t),
|
||||
btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
@@ -281,7 +284,7 @@ esp_err_t esp_ble_gatts_send_indicate(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -300,7 +303,7 @@ esp_err_t esp_ble_gatts_send_response(esp_gatt_if_t gatts_if, uint16_t conn_id,
|
||||
|
||||
esp_err_t esp_ble_gatts_set_attr_value(uint16_t attr_handle, uint16_t length, const uint8_t *value)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -330,7 +333,7 @@ esp_gatt_status_t esp_ble_gatts_get_attr_value(uint16_t attr_handle, uint16_t *l
|
||||
|
||||
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, bool is_direct)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -348,7 +351,7 @@ esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda, b
|
||||
|
||||
esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
@@ -364,7 +367,7 @@ esp_err_t esp_ble_gatts_close(esp_gatt_if_t gatts_if, uint16_t conn_id)
|
||||
|
||||
esp_err_t esp_ble_gatts_send_service_change_indication(esp_gatt_if_t gatts_if, esp_bd_addr_t remote_bda)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
@@ -133,7 +133,8 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if (strlen(name) > ESP_SPP_SERVER_NAME_MAX) {
|
||||
if (name == NULL || strlen(name) > ESP_SPP_SERVER_NAME_MAX) {
|
||||
LOG_ERROR("Invalid server name!\n");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
@@ -154,6 +155,38 @@ esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_stop_srv(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_STOP_SRV;
|
||||
arg.stop_srv.scn = BTC_SPP_INVALID_SCN;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_stop_srv_scn(uint8_t scn)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_spp_args_t arg;
|
||||
ESP_BLUEDROID_STATUS_CHECK(ESP_BLUEDROID_STATUS_ENABLED);
|
||||
|
||||
if ((scn == 0) || (scn >= PORT_MAX_RFC_PORTS)) {
|
||||
LOG_ERROR("Invalid SCN!\n");
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_SPP;
|
||||
msg.act = BTC_SPP_ACT_STOP_SRV;
|
||||
arg.stop_srv.scn = scn;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_spp_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_spp_write(uint32_t handle, int len, uint8_t *p_data)
|
||||
{
|
||||
|
||||
@@ -46,6 +46,12 @@ typedef struct {
|
||||
} cie; /*!< A2DP codec information element */
|
||||
} __attribute__((packed)) esp_a2d_mcc_t;
|
||||
|
||||
/// Bluetooth A2DP Initiation states
|
||||
typedef enum {
|
||||
ESP_A2D_DEINIT_SUCCESS = 0, /*!< A2DP profile deinit successful event */
|
||||
ESP_A2D_INIT_SUCCESS /*!< A2DP profile init successful event */
|
||||
} esp_a2d_init_state_t;
|
||||
|
||||
/// Bluetooth A2DP connection states
|
||||
typedef enum {
|
||||
ESP_A2D_CONNECTION_STATE_DISCONNECTED = 0, /*!< connection released */
|
||||
@@ -76,7 +82,7 @@ typedef enum {
|
||||
|
||||
/// A2DP media control commands
|
||||
typedef enum {
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< dummy command */
|
||||
ESP_A2D_MEDIA_CTRL_NONE = 0, /*!< Not for application use, use inside stack only. */
|
||||
ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY, /*!< check whether AVDTP is connected, only used in A2DP source */
|
||||
ESP_A2D_MEDIA_CTRL_START, /*!< command to set up media transmission channel */
|
||||
ESP_A2D_MEDIA_CTRL_STOP, /*!< command to stop media transmission */
|
||||
@@ -89,6 +95,7 @@ typedef enum {
|
||||
ESP_A2D_AUDIO_STATE_EVT, /*!< audio stream transmission state changed event */
|
||||
ESP_A2D_AUDIO_CFG_EVT, /*!< audio codec is configured, only used for A2DP SINK */
|
||||
ESP_A2D_MEDIA_CTRL_ACK_EVT, /*!< acknowledge event in response to media control commands */
|
||||
ESP_A2D_PROF_STATE_EVT, /*!< indicate a2dp deinit complete */
|
||||
} esp_a2d_cb_event_t;
|
||||
|
||||
/// A2DP state callback parameters
|
||||
@@ -125,6 +132,13 @@ typedef union {
|
||||
esp_a2d_media_ctrl_t cmd; /*!< media control commands to acknowledge */
|
||||
esp_a2d_media_ctrl_ack_t status; /*!< acknowledgement to media control commands */
|
||||
} media_ctrl_stat; /*!< status in acknowledgement to media control commands */
|
||||
|
||||
/**
|
||||
* @brief ESP_A2D_PROF_STATE_EVT
|
||||
*/
|
||||
struct a2d_prof_stat_param {
|
||||
esp_a2d_init_state_t init_state; /*!< a2dp profile state param */
|
||||
} a2d_prof_stat; /*!< status to indicate a2d prof init or deinit */
|
||||
} esp_a2d_cb_param_t;
|
||||
|
||||
/**
|
||||
@@ -193,7 +207,8 @@ esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback);
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth A2DP sink module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
* after esp_bluedroid_enable() completes successfully, and ESP_A2D_PROF_STATE_EVT
|
||||
* with ESP_A2D_INIT_SUCCESS will reported to the APP layer
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
@@ -207,7 +222,8 @@ esp_err_t esp_a2d_sink_init(void);
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP sink module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
* should be called only after esp_bluedroid_enable() completes successfully,
|
||||
* and ESP_A2D_PROF_STATE_EVT with ESP_A2D_DEINIT_SUCCESS will reported to APP layer.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
@@ -264,7 +280,8 @@ esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl);
|
||||
/**
|
||||
*
|
||||
* @brief Initialize the bluetooth A2DP source module. This function should be called
|
||||
* after esp_bluedroid_enable() completes successfully
|
||||
* after esp_bluedroid_enable() completes successfully, and ESP_A2D_PROF_STATE_EVT
|
||||
* with ESP_A2D_INIT_SUCCESS will reported to the APP layer
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: if the initialization request is sent successfully
|
||||
@@ -278,7 +295,8 @@ esp_err_t esp_a2d_source_init(void);
|
||||
/**
|
||||
*
|
||||
* @brief De-initialize for A2DP source module. This function
|
||||
* should be called only after esp_bluedroid_enable() completes successfully
|
||||
* should be called only after esp_bluedroid_enable() completes successfully,
|
||||
* and ESP_A2D_PROF_STATE_EVT with ESP_A2D_DEINIT_SUCCESS will reported to APP layer.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
|
||||
@@ -301,6 +301,7 @@ typedef void (* esp_blufi_event_cb_t)(esp_blufi_cb_event_t event, esp_blufi_cb_p
|
||||
* @param len : length of data from phone
|
||||
* @param output_data : data want to send to phone
|
||||
* @param output_len : length of data want to send to phone
|
||||
* @param need_free : output reporting if memory needs to be freed or not *
|
||||
*/
|
||||
typedef void (*esp_blufi_negotiate_data_handler_t)(uint8_t *data, int len, uint8_t **output_data, int *output_len, bool *need_free);
|
||||
|
||||
@@ -311,7 +312,7 @@ typedef void (*esp_blufi_negotiate_data_handler_t)(uint8_t *data, int len, uint8
|
||||
* @param crypt_len : length of plain text
|
||||
* @return Nonnegative number is encrypted length, if error, return negative number;
|
||||
*/
|
||||
typedef int (* esp_blufi_encrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int cyprt_len);
|
||||
typedef int (* esp_blufi_encrypt_func_t)(uint8_t iv8, uint8_t *crypt_data, int crypt_len);
|
||||
|
||||
/**
|
||||
* @brief BLUFI decrypt the data after negotiate a share key
|
||||
|
||||
@@ -69,7 +69,7 @@ typedef uint8_t esp_link_key[ESP_BT_OCTET16_LEN]; /* Link Key */
|
||||
|
||||
#define ESP_BLE_CONN_INT_MIN 0x0006 /*!< relate to BTM_BLE_CONN_INT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_INT_MAX 0x0C80 /*!< relate to BTM_BLE_CONN_INT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 500 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_LATENCY_MAX 499 /*!< relate to ESP_BLE_CONN_LATENCY_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MIN 0x000A /*!< relate to BTM_BLE_CONN_SUP_TOUT_MIN in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_SUP_TOUT_MAX 0x0C80 /*!< relate to ESP_BLE_CONN_SUP_TOUT_MAX in stack/btm_ble_api.h */
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */ /* relate to ESP_BLE_CONN_PARAM_UNDEF in stack/btm_ble_api.h */
|
||||
|
||||
@@ -287,6 +287,8 @@ typedef enum {
|
||||
ESP_BLE_SM_ONLY_ACCEPT_SPECIFIED_SEC_AUTH,
|
||||
/* Enable/Disable OOB support */
|
||||
ESP_BLE_SM_OOB_SUPPORT,
|
||||
/* Appl encryption key size */
|
||||
ESP_BLE_APP_ENC_KEY_SIZE,
|
||||
ESP_BLE_SM_MAX_PARAM,
|
||||
} esp_ble_sm_param_t;
|
||||
|
||||
@@ -388,6 +390,15 @@ typedef struct {
|
||||
advertising reports for each packet received */
|
||||
} esp_ble_scan_params_t;
|
||||
|
||||
/// connection parameters information
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< connection interval */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
|
||||
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec
|
||||
Time Range: 100 msec to 32 seconds */
|
||||
} esp_gap_conn_params_t;
|
||||
|
||||
/// Connection update parameters
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda; /*!< Bluetooth device address */
|
||||
@@ -895,7 +906,7 @@ esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params);
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length);
|
||||
|
||||
/**
|
||||
* @brief This function sets the random address for the application
|
||||
* @brief This function sets the static Random Address and Non-Resolvable Private Address for the application
|
||||
*
|
||||
* @param[in] rand_addr: the random address which should be setting
|
||||
*
|
||||
@@ -1243,6 +1254,32 @@ esp_err_t esp_ble_oob_req_reply(esp_bd_addr_t bd_addr, uint8_t *TK, uint8_t len)
|
||||
*/
|
||||
esp_err_t esp_ble_gap_disconnect(esp_bd_addr_t remote_device);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to authorized a link after Authentication(MITM protection)
|
||||
*
|
||||
* @param[in] bd_addr: BD address of the peer device.
|
||||
* @param[out] authorize: Authorized the link or not.
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_gap_ble_set_authorization(esp_bd_addr_t bd_addr, bool authorize);
|
||||
|
||||
/**
|
||||
* @brief This function is called to read the connection
|
||||
* parameters information of the device
|
||||
*
|
||||
* @param[in] bd_addr: BD address of the peer device.
|
||||
* @param[out] conn_params: the connection parameters information
|
||||
*
|
||||
* @return - ESP_OK : success
|
||||
* - other : failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_get_current_conn_params(esp_bd_addr_t bd_addr, esp_gap_conn_params_t *conn_params);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -174,6 +174,7 @@ typedef enum {
|
||||
ESP_BT_GAP_KEY_NOTIF_EVT, /*!< Simple Pairing Passkey Notification */
|
||||
ESP_BT_GAP_KEY_REQ_EVT, /*!< Simple Pairing Passkey request */
|
||||
ESP_BT_GAP_READ_RSSI_DELTA_EVT, /*!< read rssi event */
|
||||
ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT, /*!< remove bond device complete event */
|
||||
ESP_BT_GAP_EVT_MAX,
|
||||
} esp_bt_gap_cb_event_t;
|
||||
|
||||
@@ -271,6 +272,14 @@ typedef union {
|
||||
struct key_req_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
} key_req; /*!< passkey request parameter struct */
|
||||
|
||||
/**
|
||||
* @brief ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT
|
||||
*/
|
||||
struct bt_remove_bond_dev_cmpl_evt_param {
|
||||
esp_bd_addr_t bda; /*!< remote bluetooth device address*/
|
||||
esp_bt_status_t status; /*!< Indicate the remove bond device operation success status */
|
||||
}remove_bond_dev_cmpl; /*!< Event parameter of ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT */
|
||||
} esp_bt_gap_cb_param_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -46,6 +46,7 @@ extern esp_err_t esp_ble_gatt_set_local_mtu (uint16_t mtu);
|
||||
|
||||
#if (BLE_INCLUDED == TRUE)
|
||||
extern uint16_t esp_ble_get_sendable_packets_num (void);
|
||||
extern uint16_t esp_ble_get_cur_sendable_packets_num (uint16_t connid);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -278,6 +278,8 @@ typedef enum {
|
||||
#define ESP_GATT_PERM_WRITE_ENC_MITM (1 << 6) /* bit 6 - 0x0040 */ /* relate to BTA_GATT_PERM_WRITE_ENC_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED (1 << 7) /* bit 7 - 0x0080 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_WRITE_SIGNED_MITM (1 << 8) /* bit 8 - 0x0100 */ /* relate to BTA_GATT_PERM_WRITE_SIGNED_MITM in bta/bta_gatt_api.h */
|
||||
#define ESP_GATT_PERM_READ_AUTHORIZATION (1 << 9) /* bit 9 - 0x0200 */
|
||||
#define ESP_GATT_PERM_WRITE_AUTHORIZATION (1 << 10) /* bit 10 - 0x0400 */
|
||||
typedef uint16_t esp_gatt_perm_t;
|
||||
|
||||
/* relate to BTA_GATT_CHAR_PROP_BIT_xxx in bta/bta_gatt_api.h */
|
||||
@@ -393,6 +395,17 @@ typedef enum {
|
||||
ESP_GATT_WRITE_TYPE_RSP, /*!< Gatt write attribute need remote response */
|
||||
} esp_gatt_write_type_t;
|
||||
|
||||
/**
|
||||
* @brief Connection parameters information
|
||||
*/
|
||||
typedef struct {
|
||||
uint16_t interval; /*!< connection interval */
|
||||
uint16_t latency; /*!< Slave latency for the connection in number of connection events. Range: 0x0000 to 0x01F3 */
|
||||
uint16_t timeout; /*!< Supervision timeout for the LE Link. Range: 0x000A to 0x0C80.
|
||||
Mandatory Range: 0x000A to 0x0C80 Time = N * 10 msec
|
||||
Time Range: 100 msec to 32 seconds */
|
||||
} esp_gatt_conn_params_t;
|
||||
|
||||
#define ESP_GATT_IF_NONE 0xff /*!< If callback report gattc_if/gatts_if as this macro, means this event is not correspond to any app */
|
||||
|
||||
typedef uint8_t esp_gatt_if_t; /*!< Gatt interface type, different application on GATT client use different gatt_if */
|
||||
|
||||
@@ -209,6 +209,7 @@ typedef union {
|
||||
struct gattc_connect_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_params_t conn_params; /*!< current connection parameters */
|
||||
} connect; /*!< Gatt client callback param of ESP_GATTC_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
@@ -248,7 +249,7 @@ typedef union {
|
||||
/**
|
||||
* @brief GATT Client callback function type
|
||||
* @param event : Event type
|
||||
* @param gatts_if : GATT client access interface, normally
|
||||
* @param gattc_if : GATT client access interface, normally
|
||||
* different gattc_if correspond to different profile
|
||||
* @param param : Point to callback parameter, currently is union type
|
||||
*/
|
||||
@@ -603,6 +604,29 @@ esp_err_t esp_ble_gattc_read_char (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t handle,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
/**
|
||||
* @brief This function is called to read a service's characteristics of
|
||||
* the given characteristic UUID
|
||||
*
|
||||
* @param[in] gattc_if: Gatt client access interface.
|
||||
* @param[in] conn_id : connection ID.
|
||||
* @param[in] start_handle : the attribute start handle.
|
||||
* @param[in] end_handle : the attribute end handle
|
||||
* @param[in] uuid : The UUID of attribute which will be read.
|
||||
* @param[in] auth_req : authenticate request type
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*
|
||||
*/
|
||||
esp_err_t esp_ble_gattc_read_by_type (esp_gatt_if_t gattc_if,
|
||||
uint16_t conn_id,
|
||||
uint16_t start_handle,
|
||||
uint16_t end_handle,
|
||||
esp_bt_uuid_t *uuid,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/**
|
||||
* @brief This function is called to read multiple characteristic or
|
||||
|
||||
@@ -197,6 +197,7 @@ typedef union {
|
||||
struct gatts_connect_evt_param {
|
||||
uint16_t conn_id; /*!< Connection id */
|
||||
esp_bd_addr_t remote_bda; /*!< Remote bluetooth device address */
|
||||
esp_gatt_conn_params_t conn_params; /*!< current Connection parameters */
|
||||
} connect; /*!< Gatt server callback param of ESP_GATTS_CONNECT_EVT */
|
||||
|
||||
/**
|
||||
|
||||
@@ -271,7 +271,7 @@ typedef void (* esp_hf_client_incoming_data_cb_t)(const uint8_t *buf, uint32_t l
|
||||
* buffer is allocated inside bluetooth protocol stack and will be released after
|
||||
* invoke of the callback is finished.
|
||||
* @param[in] len : size(in bytes) in buf
|
||||
* @param[out] length of data successfully read
|
||||
* @return length of data successfully read
|
||||
*/
|
||||
typedef uint32_t (* esp_hf_client_outgoing_data_cb_t)(uint8_t *buf, uint32_t len);
|
||||
|
||||
|
||||
@@ -26,8 +26,12 @@ typedef enum {
|
||||
ESP_SPP_SUCCESS = 0, /*!< Successful operation. */
|
||||
ESP_SPP_FAILURE, /*!< Generic failure. */
|
||||
ESP_SPP_BUSY, /*!< Temporarily can not handle this request. */
|
||||
ESP_SPP_NO_DATA, /*!< no data. */
|
||||
ESP_SPP_NO_RESOURCE /*!< No more set pm control block */
|
||||
ESP_SPP_NO_DATA, /*!< No data. */
|
||||
ESP_SPP_NO_RESOURCE, /*!< No more resource */
|
||||
ESP_SPP_NEED_INIT, /*!< SPP module shall init first */
|
||||
ESP_SPP_NEED_DEINIT, /*!< SPP module shall deinit first */
|
||||
ESP_SPP_NO_CONNECTION, /*!< Connection may have been closed */
|
||||
ESP_SPP_NO_SERVER, /*!< No SPP server */
|
||||
} esp_spp_status_t;
|
||||
|
||||
/* Security Setting Mask, Suggest to use ESP_SPP_SEC_NONE, ESP_SPP_SEC_AUTHORIZE or ESP_SPP_SEC_AUTHENTICATE only.*/
|
||||
@@ -57,6 +61,7 @@ typedef enum {
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_SPP_INIT_EVT = 0, /*!< When SPP is inited, the event comes */
|
||||
ESP_SPP_UNINIT_EVT = 1, /*!< When SPP is uninited, the event comes */
|
||||
ESP_SPP_DISCOVERY_COMP_EVT = 8, /*!< When SDP discovery complete, the event comes */
|
||||
ESP_SPP_OPEN_EVT = 26, /*!< When SPP Client connection open, the event comes */
|
||||
ESP_SPP_CLOSE_EVT = 27, /*!< When SPP connection closed, the event comes */
|
||||
@@ -66,6 +71,7 @@ typedef enum {
|
||||
ESP_SPP_CONG_EVT = 31, /*!< When SPP connection congestion status changed, the event comes, only for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_WRITE_EVT = 33, /*!< When SPP write operation completes, the event comes, only for ESP_SPP_MODE_CB */
|
||||
ESP_SPP_SRV_OPEN_EVT = 34, /*!< When SPP Server connection open, the event comes */
|
||||
ESP_SPP_SRV_STOP_EVT = 35, /*!< When SPP server stopped, the event comes */
|
||||
} esp_spp_cb_event_t;
|
||||
|
||||
|
||||
@@ -80,13 +86,22 @@ typedef union {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} init; /*!< SPP callback param of SPP_INIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_UNINIT_EVT
|
||||
*/
|
||||
struct spp_uninit_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
} uninit; /*!< SPP callback param of SPP_UNINIT_EVT */
|
||||
|
||||
/**
|
||||
* @brief SPP_DISCOVERY_COMP_EVT
|
||||
*/
|
||||
struct spp_discovery_comp_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint8_t scn_num; /*!< The num of scn_num */
|
||||
uint8_t scn[ESP_SPP_MAX_SCN]; /*!< channel # */
|
||||
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint8_t scn_num; /*!< The num of scn_num */
|
||||
uint8_t scn[ESP_SPP_MAX_SCN]; /*!< channel # */
|
||||
const char *service_name[ESP_SPP_MAX_SCN]; /*!< service_name */
|
||||
} disc_comp; /*!< SPP callback param of SPP_DISCOVERY_COMP_EVT */
|
||||
|
||||
/**
|
||||
@@ -126,8 +141,18 @@ typedef union {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint32_t handle; /*!< The connection handle */
|
||||
uint8_t sec_id; /*!< security ID used by this server */
|
||||
uint8_t scn; /*!< Server channel number */
|
||||
bool use_co; /*!< TRUE to use co_rfc_data */
|
||||
} start; /*!< SPP callback param of ESP_SPP_START_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_SRV_STOP_EVT
|
||||
*/
|
||||
struct spp_srv_stop_evt_param {
|
||||
esp_spp_status_t status; /*!< status */
|
||||
uint8_t scn; /*!< Server channel number */
|
||||
} srv_stop; /*!< SPP callback param of ESP_SPP_SRV_STOP_EVT */
|
||||
|
||||
/**
|
||||
* @brief ESP_SPP_CL_INIT_EVT
|
||||
*/
|
||||
@@ -273,6 +298,34 @@ esp_err_t esp_spp_disconnect(uint32_t handle);
|
||||
esp_err_t esp_spp_start_srv(esp_spp_sec_t sec_mask,
|
||||
esp_spp_role_t role, uint8_t local_scn, const char *name);
|
||||
|
||||
/**
|
||||
|
||||
* @brief This function stops all SPP servers.
|
||||
* The operation will close all active SPP connection first, then the callback function will be called
|
||||
* with ESP_SPP_CLOSE_EVT, and the number of ESP_SPP_CLOSE_EVT is equal to the number of connection.
|
||||
* When the operation is completed, the callback is called with ESP_SPP_SRV_STOP_EVT.
|
||||
* This funciton must be called after esp_spp_init() successful and before esp_spp_deinit().
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_stop_srv(void);
|
||||
|
||||
/**
|
||||
* @brief This function stops a specific SPP server.
|
||||
* The operation will close all active SPP connection first on the specific SPP server, then the callback function will be called
|
||||
* with ESP_SPP_CLOSE_EVT, and the number of ESP_SPP_CLOSE_EVT is equal to the number of connection.
|
||||
* When the operation is completed, the callback is called with ESP_SPP_SRV_STOP_EVT.
|
||||
* This funciton must be called after esp_spp_init() successful and before esp_spp_deinit().
|
||||
*
|
||||
* @param[in] scn: Server channel number.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: success
|
||||
* - other: failed
|
||||
*/
|
||||
esp_err_t esp_spp_stop_srv_scn(uint8_t scn);
|
||||
|
||||
/**
|
||||
* @brief This function is used to write data, only for ESP_SPP_MODE_CB.
|
||||
|
||||
@@ -208,11 +208,8 @@ static void bta_av_rc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result, BD_AD
|
||||
UINT16 msg_event = 0;
|
||||
UNUSED(result);
|
||||
|
||||
#if (defined(BTA_AV_MIN_DEBUG_TRACES) && BTA_AV_MIN_DEBUG_TRACES == TRUE)
|
||||
APPL_TRACE_EVENT("rc_ctrl handle: %d event=0x%x", handle, event);
|
||||
#else
|
||||
APPL_TRACE_EVENT("bta_av_rc_ctrl_cback handle: %d event=0x%x", handle, event);
|
||||
#endif
|
||||
APPL_TRACE_EVENT("%s handle: %d event: 0x%x",__func__, handle, event);
|
||||
|
||||
if (event == AVRC_OPEN_IND_EVT) {
|
||||
/* save handle of opened connection
|
||||
bta_av_cb.rc_handle = handle;*/
|
||||
|
||||
@@ -563,13 +563,8 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
|
||||
if (bta_av_cb.features & (BTA_AV_FEAT_RCTG)) {
|
||||
/* register with no authorization; let AVDTP use authorization instead */
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
|
||||
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
|
||||
bta_av_cb.sec_mask, BTA_ID_AV);
|
||||
#else
|
||||
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
|
||||
(UINT8)(bta_av_cb.sec_mask & (~BTA_SEC_AUTHORIZE)), BTA_ID_AV);
|
||||
#endif
|
||||
if (p_data->api_reg.tsep == AVDT_TSEP_SRC) {
|
||||
bta_ar_reg_avrc(UUID_SERVCLASS_AV_REM_CTRL_TARGET, "AV Remote Control Target\n", NULL,
|
||||
p_bta_av_cfg->avrc_src_tg_cat, BTA_ID_AV);
|
||||
@@ -699,13 +694,8 @@ static void bta_av_api_register(tBTA_AV_DATA *p_data)
|
||||
/* if TG is not supported, we need to register to AVCT now */
|
||||
if ((bta_av_cb.features & (BTA_AV_FEAT_RCTG)) == 0) {
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
#if (BTA_AV_WITH_AVCTP_AUTHORIZATION == TRUE)
|
||||
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
|
||||
bta_av_cb.sec_mask, BTA_ID_AV);
|
||||
#else
|
||||
bta_ar_reg_avct(p_bta_av_cfg->avrc_mtu, p_bta_av_cfg->avrc_br_mtu,
|
||||
(UINT8)(bta_av_cb.sec_mask & (~BTA_SEC_AUTHORIZE)), BTA_ID_AV);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
|
||||
@@ -610,7 +610,7 @@ void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data)
|
||||
void bta_dm_read_rssi(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
if (p_data->rssi.read_rssi_cb != NULL) {
|
||||
BTM_ReadRSSI(p_data->rssi.remote_addr, p_data->rssi.transport, p_data->rssi.read_rssi_cb);
|
||||
@@ -756,11 +756,13 @@ void bta_dm_remove_device(tBTA_DM_MSG *p_data)
|
||||
/* Take the link down first, and mark the device for removal when disconnected */
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp(bta_dm_cb.device_list.peer_device[i].peer_bdaddr, p_dev->bd_addr)
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport) {
|
||||
#if BLE_INCLUDED == TRUE
|
||||
&& bta_dm_cb.device_list.peer_device[i].transport == transport
|
||||
#endif
|
||||
) {
|
||||
bta_dm_cb.device_list.peer_device[i].conn_state = BTA_DM_UNPAIRING;
|
||||
btm_remove_acl( p_dev->bd_addr, bta_dm_cb.device_list.peer_device[i].transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__,
|
||||
bta_dm_cb.device_list.peer_device[i].transport);
|
||||
btm_remove_acl( p_dev->bd_addr, transport);
|
||||
APPL_TRACE_DEBUG("%s:transport = %d", __func__, transport);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3622,9 +3624,12 @@ static void bta_dm_adjust_roles(BOOLEAN delay_role_switch)
|
||||
BTM_SwitchRole (bta_dm_cb.device_list.peer_device[i].peer_bdaddr,
|
||||
HCI_ROLE_MASTER, NULL);
|
||||
} else {
|
||||
bta_dm_cb.switch_delay_timer.p_cback =
|
||||
bta_dm_cb.switch_delay_timer[i].p_cback =
|
||||
(TIMER_CBACK *)&bta_dm_delay_role_switch_cback;
|
||||
bta_sys_start_timer(&bta_dm_cb.switch_delay_timer, 0, 500);
|
||||
/* Start the timer if not active */
|
||||
if (!bta_sys_timer_is_active(&bta_dm_cb.switch_delay_timer[i])) {
|
||||
bta_sys_start_timer(&bta_dm_cb.switch_delay_timer[i], 0, 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -206,11 +206,11 @@ void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb)
|
||||
}
|
||||
}
|
||||
|
||||
void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb)
|
||||
{
|
||||
tBTA_DM_API_READ_RSSI *p_msg;
|
||||
if ((p_msg = (tBTA_DM_API_READ_RSSI *)osi_malloc(sizeof(tBTA_DM_API_READ_RSSI))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_BLE_READ_RSSI_EVT;
|
||||
p_msg->hdr.event = BTA_DM_API_READ_RSSI_EVT;
|
||||
memcpy(p_msg->remote_addr, remote_addr, sizeof(BD_ADDR));
|
||||
p_msg->transport = transport;
|
||||
p_msg->read_rssi_cb = cmpl_cb;
|
||||
|
||||
@@ -51,6 +51,7 @@ tBTE_APPL_CFG bte_appl_cfg = {
|
||||
BTM_BLE_MIN_KEY_SIZE,
|
||||
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
|
||||
BTM_BLE_OOB_DISABLE,
|
||||
BTM_BLE_APPL_ENC_KEY_SIZE,
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -232,8 +233,8 @@ void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r)
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_rmt_oob(BD_ADDR bd_addr)
|
||||
{
|
||||
BT_OCTET16 p_c;
|
||||
BT_OCTET16 p_r;
|
||||
BT_OCTET16 p_c = {0};
|
||||
BT_OCTET16 p_r = {0};
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
#ifdef BTIF_DM_OOB_TEST
|
||||
@@ -427,6 +428,17 @@ void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_appl_enc_key_size(UINT8 ble_key_size)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
|
||||
bte_appl_cfg.ble_appl_enc_key_size = ble_key_size;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
|
||||
@@ -159,7 +159,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
|
||||
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
|
||||
bta_dm_ble_read_rssi, /* BTA_DM_API_BLE_READ_RSSI_EVT */
|
||||
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
|
||||
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
|
||||
};
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ enum {
|
||||
BTA_DM_API_REMOVE_DEVICE_EVT,
|
||||
BTA_DM_API_UPDATE_WHITE_LIST_EVT,
|
||||
BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT,
|
||||
BTA_DM_API_BLE_READ_RSSI_EVT,
|
||||
BTA_DM_API_READ_RSSI_EVT,
|
||||
BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT,
|
||||
BTA_DM_MAX_EVT
|
||||
};
|
||||
@@ -1040,7 +1040,7 @@ typedef struct {
|
||||
|
||||
|
||||
tBTA_DM_ENCRYPT_CBACK *p_encrypt_cback;
|
||||
TIMER_LIST_ENT switch_delay_timer;
|
||||
TIMER_LIST_ENT switch_delay_timer[BTA_DM_NUM_PEER_DEVICE];
|
||||
|
||||
} tBTA_DM_CB;
|
||||
|
||||
@@ -1226,7 +1226,7 @@ extern void bta_dm_disable (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_dev_name (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_update_white_list(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_adv_tx_power(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_rssi(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_read_rssi(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_set_visibility (tBTA_DM_MSG *p_data);
|
||||
|
||||
extern void bta_dm_set_scan_config(tBTA_DM_MSG *p_data);
|
||||
|
||||
@@ -488,9 +488,14 @@ void bta_gattc_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
tBTA_GATTC_DATA gattc_data;
|
||||
BOOLEAN found_app = FALSE;
|
||||
tGATT_TCB *p_tcb;
|
||||
|
||||
tGATT_TCB *p_tcb = gatt_find_tcb_by_addr(p_data->api_conn.remote_bda, BT_TRANSPORT_LE);
|
||||
if(p_tcb && p_clcb && p_data) {
|
||||
if (!p_clcb || !p_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
p_tcb = gatt_find_tcb_by_addr(p_data->api_conn.remote_bda, BT_TRANSPORT_LE);
|
||||
if(p_tcb) {
|
||||
found_app = gatt_find_specific_app_in_hold_link(p_tcb, p_clcb->p_rcb->client_if);
|
||||
}
|
||||
/* open/hold a connection */
|
||||
@@ -729,7 +734,7 @@ void bta_gattc_conncback(tBTA_GATTC_RCB *p_rcb, tBTA_GATTC_DATA *p_data)
|
||||
if (p_rcb) {
|
||||
bta_gattc_send_connect_cback(p_rcb,
|
||||
p_data->int_conn.remote_bda,
|
||||
p_data->int_conn.hdr.layer_specific);
|
||||
p_data->int_conn.hdr.layer_specific, p_data->int_conn.conn_params);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1099,6 +1104,41 @@ void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_read_by_type
|
||||
**
|
||||
** Description Read an attribute
|
||||
**
|
||||
** Returns None.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_read_by_type(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
if (!bta_gattc_enqueue(p_clcb, p_data)) {
|
||||
return;
|
||||
}
|
||||
|
||||
tGATT_READ_PARAM read_param;
|
||||
memset (&read_param, 0 ,sizeof(tGATT_READ_PARAM));
|
||||
read_param.service.auth_req = p_data->api_read.auth_req;
|
||||
read_param.service.s_handle = p_data->api_read.s_handle;
|
||||
read_param.service.e_handle = p_data->api_read.e_handle;
|
||||
memcpy(&(read_param.service.uuid), &(p_data->api_read.uuid), sizeof(tBT_UUID));
|
||||
|
||||
tBTA_GATT_STATUS status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_BY_TYPE, &read_param);
|
||||
|
||||
/* read fail */
|
||||
if (status != BTA_GATT_OK) {
|
||||
/* Dequeue the data, if it was enqueued */
|
||||
if (p_clcb->p_q_cmd == p_data) {
|
||||
p_clcb->p_q_cmd = NULL;
|
||||
bta_gattc_pop_command_to_send(p_clcb);
|
||||
}
|
||||
|
||||
bta_gattc_cmpl_sendmsg(p_clcb->bta_conn_id, GATTC_OPTYPE_READ, status, NULL);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_gattc_read_multi
|
||||
**
|
||||
** Description read multiple
|
||||
@@ -1117,7 +1157,7 @@ void bta_gattc_read_multi(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
read_param.read_multiple.num_handles = p_data->api_read_multi.num_attr;
|
||||
read_param.read_multiple.auth_req = p_data->api_read_multi.auth_req;
|
||||
memcpy(&read_param.read_multiple.handles, p_data->api_read_multi.handles,
|
||||
sizeof(UINT16) * p_data->api_read_multi.num_attr);
|
||||
sizeof(UINT16) * p_data->api_read_multi.num_attr);
|
||||
|
||||
status = GATTC_Read(p_clcb->bta_conn_id, GATT_READ_MULTIPLE, &read_param);
|
||||
}
|
||||
@@ -1392,7 +1432,7 @@ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
return;
|
||||
}
|
||||
if (p_clcb->p_q_cmd->hdr.event != bta_gattc_opcode_to_int_evt[op - GATTC_OPTYPE_READ]) {
|
||||
if (p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_MULTI_EVT) {
|
||||
if ((p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_MULTI_EVT)&&(p_clcb->p_q_cmd->hdr.event != BTA_GATTC_API_READ_BY_TYPE_EVT)) {
|
||||
mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ;
|
||||
if ( mapped_op > GATTC_OPTYPE_INDICATION) {
|
||||
mapped_op = 0;
|
||||
@@ -1651,6 +1691,16 @@ static void bta_gattc_conn_cback(tGATT_IF gattc_if, BD_ADDR bda, UINT16 conn_id,
|
||||
|
||||
p_buf->int_conn.hdr.event = connected ? BTA_GATTC_INT_CONN_EVT :
|
||||
BTA_GATTC_INT_DISCONN_EVT;
|
||||
if(p_buf->int_conn.hdr.event == BTA_GATTC_INT_CONN_EVT) {
|
||||
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bda, BT_TRANSPORT_LE);
|
||||
if(p_lcb != NULL) {
|
||||
p_buf->int_conn.conn_params.interval = p_lcb->current_used_conn_interval;
|
||||
p_buf->int_conn.conn_params.latency = p_lcb->current_used_conn_latency;
|
||||
p_buf->int_conn.conn_params.timeout = p_lcb->current_used_conn_timeout;
|
||||
} else {
|
||||
APPL_TRACE_WARNING("%s not found connection parameters of the device ", __func__);
|
||||
}
|
||||
}
|
||||
p_buf->int_conn.hdr.layer_specific = conn_id;
|
||||
p_buf->int_conn.client_if = gattc_if;
|
||||
p_buf->int_conn.role = L2CA_GetBleConnRole(bda);
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_gattc_int.h"
|
||||
|
||||
#include "stack/l2c_api.h"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@@ -298,7 +298,7 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
|
||||
** Returns returns list_t of tBTA_GATTC_SERVICE or NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
const list_t* BTA_GATTC_GetServices(UINT16 conn_id)
|
||||
const list_t* BTA_GATTC_GetServices(UINT16 conn_id)
|
||||
{
|
||||
return bta_gattc_get_services(conn_id);
|
||||
}
|
||||
@@ -315,7 +315,7 @@ const list_t* BTA_GATTC_GetServices(UINT16 conn_id)
|
||||
** Returns returns pointer to tBTA_GATTC_CHARACTERISTIC or NULL.
|
||||
**
|
||||
*******************************************************************************/
|
||||
const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_id, UINT16 handle)
|
||||
const tBTA_GATTC_CHARACTERISTIC* BTA_GATTC_GetCharacteristic(UINT16 conn_id, UINT16 handle)
|
||||
{
|
||||
return bta_gattc_get_characteristic(conn_id, handle);
|
||||
}
|
||||
@@ -562,6 +562,39 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_Read_by_type
|
||||
**
|
||||
** Description This function is called to read a attribute value by uuid
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** s_handle - start handle.
|
||||
** e_handle - end hanle
|
||||
** uuid - The attribute UUID.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_Read_by_type(UINT16 conn_id, UINT16 s_handle,UINT16 e_handle, tBT_UUID *uuid, tBTA_GATT_AUTH_REQ auth_req)
|
||||
{
|
||||
tBTA_GATTC_API_READ *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_READ *) osi_malloc(sizeof(tBTA_GATTC_API_READ))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_READ_BY_TYPE_EVT;
|
||||
p_buf->hdr.layer_specific = conn_id;
|
||||
p_buf->auth_req = auth_req;
|
||||
p_buf->s_handle = s_handle;
|
||||
p_buf->e_handle = e_handle;
|
||||
memcpy(&(p_buf->uuid), uuid, sizeof(tBT_UUID));
|
||||
p_buf->cmpl_evt = BTA_GATTC_READ_CHAR_EVT;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -603,6 +636,10 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
||||
memcpy(p_buf->p_value, p_value, len);
|
||||
}
|
||||
|
||||
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
@@ -650,6 +687,10 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
memcpy(p_buf->p_value, p_data->p_value, p_data->len);
|
||||
}
|
||||
|
||||
if(write_type == BTA_GATTC_TYPE_WRITE_NO_RSP){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
@@ -718,7 +759,7 @@ void BTA_GATTC_PrepareWriteCharDescr (UINT16 conn_id, UINT16 handle,
|
||||
tBTA_GATT_AUTH_REQ auth_req)
|
||||
{
|
||||
tBTA_GATTC_API_WRITE *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTC_API_WRITE) + p_data->len;
|
||||
UINT16 len = sizeof(tBTA_GATTC_API_WRITE);
|
||||
|
||||
if (p_data != NULL) {
|
||||
len += p_data->len;
|
||||
@@ -957,7 +998,7 @@ void BTA_GATTC_CacheAssoc(tBTA_GATTC_IF client_if, BD_ADDR src_addr, BD_ADDR ass
|
||||
memcpy(p_buf->assoc_addr, assoc_addr, sizeof(BD_ADDR));
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -154,6 +154,10 @@ static void cacheReset(BD_ADDR bda)
|
||||
cache_env.cache_addr[index].is_open = FALSE;
|
||||
} else {
|
||||
cacheOpen(bda, false, &index);
|
||||
if (index == INVALID_ADDR_NUM) {
|
||||
APPL_TRACE_ERROR("%s INVALID ADDR NUM", __func__);
|
||||
return;
|
||||
}
|
||||
if (cache_env.cache_addr[index].is_open) {
|
||||
nvs_erase_all(cache_env.cache_addr[index].cache_fp);
|
||||
nvs_close(cache_env.cache_addr[index].cache_fp);
|
||||
|
||||
@@ -65,6 +65,7 @@ enum {
|
||||
BTA_GATTC_DISC_CLOSE,
|
||||
BTA_GATTC_RESTART_DISCOVER,
|
||||
BTA_GATTC_CFG_MTU,
|
||||
BTA_GATTC_READ_BY_TYPE,
|
||||
|
||||
BTA_GATTC_IGNORE
|
||||
};
|
||||
@@ -98,7 +99,8 @@ const tBTA_GATTC_ACTION bta_gattc_action[] = {
|
||||
bta_gattc_ignore_op_cmpl,
|
||||
bta_gattc_disc_close,
|
||||
bta_gattc_restart_discover,
|
||||
bta_gattc_cfg_mtu
|
||||
bta_gattc_cfg_mtu,
|
||||
bta_gattc_read_by_type
|
||||
};
|
||||
|
||||
|
||||
@@ -133,6 +135,7 @@ static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] = {
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_BY_TYPE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
};
|
||||
|
||||
/* state table for wait for open state */
|
||||
@@ -161,6 +164,7 @@ static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] = {
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_BY_TYPE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
};
|
||||
|
||||
/* state table for open state */
|
||||
@@ -190,6 +194,7 @@ static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = {
|
||||
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_BY_TYPE_EVT */ {BTA_GATTC_READ_BY_TYPE, BTA_GATTC_CONN_ST},
|
||||
};
|
||||
|
||||
/* state table for discover state */
|
||||
@@ -218,6 +223,7 @@ static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] = {
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_BY_TYPE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
};
|
||||
|
||||
/* type for state table */
|
||||
@@ -470,6 +476,8 @@ static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
|
||||
return "BTA_GATTC_API_DISABLE_EVT";
|
||||
case BTA_GATTC_API_CFG_MTU_EVT:
|
||||
return "BTA_GATTC_API_CFG_MTU_EVT";
|
||||
case BTA_GATTC_API_READ_BY_TYPE_EVT:
|
||||
return "BTA_GATTC_API_READ_BY_TYPE_EVT";
|
||||
default:
|
||||
return "unknown GATTC event code";
|
||||
}
|
||||
|
||||
@@ -306,8 +306,11 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
|
||||
p_srcb->p_srvc_cache = NULL;
|
||||
}
|
||||
}
|
||||
osi_free(p_clcb->p_q_cmd);
|
||||
p_clcb->p_q_cmd = NULL;
|
||||
|
||||
if ( p_clcb->p_q_cmd != NULL && !list_contains(p_clcb->p_cmd_list, p_clcb->p_q_cmd)){
|
||||
osi_free(p_clcb->p_q_cmd);
|
||||
p_clcb->p_q_cmd = NULL;
|
||||
}
|
||||
// don't forget to clear the command queue before dealloc the clcb.
|
||||
list_clear(p_clcb->p_cmd_list);
|
||||
osi_free((void *)p_clcb->p_cmd_list);
|
||||
@@ -762,7 +765,7 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id)
|
||||
void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, tBTA_GATT_CONN_PARAMS conn_params)
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
@@ -771,6 +774,9 @@ void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda,
|
||||
|
||||
cb_data.connect.client_if = p_clreg->client_if;
|
||||
cb_data.connect.conn_id = conn_id;
|
||||
cb_data.connect.conn_params.interval = conn_params.interval;
|
||||
cb_data.connect.conn_params.latency = conn_params.latency;
|
||||
cb_data.connect.conn_params.timeout = conn_params.timeout;
|
||||
bdcpy(cb_data.connect.remote_bda, remote_bda);
|
||||
|
||||
(*p_clreg->p_cback)(BTA_GATTC_CONNECT_EVT, &cb_data);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include "stack/btm_ble_api.h"
|
||||
#include <string.h>
|
||||
#include "osi/allocator.h"
|
||||
#include "stack/l2c_api.h"
|
||||
#include "l2c_int.h"
|
||||
|
||||
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
|
||||
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
|
||||
@@ -672,6 +674,7 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
p_msg->api_indicate.len,
|
||||
p_msg->api_indicate.value);
|
||||
} else {
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTU_NUM, NULL);
|
||||
status = GATTS_HandleValueNotification (p_msg->api_indicate.hdr.layer_specific,
|
||||
p_msg->api_indicate.attr_id,
|
||||
p_msg->api_indicate.len,
|
||||
@@ -965,7 +968,7 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
BOOLEAN connected, tGATT_DISCONN_REASON reason,
|
||||
tGATT_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTS cb_data;
|
||||
tBTA_GATTS cb_data = {0};
|
||||
UINT8 evt = connected ? BTA_GATTS_CONNECT_EVT : BTA_GATTS_DISCONNECT_EVT;
|
||||
tBTA_GATTS_RCB *p_reg;
|
||||
|
||||
@@ -993,7 +996,16 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, bda);
|
||||
}
|
||||
}
|
||||
|
||||
if(evt == BTA_GATTS_CONNECT_EVT) {
|
||||
tL2C_LCB *p_lcb = l2cu_find_lcb_by_bd_addr(bda, BT_TRANSPORT_LE);
|
||||
if(p_lcb != NULL) {
|
||||
cb_data.conn.conn_params.interval = p_lcb->current_used_conn_interval;
|
||||
cb_data.conn.conn_params.latency = p_lcb->current_used_conn_latency;
|
||||
cb_data.conn.conn_params.timeout = p_lcb->current_used_conn_timeout;
|
||||
}else {
|
||||
APPL_TRACE_WARNING("%s not found connection parameters of the device ", __func__);
|
||||
}
|
||||
}
|
||||
cb_data.conn.conn_id = conn_id;
|
||||
cb_data.conn.server_if = gatt_if;
|
||||
cb_data.conn.reason = reason;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
#include "bta/bta_gatt_api.h"
|
||||
#include "bta_gatts_int.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#include "stack/l2c_api.h"
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
@@ -426,6 +426,11 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
|
||||
memcpy(p_buf->value, p_data, data_len);
|
||||
|
||||
}
|
||||
|
||||
if(need_confirm == false){
|
||||
l2ble_update_att_acl_pkt_num(L2CA_DECREASE_BTC_NUM, NULL);
|
||||
l2ble_update_att_acl_pkt_num(L2CA_ADD_BTU_NUM, NULL);
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
return;
|
||||
|
||||
@@ -59,6 +59,8 @@ enum {
|
||||
BTA_GATTC_OP_CMPL_EVT,
|
||||
BTA_GATTC_INT_DISCONN_EVT,
|
||||
|
||||
BTA_GATTC_API_READ_BY_TYPE_EVT,
|
||||
|
||||
BTA_GATTC_INT_START_IF_EVT,
|
||||
BTA_GATTC_API_REG_EVT,
|
||||
BTA_GATTC_API_DEREG_EVT,
|
||||
@@ -136,6 +138,9 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
UINT16 handle;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
tBT_UUID uuid;
|
||||
tBTA_GATTC_EVT cmpl_evt;
|
||||
} tBTA_GATTC_API_READ;
|
||||
|
||||
@@ -215,6 +220,7 @@ typedef struct {
|
||||
tBT_TRANSPORT transport;
|
||||
tGATT_DISCONN_REASON reason;
|
||||
BOOLEAN already_connect;
|
||||
tBTA_GATT_CONN_PARAMS conn_params;
|
||||
} tBTA_GATTC_INT_CONN;
|
||||
|
||||
typedef struct {
|
||||
@@ -449,6 +455,7 @@ extern void bta_gattc_disc_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_dat
|
||||
extern void bta_gattc_start_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_disc_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_read(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_read_by_type(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_write(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_q_cmd(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
@@ -466,7 +473,7 @@ extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *
|
||||
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
|
||||
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
|
||||
extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id);
|
||||
extern void bta_gattc_send_connect_cback( tBTA_GATTC_RCB *p_clreg, BD_ADDR remote_bda, UINT16 conn_id, tBTA_GATT_CONN_PARAMS conn_params);
|
||||
extern void bta_gattc_send_disconnect_cback( tBTA_GATTC_RCB *p_clreg, tGATT_DISCONN_REASON reason,
|
||||
BD_ADDR remote_bda, UINT16 conn_id);
|
||||
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
@@ -214,7 +214,7 @@ const UINT8 bta_hf_client_st_closing[][BTA_HF_CLIENT_NUM_COLS] = {
|
||||
/* DISC_OK_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* DISC_FAIL_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SCO_OPEN_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SCO_CLOSE_EVT */ {BTA_HF_CLIENT_SCO_CONN_CLOSE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
/* SEND_AT_CMD_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE )
|
||||
/* CI_SCO_DATA_EVT */ {BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_IGNORE, BTA_HF_CLIENT_CLOSING_ST},
|
||||
|
||||
@@ -926,7 +926,7 @@ typedef union {
|
||||
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
|
||||
tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
|
||||
tBTA_DM_AUTHORIZE authorize; /* Authorization request. */
|
||||
tBTA_DM_LINK_UP link_up; /* ACL connection down event */
|
||||
tBTA_DM_LINK_UP link_up; /* ACL connection up event */
|
||||
tBTA_DM_LINK_DOWN link_down; /* ACL connection down event */
|
||||
tBTA_DM_BUSY_LEVEL busy_level; /* System busy level */
|
||||
tBTA_DM_SP_CFM_REQ cfm_req; /* user confirm request */
|
||||
@@ -1457,7 +1457,7 @@ extern void BTA_DmUpdateWhiteList(BOOLEAN add_remove, BD_ADDR remote_addr, tBTA
|
||||
|
||||
extern void BTA_DmBleReadAdvTxPower(tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
extern void BTA_DmBleReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
extern void BTA_DmReadRSSI(BD_ADDR remote_addr, tBTA_TRANSPORT transport, tBTA_CMPL_CB *cmpl_cb);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -2296,8 +2296,8 @@ extern void BTA_DmBleSetScanRspRaw (UINT8 *p_raw_scan_rsp, UINT32 raw_scan_rsp_l
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
|
||||
BD_ADDR device_info,
|
||||
extern void BTA_DmUpdateDuplicateExceptionalList(UINT8 subcode, UINT32 type,
|
||||
BD_ADDR device_info,
|
||||
tBTA_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_CMPL_CBACK p_update_duplicate_exceptional_list_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -36,12 +36,6 @@
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
/* Set to TRUE if seperate authorization prompt desired for AVCTP besides A2DP authorization */
|
||||
/* Typically FALSE when AVRCP is used in conjunction with A2DP */
|
||||
#ifndef BTA_AV_WITH_AVCTP_AUTHORIZATION
|
||||
#define BTA_AV_WITH_AVCTP_AUTHORIZATION FALSE
|
||||
#endif
|
||||
|
||||
/* AV status values */
|
||||
#define BTA_AV_SUCCESS 0 /* successful operation */
|
||||
#define BTA_AV_FAIL 1 /* generic failure */
|
||||
@@ -581,8 +575,7 @@ void BTA_AvDisable(void);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name,
|
||||
UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep);
|
||||
void BTA_AvRegister(tBTA_AV_CHNL chnl, const char *p_service_name, UINT8 app_id, tBTA_AV_DATA_CBACK *p_data_cback, tBTA_AV_CO_FUNCTS *bta_av_cos, UINT8 tsep);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -214,4 +214,6 @@ extern UINT8 bta_dm_co_ble_get_accept_auth_enable(void);
|
||||
extern UINT8 bta_dm_co_ble_get_auth_req(void);
|
||||
|
||||
extern void bta_dm_co_ble_oob_support(UINT8 enable);
|
||||
|
||||
extern void bta_dm_co_ble_set_appl_enc_key_size(UINT8 ble_key_size);
|
||||
#endif
|
||||
|
||||
@@ -200,6 +200,12 @@ typedef struct {
|
||||
UINT8 name_spc; /* The name space of the description */
|
||||
} tBTA_GATT_CHAR_PRES;
|
||||
|
||||
typedef struct {
|
||||
UINT16 interval;
|
||||
UINT16 latency;
|
||||
UINT16 timeout;
|
||||
} tBTA_GATT_CONN_PARAMS;
|
||||
|
||||
#define BTA_GATT_CLT_CONFIG_NONE GATT_CLT_CONFIG_NONE /* 0x0000 */
|
||||
#define BTA_GATT_CLT_CONFIG_NOTIFICATION GATT_CLT_CONFIG_NOTIFICATION /* 0x0001 */
|
||||
#define BTA_GATT_CLT_CONFIG_INDICATION GATT_CLT_CONFIG_INDICATION /* 0x0002 */
|
||||
@@ -397,6 +403,7 @@ typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATT_CONN_PARAMS conn_params;
|
||||
} tBTA_GATTC_CONNECT;
|
||||
|
||||
typedef struct {
|
||||
@@ -479,6 +486,8 @@ typedef tGATT_IF tBTA_GATTS_IF;
|
||||
#define BTA_GATT_PERM_WRITE_ENC_MITM GATT_PERM_WRITE_ENC_MITM /* bit 6 - 0x0040 */
|
||||
#define BTA_GATT_PERM_WRITE_SIGNED GATT_PERM_WRITE_SIGNED /* bit 7 - 0x0080 */
|
||||
#define BTA_GATT_PERM_WRITE_SIGNED_MITM GATT_PERM_WRITE_SIGNED_MITM /* bit 8 - 0x0100 */
|
||||
#define BTA_GATT_PERM_READ_AUTHORIZATION GATT_PERM_READ_AUTHORIZATION /* bit 9 - 0x0200 */
|
||||
#define BTA_GATT_PERM_WRITE_AUTHORIZATION GATT_PERM_WRITE_AUTHORIZATION /* bit 10 - 0x0400 */
|
||||
typedef UINT16 tBTA_GATT_PERM;
|
||||
typedef tGATT_ATTR_VAL tBTA_GATT_ATTR_VAL;
|
||||
typedef tGATTS_ATTR_CONTROL tBTA_GATTS_ATTR_CONTROL;
|
||||
@@ -604,6 +613,7 @@ typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_REASON reason; /* report disconnect reason */
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
tBTA_GATT_CONN_PARAMS conn_params;
|
||||
} tBTA_GATTS_CONN;
|
||||
|
||||
typedef struct {
|
||||
@@ -937,6 +947,22 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_ReadCharDescr (UINT16 conn_id, UINT16 handle, tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_Read_by_type
|
||||
**
|
||||
** Description This function is called to read a attribute value by uuid
|
||||
**
|
||||
** Parameters conn_id - connection ID.
|
||||
** s_handle - start handle.
|
||||
** e_handle - end hanle
|
||||
** uuid - The attribute UUID.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_GATTC_Read_by_type(UINT16 conn_id, UINT16 s_handle,UINT16 e_handle, tBT_UUID *uuid, tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_GATTC_WriteCharValue
|
||||
|
||||
@@ -129,11 +129,13 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
||||
/* Java I/F callback events */
|
||||
/* events received by tBTA_JV_DM_CBACK */
|
||||
#define BTA_JV_ENABLE_EVT 0 /* JV enabled */
|
||||
#define BTA_JV_DISABLE_EVT 1 /* JV disabled */
|
||||
#define BTA_JV_GET_SCN_EVT 6 /* Reserved an SCN */
|
||||
#define BTA_JV_GET_PSM_EVT 7 /* Reserved a PSM */
|
||||
#define BTA_JV_DISCOVERY_COMP_EVT 8 /* SDP discovery complete */
|
||||
#define BTA_JV_CREATE_RECORD_EVT 11 /* the result for BTA_JvCreateRecord */
|
||||
/* events received by tBTA_JV_L2CAP_CBACK */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_L2CAP_OPEN_EVT 16 /* open status of L2CAP connection */
|
||||
#define BTA_JV_L2CAP_CLOSE_EVT 17 /* L2CAP connection closed */
|
||||
#define BTA_JV_L2CAP_START_EVT 18 /* L2CAP server started */
|
||||
@@ -144,6 +146,7 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
||||
#define BTA_JV_L2CAP_RECEIVE_EVT 23 /* the result for BTA_JvL2capReceive*/
|
||||
#define BTA_JV_L2CAP_WRITE_EVT 24 /* the result for BTA_JvL2capWrite*/
|
||||
#define BTA_JV_L2CAP_WRITE_FIXED_EVT 25 /* the result for BTA_JvL2capWriteFixed */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* events received by tBTA_JV_RFCOMM_CBACK */
|
||||
#define BTA_JV_RFCOMM_OPEN_EVT 26 /* open status of RFCOMM Client connection */
|
||||
@@ -155,7 +158,8 @@ typedef UINT8 tBTA_JV_CONN_STATE;
|
||||
#define BTA_JV_RFCOMM_READ_EVT 32 /* the result for BTA_JvRfcommRead */
|
||||
#define BTA_JV_RFCOMM_WRITE_EVT 33 /* the result for BTA_JvRfcommWrite*/
|
||||
#define BTA_JV_RFCOMM_SRV_OPEN_EVT 34 /* open status of Server RFCOMM connection */
|
||||
#define BTA_JV_MAX_EVT 35 /* max number of JV events */
|
||||
#define BTA_JV_FREE_SCN_EVT 35 /* FREE an SCN */
|
||||
#define BTA_JV_MAX_EVT 36 /* max number of JV events */
|
||||
|
||||
typedef UINT16 tBTA_JV_EVT;
|
||||
|
||||
@@ -167,9 +171,10 @@ typedef struct {
|
||||
|
||||
/* data associated with BTA_JV_DISCOVERY_COMP_EVT_ */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT8 scn_num; /* num of channel */
|
||||
UINT8 scn[BTA_JV_MAX_SCN]; /* channel # */
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT8 scn_num; /* num of channel */
|
||||
UINT8 scn[BTA_JV_MAX_SCN]; /* channel # */
|
||||
const char *service_name[BTA_JV_MAX_SCN]; /* service_name */
|
||||
} tBTA_JV_DISCOVERY_COMP;
|
||||
|
||||
/* data associated with BTA_JV_CREATE_RECORD_EVT */
|
||||
@@ -178,6 +183,7 @@ typedef struct {
|
||||
UINT32 handle; /* The SDP handle */
|
||||
} tBTA_JV_CREATE_RECORD;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
@@ -186,18 +192,6 @@ typedef struct {
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
} tBTA_JV_L2CAP_OPEN;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
void **p_p_cback; /* set them for new socket */
|
||||
void **p_user_data;/* set them for new socket */
|
||||
|
||||
} tBTA_JV_L2CAP_LE_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
@@ -255,6 +249,22 @@ typedef struct {
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_OPEN_EVT for LE sockets */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
INT32 tx_mtu; /* The transmit MTU */
|
||||
void **p_p_cback; /* set them for new socket */
|
||||
void **p_user_data;/* set them for new socket */
|
||||
|
||||
} tBTA_JV_L2CAP_LE_OPEN;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_LE_DATA_IND;
|
||||
|
||||
/* data associated with BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
typedef struct {
|
||||
@@ -265,6 +275,7 @@ typedef struct {
|
||||
UINT16 len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
} tBTA_JV_L2CAP_WRITE_FIXED;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_OPEN_EVT */
|
||||
typedef struct {
|
||||
@@ -272,6 +283,7 @@ typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_OPEN;
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
@@ -280,7 +292,6 @@ typedef struct {
|
||||
BD_ADDR rem_bda; /* The peer address */
|
||||
} tBTA_JV_RFCOMM_SRV_OPEN;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
@@ -294,6 +305,7 @@ typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
UINT32 handle; /* The connection handle */
|
||||
UINT8 sec_id; /* security ID used by this server */
|
||||
UINT8 scn; /* Server channe number */
|
||||
BOOLEAN use_co; /* TRUE to use co_rfc_data */
|
||||
} tBTA_JV_RFCOMM_START;
|
||||
|
||||
@@ -304,19 +316,13 @@ typedef struct {
|
||||
UINT8 sec_id; /* security ID used by this client */
|
||||
BOOLEAN use_co; /* TRUE to use co_rfc_data */
|
||||
} tBTA_JV_RFCOMM_CL_INIT;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT & BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_DATA_IND;
|
||||
|
||||
/*data associated with BTA_JV_L2CAP_DATA_IND_EVT if used for LE */
|
||||
typedef struct {
|
||||
UINT32 handle; /* The connection handle */
|
||||
BT_HDR *p_buf; /* The incoming data */
|
||||
} tBTA_JV_LE_DATA_IND;
|
||||
|
||||
|
||||
/* data associated with BTA_JV_RFCOMM_CONG_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
|
||||
@@ -341,6 +347,7 @@ typedef struct {
|
||||
UINT32 req_id; /* The req_id in the associated BTA_JvRfcommWrite() */
|
||||
int len; /* The length of the data written. */
|
||||
BOOLEAN cong; /* congestion status */
|
||||
BOOLEAN old_cong; /* congestion status */
|
||||
} tBTA_JV_RFCOMM_WRITE;
|
||||
|
||||
/* data associated with BTA_JV_API_SET_PM_PROFILE_EVT */
|
||||
@@ -356,6 +363,24 @@ typedef struct {
|
||||
tBTA_JV_CONN_STATE state; /* JV connection stata */
|
||||
} tBTA_JV_NOTIFY_PM_STATE_CHANGE;
|
||||
|
||||
/* indicate server at which status */
|
||||
typedef enum {
|
||||
BTA_JV_SERVER_START_FAILED,
|
||||
BTA_JV_SERVER_RUNNING,
|
||||
BTA_JV_SERVER_STATUS_MAX,
|
||||
} tBTA_JV_SERVER_STATUS;
|
||||
|
||||
typedef struct {
|
||||
tBTA_JV_SERVER_STATUS server_status;
|
||||
UINT32 slot_id;
|
||||
}tBTA_JV_FREE_SCN_USER_DATA;
|
||||
|
||||
/* data associated with BTA_JV_FREE_SCN_EVT */
|
||||
typedef struct {
|
||||
tBTA_JV_STATUS status; /* Status of the operation */
|
||||
tBTA_JV_SERVER_STATUS server_status; /* Server status */
|
||||
UINT8 scn; /* Server channe number */
|
||||
} tBTA_JV_FREE_SCN;
|
||||
|
||||
/* union of data associated with JV callback */
|
||||
typedef union {
|
||||
@@ -365,6 +390,7 @@ typedef union {
|
||||
UINT8 scn; /* BTA_JV_GET_SCN_EVT */
|
||||
UINT16 psm; /* BTA_JV_GET_PSM_EVT */
|
||||
tBTA_JV_CREATE_RECORD create_rec; /* BTA_JV_CREATE_RECORD_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2CAP_OPEN l2c_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_L2CAP_CLOSE l2c_close; /* BTA_JV_L2CAP_CLOSE_EVT */
|
||||
tBTA_JV_L2CAP_START l2c_start; /* BTA_JV_L2CAP_START_EVT */
|
||||
@@ -372,6 +398,7 @@ typedef union {
|
||||
tBTA_JV_L2CAP_CONG l2c_cong; /* BTA_JV_L2CAP_CONG_EVT */
|
||||
tBTA_JV_L2CAP_READ l2c_read; /* BTA_JV_L2CAP_READ_EVT */
|
||||
tBTA_JV_L2CAP_WRITE l2c_write; /* BTA_JV_L2CAP_WRITE_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_RFCOMM_OPEN rfc_open; /* BTA_JV_RFCOMM_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_SRV_OPEN rfc_srv_open; /* BTA_JV_RFCOMM_SRV_OPEN_EVT */
|
||||
tBTA_JV_RFCOMM_CLOSE rfc_close; /* BTA_JV_RFCOMM_CLOSE_EVT */
|
||||
@@ -382,9 +409,12 @@ typedef union {
|
||||
tBTA_JV_RFCOMM_WRITE rfc_write; /* BTA_JV_RFCOMM_WRITE_EVT */
|
||||
tBTA_JV_DATA_IND data_ind; /* BTA_JV_L2CAP_DATA_IND_EVT
|
||||
BTA_JV_RFCOMM_DATA_IND_EVT */
|
||||
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
|
||||
tBTA_JV_FREE_SCN free_scn; /* BTA_JV_FREE_SCN_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2CAP_LE_OPEN l2c_le_open; /* BTA_JV_L2CAP_OPEN_EVT */
|
||||
tBTA_JV_LE_DATA_IND le_data_ind; /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
|
||||
tBTA_JV_L2CAP_WRITE_FIXED l2c_write_fixed; /* BTA_JV_L2CAP_WRITE_FIXED_EVT */
|
||||
#endif
|
||||
} tBTA_JV;
|
||||
|
||||
/* JAVA DM Interface callback */
|
||||
@@ -393,8 +423,10 @@ typedef void (tBTA_JV_DM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_d
|
||||
/* JAVA RFCOMM interface callback */
|
||||
typedef void *(tBTA_JV_RFCOMM_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_data);
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* JAVA L2CAP interface callback */
|
||||
typedef void (tBTA_JV_L2CAP_CBACK)(tBTA_JV_EVT event, tBTA_JV *p_data, void *user_Data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* JV configuration structure */
|
||||
typedef struct {
|
||||
@@ -424,12 +456,25 @@ extern tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback);
|
||||
**
|
||||
** Function BTA_JvDisable
|
||||
**
|
||||
** Description Disable the Java I/F
|
||||
** Description Disable the Java I/F. When the enable
|
||||
** operation is complete the callback function will be
|
||||
** called with a BTA_JV_DISABLE_EVT.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_JvDisable(void);
|
||||
extern void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvFree
|
||||
**
|
||||
** Description Free JV configuration
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_JvFree(void);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -484,12 +529,17 @@ extern tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data,
|
||||
**
|
||||
** Description This function frees a SCN/PSM that was used
|
||||
** by an application running over RFCOMM or L2CAP.
|
||||
** Parameters
|
||||
** channel The channel to free
|
||||
** conn_type one of BTA_JV_CONN_TYPE_
|
||||
** p_cback tBTA_JV_RFCOMM_CBACK is called with BTA_JV_FREE_SCN_EVT when server frees a SCN/PSM
|
||||
** user_data indicate the RFCOMM server status
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type);
|
||||
extern tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -532,6 +582,7 @@ extern tBTA_JV_STATUS BTA_JvCreateRecordByUser(const char *name, UINT32 channel,
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle);
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
@@ -739,6 +790,7 @@ extern tBTA_JV_STATUS BTA_JvL2capWrite(UINT32 handle, UINT32 req_id,
|
||||
extern tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_id,
|
||||
tBTA_JV_L2CAP_CBACK *p_cback,
|
||||
UINT8 *p_data, UINT16 len, void *user_data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -769,7 +821,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -786,9 +838,9 @@ extern tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data);
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask,
|
||||
tBTA_JV_ROLE role, UINT8 local_scn, UINT8 max_session,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommStartServer(tBTA_SEC sec_mask, tBTA_JV_ROLE role,
|
||||
UINT8 local_scn, UINT8 max_session,
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -815,8 +867,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommStopServer(UINT32 handle, void *user_data);
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id,
|
||||
UINT8 *p_data, UINT16 len);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommRead(UINT32 handle, UINT32 req_id, UINT8 *p_data, UINT16 len);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -843,9 +894,20 @@ extern tBTA_JV_STATUS BTA_JvRfcommReady(UINT32 handle, UINT32 *p_data_size);
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
// extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id);
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommFlowControl
|
||||
**
|
||||
** Description This function gives the credit to the peer
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JVSetPmProfile
|
||||
@@ -865,8 +927,7 @@ extern tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, U
|
||||
** BTA_JV_CONN_CLOSE to remove in case of connection close!
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id,
|
||||
tBTA_JV_CONN_STATE init_st);
|
||||
extern tBTA_JV_STATUS BTA_JvSetPmProfile(UINT32 handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_STATE init_st);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -225,6 +225,7 @@ extern void bta_sys_sendmsg(void *p_msg);
|
||||
extern void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms);
|
||||
extern void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle);
|
||||
extern void bta_sys_free_timer(TIMER_LIST_ENT *p_tle);
|
||||
extern BOOLEAN bta_sys_timer_is_active(TIMER_LIST_ENT *p_tle);
|
||||
extern void bta_sys_disable(tBTA_SYS_HW_MODULE module);
|
||||
extern UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
|
||||
|
||||
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* one of these exists for each client */
|
||||
struct fc_client {
|
||||
struct fc_client *next_all_list;
|
||||
@@ -92,11 +93,10 @@ static void __attribute__((unused)) fc_init(void)
|
||||
pthread_once(&fc_init_once, fc_init_work);
|
||||
}
|
||||
|
||||
|
||||
static void fcchan_conn_chng_cbk(UINT16 chan, BD_ADDR bd_addr, BOOLEAN connected,
|
||||
UINT16 reason, tBT_TRANSPORT );
|
||||
static void fcchan_data_cbk(UINT16 chan, BD_ADDR bd_addr, BT_HDR *p_buf);
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
extern void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str);
|
||||
static inline void logu(const char *title, const uint8_t *p_uuid)
|
||||
@@ -114,6 +114,10 @@ static void bta_jv_pm_conn_idle(tBTA_JV_PM_CB *p_cb);
|
||||
static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE state);
|
||||
tBTA_JV_STATUS bta_jv_set_pm_conn_state(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
|
||||
new_st);
|
||||
static int find_rfc_pcb(void *user_data, tBTA_JV_RFC_CB **cb, tBTA_JV_PCB **pcb);
|
||||
static void bta_jv_port_mgmt_sr_cback(UINT32 code, UINT16 port_handle);
|
||||
static void bta_jv_port_event_sr_cback(UINT32 code, UINT16 port_handle);
|
||||
static int bta_jv_port_data_co_cback(UINT16 port_handle, UINT8 *buf, UINT16 len, int type);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -288,6 +292,12 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
||||
BOOLEAN remove_server = FALSE;
|
||||
int close_pending = 0;
|
||||
|
||||
UINT8 used = 0, i, listen = 0;
|
||||
tPORT_STATE port_state;
|
||||
UINT32 event_mask = BTA_JV_RFC_EV_MASK;
|
||||
UINT32 scn_num = (UINT32)p_cb->scn;
|
||||
tBTA_JV evt_data;
|
||||
|
||||
if (!p_cb || !p_pcb) {
|
||||
APPL_TRACE_ERROR("bta_jv_free_sr_rfc_cb, p_cb or p_pcb cannot be null");
|
||||
return BTA_JV_FAILURE;
|
||||
@@ -363,6 +373,57 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
||||
}
|
||||
p_pcb->handle = 0;
|
||||
p_cb->curr_sess--;
|
||||
|
||||
if ((p_cb->max_sess > 1) &&
|
||||
(p_cb->scn != 0) &&
|
||||
(p_cb->curr_sess == p_cb->max_sess - 1)) {
|
||||
|
||||
for (i = 0; i < p_cb->max_sess; i++) {
|
||||
if (p_cb->rfc_hdl[i] != 0) {
|
||||
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[i] - 1];
|
||||
if (p_pcb->state == BTA_JV_ST_SR_LISTEN) {
|
||||
listen++;
|
||||
}
|
||||
used++;
|
||||
}
|
||||
}
|
||||
APPL_TRACE_DEBUG("%s max_sess=%d used:%d curr_sess:%d, listen:%d si:%d",
|
||||
__func__, p_cb->max_sess, used, p_cb->curr_sess, listen, si);
|
||||
if (used < p_cb->max_sess &&
|
||||
listen == 0 &&
|
||||
0 <= si &&
|
||||
si < BTA_JV_MAX_RFC_SR_SESSION) {
|
||||
/* make sure the server has a listen port */
|
||||
if ((RFCOMM_CreateConnection(p_cb->sec_id, p_cb->scn, TRUE,
|
||||
BTA_JV_DEF_RFC_MTU, (UINT8 *)bd_addr_any, &(p_cb->rfc_hdl[si]), bta_jv_port_mgmt_sr_cback) == PORT_SUCCESS) &&
|
||||
(p_cb->rfc_hdl[si] != 0)) {
|
||||
p_cb->curr_sess++;
|
||||
p_pcb = &bta_jv_cb.port_cb[p_cb->rfc_hdl[si] - 1];
|
||||
p_pcb->state = BTA_JV_ST_SR_LISTEN;
|
||||
p_pcb->port_handle = p_cb->rfc_hdl[si];
|
||||
// p_pcb->user_data = p_pcb_open->user_data;
|
||||
|
||||
PORT_ClearKeepHandleFlag(p_pcb->port_handle);
|
||||
PORT_SetEventCallback(p_pcb->port_handle, bta_jv_port_event_sr_cback);
|
||||
PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback);
|
||||
PORT_SetEventMask(p_pcb->port_handle, event_mask);
|
||||
PORT_GetState(p_pcb->port_handle, &port_state);
|
||||
|
||||
port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
|
||||
|
||||
PORT_SetState(p_pcb->port_handle, &port_state);
|
||||
p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si);
|
||||
APPL_TRACE_DEBUG("%s: p_pcb->handle:0x%x, curr_sess:%d", __func__,
|
||||
p_pcb->handle, p_cb->curr_sess);
|
||||
|
||||
evt_data.rfc_srv_open.handle = 0;
|
||||
evt_data.rfc_srv_open.new_listen_handle = p_pcb->handle;
|
||||
evt_data.rfc_srv_open.status = BTA_JV_SUCCESS;
|
||||
p_pcb->user_data = p_cb->p_cback(BTA_JV_RFCOMM_SRV_OPEN_EVT, &evt_data, (void *)scn_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (p_cb->curr_sess == 0) {
|
||||
p_cb->scn = 0;
|
||||
bta_jv_free_sec_id(&p_cb->sec_id);
|
||||
@@ -377,6 +438,7 @@ static tBTA_JV_STATUS bta_jv_free_rfc_cb(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pc
|
||||
return status;
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_free_l2c_cb
|
||||
@@ -402,6 +464,7 @@ tBTA_JV_STATUS bta_jv_free_l2c_cb(tBTA_JV_L2C_CB *p_cb)
|
||||
p_cb->p_cback = NULL;
|
||||
return status;
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -456,10 +519,9 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
}
|
||||
}
|
||||
|
||||
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, "
|
||||
"app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
|
||||
APPL_TRACE_API("%s, bd_counter = %d, "
|
||||
"appid_counter = %d", __func__, bd_counter, appid_counter);
|
||||
APPL_TRACE_API("%s(jv_handle: 0x%2x), idx: %d, app_id: 0x%x", __func__, jv_handle, i, bta_jv_cb.pm_cb[i].app_id);
|
||||
APPL_TRACE_API("%s, bd_counter = %d, appid_counter = %d", __func__, bd_counter, appid_counter);
|
||||
|
||||
if (bd_counter > 1) {
|
||||
bta_jv_pm_conn_idle(&bta_jv_cb.pm_cb[i]);
|
||||
}
|
||||
@@ -478,14 +540,15 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
tBTA_JV_PCB *p_pcb = bta_jv_rfc_port_to_pcb(bta_jv_cb.rfc_cb[hi].rfc_hdl[si]);
|
||||
if (p_pcb) {
|
||||
if (NULL == p_pcb->p_pm_cb) {
|
||||
APPL_TRACE_WARNING("%s(jv_handle:"
|
||||
" 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to "
|
||||
"pm_cb?", __func__, jv_handle, p_pcb->port_handle, i);
|
||||
APPL_TRACE_WARNING("%s(jv_handle: 0x%x):port_handle: 0x%x, p_pm_cb: %d: no link to pm_cb?",
|
||||
__func__, jv_handle, p_pcb->port_handle, i);
|
||||
}
|
||||
p_cb = &p_pcb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
else {
|
||||
if (jv_handle < BTA_JV_MAX_L2C_CONN) {
|
||||
tBTA_JV_L2C_CB *p_l2c_cb = &bta_jv_cb.l2c_cb[jv_handle];
|
||||
if (NULL == p_l2c_cb->p_pm_cb) {
|
||||
@@ -495,6 +558,8 @@ static tBTA_JV_STATUS bta_jv_free_set_pm_profile_cb(UINT32 jv_handle)
|
||||
p_cb = &p_l2c_cb->p_pm_cb;
|
||||
}
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
if (p_cb) {
|
||||
*p_cb = NULL;
|
||||
status = BTA_JV_SUCCESS;
|
||||
@@ -537,7 +602,9 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
}
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
else {
|
||||
/* use jv handle for l2cap bd address retrieval */
|
||||
for (j = 0; j < BTA_JV_MAX_L2C_CONN; j++) {
|
||||
if (jv_handle == bta_jv_cb.l2c_cb[j].handle) {
|
||||
@@ -552,6 +619,7 @@ static tBTA_JV_PM_CB *bta_jv_alloc_set_pm_profile_cb(UINT32 jv_handle, tBTA_JV_P
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
APPL_TRACE_API("bta_jv_alloc_set_pm_profile_cb(handle 0x%2x, app_id %d): "
|
||||
"idx: %d, (BTA_JV_PM_MAX_NUM: %d), pp_cb: %p", jv_handle, app_id,
|
||||
i, BTA_JV_PM_MAX_NUM, (void *)pp_cb);
|
||||
@@ -634,7 +702,6 @@ BOOLEAN bta_jv_check_psm(UINT16 psm)
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -673,7 +740,12 @@ void bta_jv_enable(tBTA_JV_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_jv_disable (tBTA_JV_MSG *p_data)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
tBTA_JV_STATUS evt_data;
|
||||
evt_data = BTA_JV_SUCCESS;
|
||||
// UNUSED(p_data);
|
||||
if (p_data->disable.p_cback) {
|
||||
p_data->disable.p_cback(BTA_JV_DISABLE_EVT, (tBTA_JV *)&evt_data, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -782,7 +854,17 @@ void bta_jv_get_channel_id(tBTA_JV_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_jv_free_scn(tBTA_JV_MSG *p_data)
|
||||
{
|
||||
UINT16 scn = p_data->free_channel.scn;
|
||||
tBTA_JV_API_FREE_CHANNEL *fc = &(p_data->free_channel);
|
||||
UINT16 scn = fc->scn;
|
||||
tBTA_JV_FREE_SCN evt_data = {
|
||||
.status = BTA_JV_SUCCESS,
|
||||
.server_status = BTA_JV_SERVER_STATUS_MAX,
|
||||
.scn = scn
|
||||
};
|
||||
|
||||
tBTA_JV_FREE_SCN_USER_DATA *user_data = NULL;
|
||||
tBTA_JV_RFC_CB *p_cb = NULL;
|
||||
tBTA_JV_PCB *p_pcb = NULL;
|
||||
|
||||
switch (p_data->free_channel.type) {
|
||||
case BTA_JV_CONN_TYPE_RFCOMM: {
|
||||
@@ -802,6 +884,19 @@ void bta_jv_free_scn(tBTA_JV_MSG *p_data)
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (fc->user_data) {
|
||||
user_data = (tBTA_JV_FREE_SCN_USER_DATA *)fc->user_data;
|
||||
evt_data.server_status = user_data->server_status;
|
||||
if (user_data->server_status == BTA_JV_SERVER_RUNNING && find_rfc_pcb((void *)user_data->slot_id, &p_cb, &p_pcb)) {
|
||||
/* if call bta_jv_rfcomm_stop_server successfully, find_rfc_pcb shall return false */
|
||||
evt_data.status = BTA_JV_FAILURE;
|
||||
}
|
||||
|
||||
if (fc->p_cback) {
|
||||
fc->p_cback(BTA_JV_FREE_SCN_EVT, (tBTA_JV *)&evt_data, (void *)user_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID *u)
|
||||
{
|
||||
@@ -857,6 +952,7 @@ static void bta_jv_start_discovery_cback(UINT16 result, void *user_data)
|
||||
status = BTA_JV_FAILURE;
|
||||
if (result == SDP_SUCCESS || result == SDP_DB_FULL) {
|
||||
tSDP_DISC_REC *p_sdp_rec = NULL;
|
||||
tSDP_DISC_ATTR *p_attr = NULL;
|
||||
tSDP_PROTOCOL_ELEM pe;
|
||||
logu("bta_jv_cb.uuid", bta_jv_cb.uuid.uu.uuid128);
|
||||
tBT_UUID su = shorten_sdp_uuid(&bta_jv_cb.uuid);
|
||||
@@ -865,7 +961,13 @@ static void bta_jv_start_discovery_cback(UINT16 result, void *user_data)
|
||||
p_sdp_rec = SDP_FindServiceUUIDInDb(p_bta_jv_cfg->p_sdp_db, &su, p_sdp_rec);
|
||||
APPL_TRACE_DEBUG("p_sdp_rec:%p", p_sdp_rec);
|
||||
if (p_sdp_rec && SDP_FindProtocolListElemInRec(p_sdp_rec, UUID_PROTOCOL_RFCOMM, &pe)){
|
||||
dcomp.scn[dcomp.scn_num++] = (UINT8) pe.params[0];
|
||||
dcomp.scn[dcomp.scn_num] = (UINT8) pe.params[0];
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_sdp_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
dcomp.service_name[dcomp.scn_num] = (char *)p_attr->attr_value.v.array;
|
||||
} else {
|
||||
dcomp.service_name[dcomp.scn_num] = NULL;
|
||||
}
|
||||
dcomp.scn_num++;
|
||||
status = BTA_JV_SUCCESS;
|
||||
}
|
||||
} while (p_sdp_rec);
|
||||
@@ -1092,6 +1194,7 @@ void bta_jv_delete_record(tBTA_JV_MSG *p_data)
|
||||
}
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_l2cap_client_cback
|
||||
@@ -1517,6 +1620,7 @@ void bta_jv_l2cap_write_fixed(tBTA_JV_MSG *p_data)
|
||||
|
||||
ls->p_cback(BTA_JV_L2CAP_WRITE_FIXED_EVT, (tBTA_JV *)&evt_data, ls->user_data);
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -1596,6 +1700,7 @@ static void bta_jv_port_mgmt_cl_cback(UINT32 code, UINT16 port_handle)
|
||||
evt_data.rfc_close.async = TRUE;
|
||||
if (p_pcb->state == BTA_JV_ST_CL_CLOSING) {
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
}
|
||||
//p_pcb->state = BTA_JV_ST_NONE;
|
||||
//p_pcb->cong = FALSE;
|
||||
@@ -1760,9 +1865,10 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
||||
tBTA_JV_API_RFCOMM_CLOSE *cc = &(p_data->rfcomm_close);
|
||||
tBTA_JV_RFC_CB *p_cb = NULL;
|
||||
tBTA_JV_PCB *p_pcb = NULL;
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_close, rfc handle:%d", cc->handle);
|
||||
tBTA_JV evt_data;
|
||||
APPL_TRACE_DEBUG("%s, rfc handle:%d",__func__, cc->handle);
|
||||
if (!cc->handle) {
|
||||
APPL_TRACE_ERROR("bta_jv_rfcomm_close, rfc handle is null");
|
||||
APPL_TRACE_ERROR("%s, rfc handle is null", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1770,9 +1876,21 @@ void bta_jv_rfcomm_close(tBTA_JV_MSG *p_data)
|
||||
if (!find_rfc_pcb(user_data, &p_cb, &p_pcb)) {
|
||||
return;
|
||||
}
|
||||
if(cc->p_cback) {
|
||||
evt_data.rfc_close.status = BTA_JV_SUCCESS;
|
||||
evt_data.rfc_close.port_status = PORT_LOCAL_CLOSED;
|
||||
evt_data.rfc_close.handle = cc->handle;
|
||||
evt_data.rfc_close.async = TRUE;
|
||||
if (p_pcb && (p_pcb->state == BTA_JV_ST_SR_LISTEN ||
|
||||
p_pcb->state == BTA_JV_ST_SR_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPEN ||
|
||||
p_pcb->state == BTA_JV_ST_CL_OPENING)) {
|
||||
evt_data.rfc_close.async = FALSE;
|
||||
}
|
||||
cc->p_cback(BTA_JV_RFCOMM_CLOSE_EVT, (tBTA_JV *)&evt_data, user_data);
|
||||
}
|
||||
bta_jv_free_rfc_cb(p_cb, p_pcb);
|
||||
APPL_TRACE_DEBUG("bta_jv_rfcomm_close: sec id in use:%d, rfc_cb in use:%d",
|
||||
get_sec_id_used(), get_rfc_cb_used());
|
||||
APPL_TRACE_DEBUG("%s: sec id in use:%d, rfc_cb in use:%d", __func__, get_sec_id_used(), get_rfc_cb_used());
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1976,6 +2094,8 @@ static tBTA_JV_PCB *bta_jv_add_rfc_port(tBTA_JV_RFC_CB *p_cb, tBTA_JV_PCB *p_pcb
|
||||
p_pcb->handle, p_cb->curr_sess);
|
||||
}
|
||||
} else {
|
||||
/* avoid p_pcb always points to the last element of rfc_hdl */
|
||||
p_pcb = p_pcb_open;
|
||||
APPL_TRACE_ERROR("bta_jv_add_rfc_port, cannot create new rfc listen port");
|
||||
}
|
||||
}
|
||||
@@ -2043,6 +2163,7 @@ void bta_jv_rfcomm_start_server(tBTA_JV_MSG *p_data)
|
||||
evt_data.status = BTA_JV_SUCCESS;
|
||||
evt_data.handle = p_pcb->handle;
|
||||
evt_data.sec_id = sec_id;
|
||||
evt_data.scn = rs->local_scn;
|
||||
evt_data.use_co = TRUE;
|
||||
|
||||
PORT_ClearKeepHandleFlag(handle);
|
||||
@@ -2146,16 +2267,16 @@ void bta_jv_rfcomm_write(tBTA_JV_MSG *p_data)
|
||||
evt_data.status = BTA_JV_FAILURE;
|
||||
evt_data.handle = p_pcb->handle;
|
||||
evt_data.req_id = wc->req_id;
|
||||
evt_data.cong = p_pcb->cong;
|
||||
evt_data.old_cong = p_pcb->cong;
|
||||
bta_jv_pm_conn_busy(p_pcb->p_pm_cb);
|
||||
evt_data.len = wc->len;
|
||||
if (!evt_data.cong &&
|
||||
evt_data.len = -1;
|
||||
if (!evt_data.old_cong &&
|
||||
PORT_WriteDataCO(p_pcb->port_handle, &evt_data.len, wc->len, wc->p_data) ==
|
||||
PORT_SUCCESS) {
|
||||
evt_data.status = BTA_JV_SUCCESS;
|
||||
}
|
||||
// update congestion flag
|
||||
evt_data.cong = p_pcb->cong;
|
||||
evt_data.cong = p_pcb->cong;
|
||||
if (p_cb->p_cback) {
|
||||
p_cb->p_cback(BTA_JV_RFCOMM_WRITE_EVT, (tBTA_JV *)&evt_data, p_pcb->user_data);
|
||||
} else {
|
||||
@@ -2164,6 +2285,24 @@ void bta_jv_rfcomm_write(tBTA_JV_MSG *p_data)
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_rfcomm_flow_control
|
||||
**
|
||||
** Description give credits to the peer
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_jv_rfcomm_flow_control(tBTA_JV_MSG *p_data)
|
||||
{
|
||||
tBTA_JV_API_RFCOMM_FLOW_CONTROL *fc = &(p_data->rfcomm_fc);
|
||||
|
||||
tBTA_JV_PCB *p_pcb = fc->p_pcb;
|
||||
PORT_FlowControl_GiveCredit(p_pcb->port_handle, TRUE, fc->credits_given);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_jv_set_pm_profile
|
||||
@@ -2351,7 +2490,7 @@ static void bta_jv_pm_state_change(tBTA_JV_PM_CB *p_cb, const tBTA_JV_CONN_STATE
|
||||
}
|
||||
/**********************************************************************************************/
|
||||
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
static struct fc_channel *fcchan_get(uint16_t chan, char create)
|
||||
{
|
||||
struct fc_channel *t = fc_channels;
|
||||
@@ -2791,6 +2930,6 @@ extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data)
|
||||
fcclient_free(t);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
|
||||
@@ -69,6 +69,16 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
||||
int i;
|
||||
|
||||
APPL_TRACE_API( "BTA_JvEnable");
|
||||
|
||||
#if BTA_DYNAMIC_MEMORY == TRUE
|
||||
/* Malloc buffer for JV configuration structure */
|
||||
p_bta_jv_cfg->p_sdp_raw_data = (UINT8 *)osi_malloc(p_bta_jv_cfg->sdp_raw_size);
|
||||
p_bta_jv_cfg->p_sdp_db = (tSDP_DISCOVERY_DB *)osi_malloc(p_bta_jv_cfg->sdp_db_size);
|
||||
if (p_bta_jv_cfg->p_sdp_raw_data == NULL || p_bta_jv_cfg->p_sdp_db == NULL) {
|
||||
return BTA_JV_NO_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (p_cback && FALSE == bta_sys_is_register(BTA_ID_JV)) {
|
||||
memset(&bta_jv_cb, 0, sizeof(tBTA_JV_CB));
|
||||
/* set handle to invalid value by default */
|
||||
@@ -85,8 +95,11 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
||||
bta_sys_sendmsg(p_buf);
|
||||
status = BTA_JV_SUCCESS;
|
||||
}
|
||||
} else if (p_cback == NULL) {
|
||||
APPL_TRACE_ERROR("No p_cback.");
|
||||
} else {
|
||||
APPL_TRACE_ERROR("JVenable fails");
|
||||
APPL_TRACE_WARNING("No need to Init again.");
|
||||
// status = BTA_JV_SUCCESS;
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
@@ -100,18 +113,39 @@ tBTA_JV_STATUS BTA_JvEnable(tBTA_JV_DM_CBACK *p_cback)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_JvDisable(void)
|
||||
void BTA_JvDisable(tBTA_JV_RFCOMM_CBACK *p_cback)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
tBTA_JV_API_DISABLE *p_buf;
|
||||
|
||||
APPL_TRACE_API( "BTA_JvDisable");
|
||||
bta_sys_deregister(BTA_ID_JV);
|
||||
if ((p_buf = (BT_HDR *) osi_malloc(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_JV_API_DISABLE_EVT;
|
||||
if ((p_buf = (tBTA_JV_API_DISABLE *) osi_malloc(sizeof(tBTA_JV_API_DISABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_JV_API_DISABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvFree
|
||||
**
|
||||
** Description Free JV configuration
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_JvFree(void)
|
||||
{
|
||||
#if BTA_DYNAMIC_MEMORY == TRUE
|
||||
/* Free buffer for JV configuration structure */
|
||||
osi_free(p_bta_jv_cfg->p_sdp_raw_data);
|
||||
osi_free(p_bta_jv_cfg->p_sdp_db);
|
||||
p_bta_jv_cfg->p_sdp_raw_data = NULL;
|
||||
p_bta_jv_cfg->p_sdp_db = NULL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvIsEnable
|
||||
@@ -199,12 +233,14 @@ tBTA_JV_STATUS BTA_JvGetChannelId(int conn_type, void *user_data, INT32 channel)
|
||||
** Parameters
|
||||
** channel The channel to free
|
||||
** conn_type one of BTA_JV_CONN_TYPE_
|
||||
** p_cback tBTA_JV_RFCOMM_CBACK is called with when server
|
||||
** user_data indicate the RFCOMM server status
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
|
||||
tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_FREE_CHANNEL *p_msg;
|
||||
@@ -214,6 +250,8 @@ tBTA_JV_STATUS BTA_JvFreeChannel(UINT16 channel, int conn_type)
|
||||
p_msg->hdr.event = BTA_JV_API_FREE_SCN_EVT;
|
||||
p_msg->scn = channel;
|
||||
p_msg->type = conn_type;
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
}
|
||||
@@ -310,6 +348,7 @@ tBTA_JV_STATUS BTA_JvDeleteRecord(UINT32 handle)
|
||||
return (status);
|
||||
}
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvL2capConnectLE
|
||||
@@ -823,6 +862,7 @@ tBTA_JV_STATUS BTA_JvL2capWriteFixed(UINT16 channel, BD_ADDR *addr, UINT32 req_i
|
||||
|
||||
return (status);
|
||||
}
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@@ -868,19 +908,20 @@ tBTA_JV_STATUS BTA_JvRfcommConnect(tBTA_SEC sec_mask,
|
||||
** Function BTA_JvRfcommClose
|
||||
**
|
||||
** Description This function closes an RFCOMM connection
|
||||
**
|
||||
** When the connection is established or failed,
|
||||
** tBTA_JV_RFCOMM_CBACK is called with BTA_JV_RFCOMM_CLOSE_EVT
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
|
||||
tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, tBTA_JV_RFCOMM_CBACK *p_cback, void *user_data)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_RFCOMM_CLOSE *p_msg;
|
||||
UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1;
|
||||
UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle);
|
||||
|
||||
APPL_TRACE_API( "BTA_JvRfcommClose");
|
||||
APPL_TRACE_API( "%s", __func__);
|
||||
if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
|
||||
si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
|
||||
(p_msg = (tBTA_JV_API_RFCOMM_CLOSE *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_CLOSE))) != NULL) {
|
||||
@@ -888,6 +929,7 @@ tBTA_JV_STATUS BTA_JvRfcommClose(UINT32 handle, void *user_data)
|
||||
p_msg->handle = handle;
|
||||
p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
|
||||
p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
|
||||
p_msg->p_cback = p_cback;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
@@ -1095,6 +1137,38 @@ tBTA_JV_STATUS BTA_JvRfcommWrite(UINT32 handle, UINT32 req_id, int len, UINT8 *p
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_JvRfcommFlowControl
|
||||
**
|
||||
** Description This function gives credits to the peer
|
||||
**
|
||||
** Returns BTA_JV_SUCCESS, if the request is being processed.
|
||||
** BTA_JV_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_JV_STATUS BTA_JvRfcommFlowControl(UINT32 handle, UINT16 credits_given)
|
||||
{
|
||||
tBTA_JV_STATUS status = BTA_JV_FAILURE;
|
||||
tBTA_JV_API_RFCOMM_FLOW_CONTROL *p_msg;
|
||||
UINT32 hi = ((handle & BTA_JV_RFC_HDL_MASK) & ~BTA_JV_RFCOMM_MASK) - 1;
|
||||
UINT32 si = BTA_JV_RFC_HDL_TO_SIDX(handle);
|
||||
|
||||
APPL_TRACE_API( "BTA_JvRfcommFlowControl");
|
||||
APPL_TRACE_DEBUG( "handle:0x%x, hi:%d, si:%d", handle, hi, si);
|
||||
if (hi < BTA_JV_MAX_RFC_CONN && bta_jv_cb.rfc_cb[hi].p_cback &&
|
||||
si < BTA_JV_MAX_RFC_SR_SESSION && bta_jv_cb.rfc_cb[hi].rfc_hdl[si] &&
|
||||
(p_msg = (tBTA_JV_API_RFCOMM_FLOW_CONTROL *)osi_malloc(sizeof(tBTA_JV_API_RFCOMM_FLOW_CONTROL))) != NULL) {
|
||||
p_msg->hdr.event = BTA_JV_API_RFCOMM_FLOW_CONTROL_EVT;
|
||||
p_msg->p_cb = &bta_jv_cb.rfc_cb[hi];
|
||||
p_msg->p_pcb = &bta_jv_cb.port_cb[p_msg->p_cb->rfc_hdl[si] - 1];
|
||||
p_msg->credits_given = credits_given;
|
||||
APPL_TRACE_API( "credits given %d", credits_given);
|
||||
bta_sys_sendmsg(p_msg);
|
||||
status = BTA_JV_SUCCESS;
|
||||
}
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -43,15 +43,22 @@
|
||||
* between BTA_JvEnable and BTA_JvDisable
|
||||
* p_bta_jv_cfg->p_sdp_raw_data can be allocated before calling BTA_JvStartDiscovery
|
||||
* it can be de-allocated after the last call to access the database */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
static UINT8 bta_jv_sdp_raw_data[BTA_JV_SDP_RAW_DATA_SIZE];
|
||||
static UINT8 __attribute__ ((aligned(4))) bta_jv_sdp_db_data[BTA_JV_SDP_DB_SIZE];
|
||||
#endif
|
||||
|
||||
/* JV configuration structure */
|
||||
const tBTA_JV_CFG bta_jv_cfg = {
|
||||
BTA_JV_SDP_RAW_DATA_SIZE, /* The size of p_sdp_raw_data */
|
||||
BTA_JV_SDP_DB_SIZE, /* The size of p_sdp_db_data */
|
||||
bta_jv_sdp_raw_data, /* The data buffer to keep raw data */
|
||||
/* const */ tBTA_JV_CFG bta_jv_cfg = {
|
||||
BTA_JV_SDP_RAW_DATA_SIZE, /* The size of p_sdp_raw_data */
|
||||
BTA_JV_SDP_DB_SIZE, /* The size of p_sdp_db_data */
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
bta_jv_sdp_raw_data, /* The data buffer to keep raw data */
|
||||
(tSDP_DISCOVERY_DB *)bta_jv_sdp_db_data /* The data buffer to keep SDP database */
|
||||
#else
|
||||
NULL,
|
||||
NULL
|
||||
#endif
|
||||
};
|
||||
|
||||
tBTA_JV_CFG *p_bta_jv_cfg = (tBTA_JV_CFG *) &bta_jv_cfg;
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_JV_CB bta_jv_cb;
|
||||
#else
|
||||
tBTA_JV_CB *bta_jv_cb_ptr;
|
||||
#endif
|
||||
|
||||
/* state machine action enumeration list */
|
||||
@@ -52,25 +54,30 @@ const tBTA_JV_ACTION bta_jv_action[] = {
|
||||
bta_jv_start_discovery, /* BTA_JV_API_START_DISCOVERY_EVT */
|
||||
bta_jv_create_record, /* BTA_JV_API_CREATE_RECORD_EVT */
|
||||
bta_jv_delete_record, /* BTA_JV_API_DELETE_RECORD_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
bta_jv_l2cap_connect, /* BTA_JV_API_L2CAP_CONNECT_EVT */
|
||||
bta_jv_l2cap_close, /* BTA_JV_API_L2CAP_CLOSE_EVT */
|
||||
bta_jv_l2cap_start_server, /* BTA_JV_API_L2CAP_START_SERVER_EVT */
|
||||
bta_jv_l2cap_stop_server, /* BTA_JV_API_L2CAP_STOP_SERVER_EVT */
|
||||
bta_jv_l2cap_read, /* BTA_JV_API_L2CAP_READ_EVT */
|
||||
bta_jv_l2cap_write, /* BTA_JV_API_L2CAP_WRITE_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
bta_jv_rfcomm_connect, /* BTA_JV_API_RFCOMM_CONNECT_EVT */
|
||||
bta_jv_rfcomm_close, /* BTA_JV_API_RFCOMM_CLOSE_EVT */
|
||||
bta_jv_rfcomm_start_server, /* BTA_JV_API_RFCOMM_START_SERVER_EVT */
|
||||
bta_jv_rfcomm_stop_server, /* BTA_JV_API_RFCOMM_STOP_SERVER_EVT */
|
||||
bta_jv_rfcomm_read, /* BTA_JV_API_RFCOMM_READ_EVT */
|
||||
bta_jv_rfcomm_write, /* BTA_JV_API_RFCOMM_WRITE_EVT */
|
||||
bta_jv_rfcomm_flow_control, /* BTA_JV_API_RFCOMM_FLOW_CONTROL_EVT */
|
||||
bta_jv_set_pm_profile, /* BTA_JV_API_SET_PM_PROFILE_EVT */
|
||||
bta_jv_change_pm_state, /* BTA_JV_API_PM_STATE_CHANGE_EVT */
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
bta_jv_l2cap_connect_le, /* BTA_JV_API_L2CAP_CONNECT_LE_EVT */
|
||||
bta_jv_l2cap_start_server_le, /* BTA_JV_API_L2CAP_START_SERVER_LE_EVT */
|
||||
bta_jv_l2cap_stop_server_le, /* BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT */
|
||||
bta_jv_l2cap_write_fixed, /* BTA_JV_API_L2CAP_WRITE_FIXED_EVT */
|
||||
bta_jv_l2cap_close_fixed, /* BTA_JV_API_L2CAP_CLOSE_FIXED_EVT */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
|
||||
@@ -48,25 +48,30 @@ enum {
|
||||
BTA_JV_API_START_DISCOVERY_EVT,
|
||||
BTA_JV_API_CREATE_RECORD_EVT,
|
||||
BTA_JV_API_DELETE_RECORD_EVT,
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
BTA_JV_API_L2CAP_CONNECT_EVT,
|
||||
BTA_JV_API_L2CAP_CLOSE_EVT,
|
||||
BTA_JV_API_L2CAP_START_SERVER_EVT,
|
||||
BTA_JV_API_L2CAP_STOP_SERVER_EVT,
|
||||
BTA_JV_API_L2CAP_READ_EVT,
|
||||
BTA_JV_API_L2CAP_WRITE_EVT,
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
BTA_JV_API_RFCOMM_CONNECT_EVT,
|
||||
BTA_JV_API_RFCOMM_CLOSE_EVT,
|
||||
BTA_JV_API_RFCOMM_START_SERVER_EVT,
|
||||
BTA_JV_API_RFCOMM_STOP_SERVER_EVT,
|
||||
BTA_JV_API_RFCOMM_READ_EVT,
|
||||
BTA_JV_API_RFCOMM_WRITE_EVT,
|
||||
BTA_JV_API_RFCOMM_FLOW_CONTROL_EVT,
|
||||
BTA_JV_API_SET_PM_PROFILE_EVT,
|
||||
BTA_JV_API_PM_STATE_CHANGE_EVT,
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
BTA_JV_API_L2CAP_CONNECT_LE_EVT,
|
||||
BTA_JV_API_L2CAP_START_SERVER_LE_EVT,
|
||||
BTA_JV_API_L2CAP_STOP_SERVER_LE_EVT,
|
||||
BTA_JV_API_L2CAP_WRITE_FIXED_EVT,
|
||||
BTA_JV_API_L2CAP_CLOSE_FIXED_EVT,
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
BTA_JV_MAX_INT_EVT
|
||||
};
|
||||
|
||||
@@ -80,6 +85,12 @@ typedef struct {
|
||||
tBTA_JV_DM_CBACK *p_cback;
|
||||
} tBTA_JV_API_ENABLE;
|
||||
|
||||
/* data type for BTA_JV_API_DISABLE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
} tBTA_JV_API_DISABLE;
|
||||
|
||||
/* data type for BTA_JV_API_START_DISCOVERY_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -115,6 +126,8 @@ enum {
|
||||
BTA_JV_ST_SR_CLOSING
|
||||
} ;
|
||||
typedef UINT8 tBTA_JV_STATE;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_ST_CL_MAX BTA_JV_ST_CL_CLOSING
|
||||
/* JV L2CAP control block */
|
||||
typedef struct {
|
||||
@@ -127,6 +140,7 @@ typedef struct {
|
||||
tBTA_JV_PM_CB *p_pm_cb; /* ptr to pm control block, NULL: unused */
|
||||
void *user_data; /* user data for callback from higher layers */
|
||||
} tBTA_JV_L2C_CB;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
#define BTA_JV_RFC_HDL_MASK 0xFF
|
||||
#define BTA_JV_RFCOMM_MASK 0x80
|
||||
@@ -156,6 +170,7 @@ typedef struct {
|
||||
int curr_sess; /* current sessions count*/
|
||||
} tBTA_JV_RFC_CB;
|
||||
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
/* data type for BTA_JV_API_L2CAP_CONNECT_EVT & BTA_JV_API_L2CAP_CONNECT_LE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
@@ -233,6 +248,7 @@ typedef struct {
|
||||
UINT16 len;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_L2CAP_WRITE_FIXED;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
|
||||
/* data type for BTA_JV_API_RFCOMM_CONNECT_EVT */
|
||||
typedef struct {
|
||||
@@ -294,12 +310,21 @@ typedef struct {
|
||||
tBTA_JV_PCB *p_pcb;
|
||||
} tBTA_JV_API_RFCOMM_WRITE;
|
||||
|
||||
/* data type for BTA_JV_API_RFCOMM_FLOW_CONTROL_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_JV_RFC_CB *p_cb;
|
||||
tBTA_JV_PCB *p_pcb;
|
||||
UINT16 credits_given;
|
||||
} tBTA_JV_API_RFCOMM_FLOW_CONTROL;
|
||||
|
||||
/* data type for BTA_JV_API_RFCOMM_CLOSE_EVT */
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT32 handle;
|
||||
tBTA_JV_RFC_CB *p_cb;
|
||||
tBTA_JV_PCB *p_pcb;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_RFCOMM_CLOSE;
|
||||
|
||||
@@ -326,6 +351,8 @@ typedef struct {
|
||||
BT_HDR hdr;
|
||||
INT32 type; /* One of BTA_JV_CONN_TYPE_ */
|
||||
UINT16 scn;
|
||||
tBTA_JV_RFCOMM_CBACK *p_cback;
|
||||
void *user_data;
|
||||
} tBTA_JV_API_FREE_CHANNEL;
|
||||
|
||||
/* data type for BTA_JV_API_ALLOC_CHANNEL_EVT */
|
||||
@@ -340,24 +367,28 @@ typedef union {
|
||||
/* GKI event buffer header */
|
||||
BT_HDR hdr;
|
||||
tBTA_JV_API_ENABLE enable;
|
||||
tBTA_JV_API_DISABLE disable;
|
||||
tBTA_JV_API_START_DISCOVERY start_discovery;
|
||||
tBTA_JV_API_ALLOC_CHANNEL alloc_channel;
|
||||
tBTA_JV_API_FREE_CHANNEL free_channel;
|
||||
tBTA_JV_API_CREATE_RECORD create_record;
|
||||
tBTA_JV_API_ADD_ATTRIBUTE add_attr;
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_API_L2CAP_CONNECT l2cap_connect;
|
||||
tBTA_JV_API_L2CAP_READ l2cap_read;
|
||||
tBTA_JV_API_L2CAP_WRITE l2cap_write;
|
||||
tBTA_JV_API_L2CAP_CLOSE l2cap_close;
|
||||
tBTA_JV_API_L2CAP_SERVER l2cap_server;
|
||||
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_API_RFCOMM_CONNECT rfcomm_connect;
|
||||
tBTA_JV_API_RFCOMM_READ rfcomm_read;
|
||||
tBTA_JV_API_RFCOMM_WRITE rfcomm_write;
|
||||
tBTA_JV_API_RFCOMM_FLOW_CONTROL rfcomm_fc;
|
||||
tBTA_JV_API_SET_PM_PROFILE set_pm;
|
||||
tBTA_JV_API_PM_STATE_CHANGE change_pm_state;
|
||||
tBTA_JV_API_RFCOMM_CLOSE rfcomm_close;
|
||||
tBTA_JV_API_RFCOMM_SERVER rfcomm_server;
|
||||
tBTA_JV_API_L2CAP_WRITE_FIXED l2cap_write_fixed;
|
||||
} tBTA_JV_MSG;
|
||||
|
||||
/* JV control block */
|
||||
@@ -368,7 +399,9 @@ typedef struct {
|
||||
UINT32 sdp_handle[BTA_JV_MAX_SDP_REC]; /* SDP records created */
|
||||
UINT8 *p_sel_raw_data;/* the raw data of last service select */
|
||||
tBTA_JV_DM_CBACK *p_dm_cback;
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
tBTA_JV_L2C_CB l2c_cb[BTA_JV_MAX_L2C_CONN]; /* index is GAP handle (index) */
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
tBTA_JV_RFC_CB rfc_cb[BTA_JV_MAX_RFC_CONN];
|
||||
tBTA_JV_PCB port_cb[MAX_RFC_PORTS]; /* index of this array is
|
||||
the port_handle, */
|
||||
@@ -407,25 +440,29 @@ extern void bta_jv_free_scn (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_start_discovery (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_create_record (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_delete_record (tBTA_JV_MSG *p_data);
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
extern void bta_jv_l2cap_connect (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_close (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_start_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_stop_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_read (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_write (tBTA_JV_MSG *p_data);
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
extern void bta_jv_rfcomm_connect (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_close (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_start_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_stop_server (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_read (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_write (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_rfcomm_flow_control(tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_set_pm_profile (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_change_pm_state(tBTA_JV_MSG *p_data);
|
||||
#if BTA_JV_L2CAP_INCLUDED
|
||||
extern void bta_jv_l2cap_connect_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_start_server_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_stop_server_le (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_write_fixed (tBTA_JV_MSG *p_data);
|
||||
extern void bta_jv_l2cap_close_fixed (tBTA_JV_MSG *p_data);
|
||||
|
||||
#endif /* BTA_JV_L2CAP_INCLUDED */
|
||||
#endif ///defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE
|
||||
#endif /* BTA_JV_INT_H */
|
||||
|
||||
@@ -501,7 +501,6 @@ void bta_sys_event(BT_HDR *p_msg)
|
||||
if (freebuf) {
|
||||
osi_free(p_msg);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -635,6 +634,26 @@ UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
|
||||
return remaining_ms;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_sys_timer_is_active
|
||||
**
|
||||
** Description Get info of one-shot timer is active or not.
|
||||
**
|
||||
** Returns true if timer is exist and active, false otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_sys_timer_is_active(TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
assert(p_tle != NULL);
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm != NULL && osi_alarm_is_active(alarm)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "common/bt_target.h"
|
||||
#include "btc/btc_storage.h"
|
||||
#include "btc/btc_ble_storage.h"
|
||||
#include "esp_gap_ble_api.h"
|
||||
#include "btc_gap_ble.h"
|
||||
#include "btm_int.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_gatt_api.h"
|
||||
@@ -103,7 +103,7 @@ void btc_dm_sec_arg_deep_copy(btc_msg_t *msg, void *dst, void *src)
|
||||
|
||||
void btc_dm_sec_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_DM_SEC;
|
||||
@@ -304,11 +304,11 @@ static void btc_dm_link_up_evt(tBTA_DM_LINK_UP *p_link_up)
|
||||
BD_ADDR bd_addr;
|
||||
bt_bdaddr_t bt_bdaddr;
|
||||
|
||||
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
|
||||
if (p_link_up->sc_downgrade == 1) {
|
||||
memcpy(bt_bdaddr.address, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
if (btc_storage_remove_bonded_device(&bt_bdaddr) == BT_STATUS_SUCCESS) {
|
||||
memcpy(bd_addr, p_link_up->bd_addr, sizeof(BD_ADDR));
|
||||
if (BTA_DmRemoveDevice(bd_addr, BT_TRANSPORT_BR_EDR) == BTA_SUCCESS) {
|
||||
BTC_TRACE_EVENT(" %s() Bonding information removed.", __FUNCTION__);
|
||||
} else {
|
||||
@@ -391,6 +391,7 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
break;
|
||||
default:
|
||||
status = BT_STATUS_FAIL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
@@ -404,11 +405,10 @@ static void btc_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
|
||||
memcpy(param.auth_cmpl.bda, p_auth_cmpl->bd_addr, ESP_BD_ADDR_LEN);
|
||||
memcpy(param.auth_cmpl.device_name, p_auth_cmpl->bd_name, ESP_BT_GAP_MAX_BDNAME_LEN + 1);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
@@ -427,11 +427,10 @@ static void btc_dm_pin_req_evt(tBTA_DM_PIN_REQ *p_pin_req)
|
||||
param.pin_req.min_16_digit = p_pin_req->min_16_digit;
|
||||
memcpy(param.pin_req.bda, p_pin_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
@@ -455,11 +454,10 @@ static void btc_dm_sp_cfm_req_evt(tBTA_DM_SP_CFM_REQ *p_cfm_req)
|
||||
param.cfm_req.num_val = p_cfm_req->num_val;
|
||||
memcpy(param.cfm_req.bda, p_cfm_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
@@ -476,11 +474,10 @@ static void btc_dm_sp_key_notif_evt(tBTA_DM_SP_KEY_NOTIF *p_key_notif)
|
||||
param.key_notif.passkey = p_key_notif->passkey;
|
||||
memcpy(param.key_notif.bda, p_key_notif->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
@@ -496,16 +493,43 @@ static void btc_dm_sp_key_req_evt(tBTA_DM_SP_KEY_REQ *p_key_req)
|
||||
msg.act = BTC_GAP_BT_KEY_REQ_EVT;
|
||||
memcpy(param.key_req.bda, p_key_req->bd_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
ret = btc_transfer_context(&msg, ¶m,
|
||||
sizeof(esp_bt_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
#endif /// BT_SSP_INCLUDED == TRUE
|
||||
|
||||
static void btc_dm_dev_unpaired_evt(tBTA_DM_LINK_DOWN *p_link_down)
|
||||
{
|
||||
esp_bt_gap_cb_param_t param;
|
||||
BTC_TRACE_DEBUG("%s",__func__);
|
||||
memcpy(param.remove_bond_dev_cmpl.bda, p_link_down->bd_addr, ESP_BD_ADDR_LEN);
|
||||
btm_set_bond_type_dev(p_link_down->bd_addr, BOND_TYPE_UNKNOWN);
|
||||
if (p_link_down->status == HCI_SUCCESS) {
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
param.remove_bond_dev_cmpl.status = btc_storage_remove_bonded_device((bt_bdaddr_t *)param.remove_bond_dev_cmpl.bda);
|
||||
} else {
|
||||
param.remove_bond_dev_cmpl.status = ESP_BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BT;
|
||||
msg.act = BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT;
|
||||
|
||||
ret = btc_inter_profile_call(&msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
#endif /// BTC_GAP_BT_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
tBTA_SERVICE_MASK btc_get_enabled_services_mask(void)
|
||||
{
|
||||
return btc_enabled_services;
|
||||
@@ -643,16 +667,7 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
|
||||
case BTA_DM_DEV_UNPAIRED_EVT: {
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bt_bdaddr_t bd_addr;
|
||||
BTC_TRACE_DEBUG("BTA_DM_DEV_UNPAIRED_EVT");
|
||||
memcpy(bd_addr.address, p_data->link_down.bd_addr, sizeof(BD_ADDR));
|
||||
btm_set_bond_type_dev(p_data->link_down.bd_addr, BOND_TYPE_UNKNOWN);
|
||||
if (p_data->link_down.status == HCI_SUCCESS) {
|
||||
//remove the bonded key in the config and nvs flash.
|
||||
btc_storage_remove_bonded_device(&bd_addr);
|
||||
}
|
||||
#endif /* #if (SMP_INCLUDED == TRUE) */
|
||||
btc_dm_dev_unpaired_evt(&p_data->link_down);
|
||||
break;
|
||||
}
|
||||
case BTA_DM_BLE_DEV_UNPAIRED_EVT: {
|
||||
@@ -685,13 +700,14 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
#endif /* BTC_GAP_BT_INCLUDED == TRUE */
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
btc_dm_link_up_evt(&p_data->link_up);
|
||||
case BTA_DM_LINK_DOWN_EVT:
|
||||
case BTA_DM_HW_ERROR_EVT:
|
||||
BTC_TRACE_DEBUG( "btc_dm_sec_cback : unhandled event (%d)\n", msg->act );
|
||||
break;
|
||||
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
case BTA_DM_LINK_UP_EVT:
|
||||
btc_dm_link_up_evt(&p_data->link_up);
|
||||
break;
|
||||
#if ((BLE_INCLUDED == TRUE) && (SMP_INCLUDED == TRUE))
|
||||
case BTA_DM_BLE_AUTH_CMPL_EVT: {
|
||||
rsp_app = true;
|
||||
ble_msg.act = ESP_GAP_BLE_AUTH_CMPL_EVT;
|
||||
@@ -854,11 +870,10 @@ void btc_dm_sec_cb_handler(btc_msg_t *msg)
|
||||
}
|
||||
|
||||
if (rsp_app) {
|
||||
ret = btc_transfer_context(&ble_msg, ¶m,
|
||||
sizeof(esp_ble_gap_cb_param_t), NULL);
|
||||
ret = btc_inter_profile_call(&ble_msg, ¶m);
|
||||
|
||||
if (ret != BT_STATUS_SUCCESS) {
|
||||
BTC_TRACE_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
BTC_TRACE_ERROR("%s btc_inter_profile_call failed\n", __func__);
|
||||
}
|
||||
}
|
||||
btc_dm_sec_arg_deep_free(msg);
|
||||
|
||||
@@ -201,7 +201,6 @@ int btc_storage_get_num_bt_bond_devices(void)
|
||||
}
|
||||
}
|
||||
btc_config_unlock();
|
||||
|
||||
return num_dev;
|
||||
}
|
||||
|
||||
@@ -215,15 +214,17 @@ int btc_storage_get_num_bt_bond_devices(void)
|
||||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num)
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num)
|
||||
{
|
||||
bt_bdaddr_t bd_addr;
|
||||
int in_dev_num = *dev_num; /* buffer size */
|
||||
int out_dev_num = 0; /* bond_dev size */
|
||||
|
||||
btc_config_lock();
|
||||
for (const btc_config_section_iter_t *iter = btc_config_section_begin(); iter != btc_config_section_end();
|
||||
iter = btc_config_section_next(iter)) {
|
||||
|
||||
if (dev_num-- <= 0) {
|
||||
if (in_dev_num <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -236,9 +237,12 @@ bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int de
|
||||
btc_config_exist(name, BTC_STORAGE_LINK_KEY_STR)) {
|
||||
string_to_bdaddr(name, &bd_addr);
|
||||
memcpy(bond_dev, &bd_addr, sizeof(bt_bdaddr_t));
|
||||
in_dev_num--;
|
||||
out_dev_num++;
|
||||
bond_dev++;
|
||||
}
|
||||
}
|
||||
*dev_num = out_dev_num; /* out_dev_num <= in_dev_num */
|
||||
btc_config_unlock();
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
|
||||
@@ -89,6 +89,6 @@ int btc_storage_get_num_bt_bond_devices(void);
|
||||
** BT_STATUS_FAIL otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int dev_num);
|
||||
bt_status_t btc_storage_get_bonded_bt_devices_list(bt_bdaddr_t *bond_dev, int *dev_num);
|
||||
|
||||
#endif /* BTC_STORAGE_H */
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
#include "blufi_int.h"
|
||||
|
||||
#include "esp_blufi_api.h"
|
||||
#include "esp_gatt_common_api.h"
|
||||
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
|
||||
#define BT_BD_ADDR_STR "%02x:%02x:%02x:%02x:%02x:%02x"
|
||||
#define BT_BD_ADDR_HEX(addr) addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]
|
||||
@@ -283,6 +284,7 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
memcpy(blufi_env.remote_bda, p_data->conn.remote_bda, sizeof(esp_bd_addr_t));
|
||||
blufi_env.conn_id = p_data->conn.conn_id;
|
||||
blufi_env.is_connected = true;
|
||||
blufi_env.recv_seq = blufi_env.send_seq = 0;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
@@ -305,7 +307,6 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
|
||||
memcpy(blufi_env.remote_bda, p_data->conn.remote_bda, sizeof(esp_bd_addr_t));
|
||||
blufi_env.conn_id = p_data->conn.conn_id;
|
||||
blufi_env.is_connected = false;
|
||||
blufi_env.recv_seq = blufi_env.send_seq = 0;
|
||||
blufi_env.sec_mode = 0x0;
|
||||
|
||||
@@ -456,6 +457,7 @@ static void btc_blufi_recv_handler(uint8_t *data, int len)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
{
|
||||
struct blufi_hdr *hdr = NULL;
|
||||
@@ -463,6 +465,11 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
uint16_t checksum;
|
||||
int ret;
|
||||
|
||||
if (blufi_env.is_connected == false) {
|
||||
BTC_TRACE_ERROR("blufi connection has been disconnected \n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (remain_len > 0) {
|
||||
if (remain_len > blufi_env.frag_size) {
|
||||
hdr = osi_malloc(sizeof(struct blufi_hdr) + 2 + blufi_env.frag_size + 2);
|
||||
@@ -526,10 +533,21 @@ void btc_blufi_send_encap(uint8_t type, uint8_t *data, int total_data_len)
|
||||
remain_len -= hdr->data_len;
|
||||
}
|
||||
|
||||
btc_blufi_send_notify((uint8_t *)hdr,
|
||||
retry:
|
||||
if (blufi_env.is_connected == false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (esp_ble_get_cur_sendable_packets_num(BTC_GATT_GET_CONN_ID(blufi_env.conn_id)) > 0) {
|
||||
btc_blufi_send_notify((uint8_t *)hdr,
|
||||
((hdr->fc & BLUFI_FC_CHECK) ?
|
||||
hdr->data_len + sizeof(struct blufi_hdr) + 2 :
|
||||
hdr->data_len + sizeof(struct blufi_hdr)));
|
||||
} else {
|
||||
BTC_TRACE_WARNING("%s wait to send blufi custom data\n", __func__);
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
goto retry;
|
||||
}
|
||||
|
||||
osi_free(hdr);
|
||||
hdr = NULL;
|
||||
@@ -1117,4 +1135,4 @@ uint16_t btc_blufi_get_version(void)
|
||||
return BTC_BLUFI_VERSION;
|
||||
}
|
||||
|
||||
#endif ///GATTS_INCLUDED == TRUE
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
//#include "esp_wifi.h"
|
||||
|
||||
#if (GATTS_INCLUDED == TRUE)
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
extern tBLUFI_ENV blufi_env;
|
||||
|
||||
void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len)
|
||||
@@ -269,4 +269,5 @@ void btc_blufi_protocol_handler(uint8_t type, uint8_t *data, int len)
|
||||
}
|
||||
}
|
||||
|
||||
#endif ///(GATTS_INCLUDED == TRUE)
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#ifndef __BLUFI_INT_H__
|
||||
#define __BLUFI_INT_H__
|
||||
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x02 //Version + Subversion
|
||||
#define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion
|
||||
@@ -184,3 +185,4 @@ void btc_blufi_cb_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src);
|
||||
void btc_blufi_cb_deep_free(btc_msg_t *msg);
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
#endif ///BLUFI_INCLUDED == TRUE
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
*******************************************************************************/
|
||||
void btc_a2dp_on_init(void)
|
||||
{
|
||||
//tput_mon(1, 0, 1);
|
||||
BTC_TRACE_EVENT("A2DP Initialized.");
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
@@ -127,12 +127,16 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
switch (ctrl) {
|
||||
case ESP_A2D_MEDIA_CTRL_CHECK_SRC_RDY:
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_a2dp_source_is_task_shutting_down()) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
} else if ((btc_av_stream_ready() == TRUE) ||
|
||||
(btc_av_stream_started_ready() == TRUE)) {
|
||||
/* check whether av is ready to setup a2dp datapath */
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
if (btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
if (btc_a2dp_source_is_task_shutting_down()) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
} else if ((btc_av_stream_ready() == TRUE) ||
|
||||
(btc_av_stream_started_ready() == TRUE)) {
|
||||
/* check whether av is ready to setup a2dp datapath */
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
@@ -159,6 +163,10 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
}
|
||||
break;
|
||||
case ESP_A2D_MEDIA_CTRL_STOP:
|
||||
if (btc_av_is_connected() == FALSE) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
break;
|
||||
}
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
if (btc_av_get_peer_sep() == AVDT_TSEP_SNK && !btc_a2dp_source_is_streaming() &&
|
||||
btc_av_get_service_id() == BTA_A2DP_SOURCE_SERVICE_ID) {
|
||||
@@ -174,7 +182,6 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
case ESP_A2D_MEDIA_CTRL_SUSPEND:
|
||||
/* local suspend */
|
||||
if (btc_av_stream_started_ready()) {
|
||||
@@ -184,14 +191,15 @@ void btc_a2dp_control_media_ctrl(esp_a2d_media_ctrl_t ctrl)
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
} else if (btc_av_is_connected() == TRUE) {
|
||||
/* we are not in started state; just ack back ok. This can happen if we are
|
||||
remotely suspended; clear REMOTE SUSPEND Flag */
|
||||
btc_av_clear_remote_suspend_flag();
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_SUCCESS);
|
||||
} else {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
}
|
||||
break;
|
||||
|
||||
default :
|
||||
APPL_TRACE_ERROR("### A2DP-MEDIA EVENT %u NOT HANDLED ###", ctrl);
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
|
||||
@@ -88,7 +88,8 @@ enum {
|
||||
layers we might need to temporarily buffer up data */
|
||||
|
||||
/* 18 frames is equivalent to 6.89*18*2.9 ~= 360 ms @ 44.1 khz, 20 ms mediatick */
|
||||
#define MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ (18)
|
||||
#define JITTER_BUFFER_WATER_LEVEL (15)
|
||||
#define MAX_OUTPUT_A2DP_SNK_FRAME_QUEUE_SZ (18 + JITTER_BUFFER_WATER_LEVEL)
|
||||
|
||||
typedef struct {
|
||||
UINT16 num_frames_to_be_processed;
|
||||
@@ -458,7 +459,7 @@ static void btc_a2dp_sink_data_ready(UNUSED_ATTR void *context)
|
||||
tBT_SBC_HDR *p_msg;
|
||||
|
||||
if (fixed_queue_is_empty(btc_aa_snk_cb.RxSbcQ)) {
|
||||
APPL_TRACE_DEBUG(" QUE EMPTY ");
|
||||
APPL_TRACE_ERROR(" QUE EMPTY ");
|
||||
} else {
|
||||
if (btc_aa_snk_cb.rx_flush == TRUE) {
|
||||
btc_a2dp_sink_flush_q(btc_aa_snk_cb.RxSbcQ);
|
||||
@@ -775,8 +776,13 @@ UINT8 btc_a2dp_sink_enque_buf(BT_HDR *p_pkt)
|
||||
p_pkt->offset + p_pkt->len)) != NULL) {
|
||||
memcpy(p_msg, p_pkt, (sizeof(BT_HDR) + p_pkt->offset + p_pkt->len));
|
||||
p_msg->num_frames_to_be_processed = (*((UINT8 *)(p_msg + 1) + p_msg->offset)) & 0x0f;
|
||||
APPL_TRACE_VERBOSE("btc_a2dp_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed);
|
||||
APPL_TRACE_DEBUG("btc_a2dp_sink_enque_buf %d + \n", p_msg->num_frames_to_be_processed);
|
||||
fixed_queue_enqueue(btc_aa_snk_cb.RxSbcQ, p_msg);
|
||||
|
||||
if (fixed_queue_length(btc_aa_snk_cb.RxSbcQ) < JITTER_BUFFER_WATER_LEVEL) {
|
||||
return fixed_queue_length(btc_aa_snk_cb.RxSbcQ);
|
||||
}
|
||||
|
||||
btc_a2dp_sink_data_post(BTC_A2DP_SINK_DATA_EVT);
|
||||
} else {
|
||||
/* let caller deal with a failed allocation */
|
||||
|
||||
@@ -1290,8 +1290,6 @@ BOOLEAN btc_media_aa_read_feeding(void)
|
||||
/* Read Data from data channel */
|
||||
nb_byte_read = btc_aa_src_data_read((uint8_t *)read_buffer, read_size);
|
||||
|
||||
//tput_mon(TRUE, nb_byte_read, FALSE);
|
||||
|
||||
if (nb_byte_read < read_size) {
|
||||
APPL_TRACE_WARNING("### UNDERRUN :: ONLY READ %d BYTES OUT OF %d ###",
|
||||
nb_byte_read, read_size);
|
||||
@@ -1503,7 +1501,7 @@ static void btc_a2dp_source_handle_timer(UNUSED_ATTR void *context)
|
||||
log_tstamps_us("media task tx timer");
|
||||
|
||||
#if (BTA_AV_INCLUDED == TRUE)
|
||||
if (btc_a2dp_source_state != BTC_A2DP_SOURCE_STATE_ON){
|
||||
if (btc_a2dp_source_state != BTC_A2DP_SOURCE_STATE_ON || g_a2dp_source_ongoing_deinit){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,18 @@
|
||||
|
||||
#if BTC_AV_INCLUDED
|
||||
|
||||
// global variable to inidcate avrc is initialized with a2dp
|
||||
bool g_av_with_rc;
|
||||
// global variable to indicate a2dp is initialized
|
||||
bool g_a2dp_on_init;
|
||||
// global variable to indicate a2dp is deinitialized
|
||||
bool g_a2dp_on_deinit;
|
||||
// global variable to indicate a2dp source deinitialization is ongoing
|
||||
bool g_a2dp_source_ongoing_deinit;
|
||||
// global variable to indicate a2dp sink deinitialization is ongoing
|
||||
bool g_a2dp_sink_ongoing_deinit;
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants & Macros
|
||||
******************************************************************************/
|
||||
@@ -86,6 +98,10 @@ typedef struct {
|
||||
uint16_t uuid;
|
||||
} btc_av_connect_req_t;
|
||||
|
||||
typedef struct {
|
||||
bt_bdaddr_t target_bda;
|
||||
} btc_av_disconn_req_t;
|
||||
|
||||
/*****************************************************************************
|
||||
** Static variables
|
||||
******************************************************************************/
|
||||
@@ -120,6 +136,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *data);
|
||||
static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *data);
|
||||
static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *data);
|
||||
static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *data);
|
||||
static void clean_up(int service_id);
|
||||
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
static bt_status_t btc_a2d_src_init(void);
|
||||
@@ -284,7 +301,7 @@ static void btc_report_audio_state(esp_a2d_audio_state_t state, bt_bdaddr_t *bd_
|
||||
|
||||
static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event: %s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@@ -309,20 +326,34 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
case BTA_AV_PENDING_EVT:
|
||||
case BTC_AV_CONNECT_REQ_EVT: {
|
||||
if (event == BTC_AV_CONNECT_REQ_EVT) {
|
||||
memcpy(&btc_av_cb.peer_bda, &((btc_av_connect_req_t *)p_data)->target_bda,
|
||||
sizeof(bt_bdaddr_t));
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||
memcpy(&btc_av_cb.peer_bda, &((btc_av_connect_req_t *)p_data)->target_bda, sizeof(bt_bdaddr_t));
|
||||
if (g_av_with_rc) {
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||
} else {
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
FALSE, BTA_SEC_AUTHENTICATE, ((btc_av_connect_req_t *)p_data)->uuid);
|
||||
}
|
||||
} else if (event == BTA_AV_PENDING_EVT) {
|
||||
bdcpy(btc_av_cb.peer_bda.address, ((tBTA_AV *)p_data)->pend.bd_addr);
|
||||
UINT16 uuid = (btc_av_cb.service_id == BTA_A2DP_SOURCE_SERVICE_ID) ? UUID_SERVCLASS_AUDIO_SOURCE :
|
||||
UUID_SERVCLASS_AUDIO_SINK;
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, uuid);
|
||||
UINT16 uuid = (btc_av_cb.service_id == BTA_A2DP_SOURCE_SERVICE_ID) ? UUID_SERVCLASS_AUDIO_SOURCE : UUID_SERVCLASS_AUDIO_SINK;
|
||||
if (g_av_with_rc) {
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
TRUE, BTA_SEC_AUTHENTICATE, uuid);
|
||||
} else {
|
||||
BTA_AvOpen(btc_av_cb.peer_bda.address, btc_av_cb.bta_handle,
|
||||
FALSE, BTA_SEC_AUTHENTICATE, uuid);
|
||||
}
|
||||
}
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_OPENING);
|
||||
} break;
|
||||
|
||||
|
||||
case BTC_AV_DISCONNECT_REQ_EVT:
|
||||
BTC_TRACE_WARNING("No Link At All.");
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &((btc_av_disconn_req_t *)p_data)->target_bda, 0);
|
||||
break;
|
||||
|
||||
case BTA_AV_RC_OPEN_EVT:
|
||||
/* IOP_FIX: Jabra 620 only does RC open without AV open whenever it connects. So
|
||||
* as per the AV WP, an AVRC connection cannot exist without an AV connection. Therefore,
|
||||
@@ -333,7 +364,6 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
*
|
||||
* TODO: We may need to do this only on an AVRCP Play. FixMe
|
||||
*/
|
||||
|
||||
#if BTC_AV_SRC_INCLUDED
|
||||
BTC_TRACE_DEBUG("BTA_AV_RC_OPEN_EVT received w/o AV");
|
||||
tle_av_open_on_rc = osi_alarm_new("AVconn", btc_initiate_av_open_tmr_hdlr, NULL, BTC_TIMEOUT_AV_OPEN_ON_RC_SECS * 1000);
|
||||
@@ -361,15 +391,13 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
default:
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
/*****************************************************************************
|
||||
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Function btc_av_state_opening_handler
|
||||
**
|
||||
@@ -382,7 +410,7 @@ static BOOLEAN btc_av_state_idle_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event: %s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@@ -395,35 +423,36 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTA_AV_REJECT_EVT:
|
||||
BTC_TRACE_DEBUG(" Received BTA_AV_REJECT_EVT \n");
|
||||
BTC_TRACE_WARNING(" Received BTA_AV_REJECT_EVT \n");
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), 0);
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||
break;
|
||||
|
||||
case BTA_AV_OPEN_EVT: {
|
||||
tBTA_AV *p_bta_data = (tBTA_AV *)p_data;
|
||||
esp_a2d_connection_state_t state;
|
||||
esp_a2d_connection_state_t conn_stat;
|
||||
btc_sm_state_t av_state;
|
||||
BTC_TRACE_DEBUG("status:%d, edr 0x%x, peer sep %d\n", p_bta_data->open.status,
|
||||
p_bta_data->open.edr, p_bta_data->open.sep);
|
||||
|
||||
if (p_bta_data->open.status == BTA_AV_SUCCESS) {
|
||||
state = ESP_A2D_CONNECTION_STATE_CONNECTED;
|
||||
av_state = BTC_AV_STATE_OPENED;
|
||||
btc_av_cb.edr = p_bta_data->open.edr;
|
||||
|
||||
btc_av_cb.peer_sep = p_bta_data->open.sep;
|
||||
|
||||
conn_stat = ESP_A2D_CONNECTION_STATE_CONNECTED;
|
||||
av_state = BTC_AV_STATE_OPENED;
|
||||
} else {
|
||||
BTC_TRACE_WARNING("BTA_AV_OPEN_EVT::FAILED status: %d\n",
|
||||
p_bta_data->open.status );
|
||||
state = ESP_A2D_CONNECTION_STATE_DISCONNECTED;
|
||||
av_state = BTC_AV_STATE_IDLE;
|
||||
BTC_TRACE_WARNING("BTA_AV_OPEN_EVT::FAILED status: %d\n", p_bta_data->open.status );
|
||||
|
||||
conn_stat = ESP_A2D_CONNECTION_STATE_DISCONNECTED;
|
||||
av_state = BTC_AV_STATE_IDLE;
|
||||
}
|
||||
|
||||
/* inform the application of the event */
|
||||
btc_report_connection_state(state, &(btc_av_cb.peer_bda), 0);
|
||||
btc_report_connection_state(conn_stat, &(btc_av_cb.peer_bda), 0);
|
||||
/* change state to open/idle based on the status */
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, av_state);
|
||||
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SNK) {
|
||||
/* if queued PLAY command, send it now */
|
||||
/* necessary to add this?
|
||||
@@ -432,8 +461,12 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
*/
|
||||
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC &&
|
||||
(p_bta_data->open.status == BTA_AV_SUCCESS)) {
|
||||
/* Bring up AVRCP connection too */
|
||||
BTA_AvOpenRc(btc_av_cb.bta_handle);
|
||||
/* Bring up AVRCP connection too if AVRC Initialized */
|
||||
if(g_av_with_rc) {
|
||||
BTA_AvOpenRc(btc_av_cb.bta_handle);
|
||||
} else {
|
||||
BTC_TRACE_WARNING("AVRC not Init, not using it.");
|
||||
}
|
||||
}
|
||||
btc_queue_advance();
|
||||
} break;
|
||||
@@ -473,11 +506,10 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
}
|
||||
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@@ -498,7 +530,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event: %s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
@@ -539,9 +571,7 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
case BTA_AV_CLOSE_EVT: {
|
||||
tBTA_AV_CLOSE *close = (tBTA_AV_CLOSE *)p_data;
|
||||
/* inform the application that we are disconnecting */
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda),
|
||||
close->disc_rsn);
|
||||
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), close->disc_rsn);
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||
break;
|
||||
}
|
||||
@@ -552,14 +582,12 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
default:
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Function btc_av_state_opened_handler
|
||||
@@ -569,12 +597,11 @@ static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *p_data)
|
||||
** Returns TRUE if event was processed, FALSE otherwise
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
tBTA_AV *p_av = (tBTA_AV *)p_data;
|
||||
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event: %s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
if ( (event == BTA_AV_REMOTE_CMD_EVT) && (btc_av_cb.flags & BTC_AV_FLAG_REMOTE_SUSPEND) &&
|
||||
@@ -654,10 +681,9 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
|
||||
case BTC_AV_DISCONNECT_REQ_EVT:
|
||||
BTA_AvClose(btc_av_cb.bta_handle);
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC && g_av_with_rc == true) {
|
||||
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||
}
|
||||
|
||||
/* inform the application that we are disconnecting */
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTING, &(btc_av_cb.peer_bda), 0);
|
||||
break;
|
||||
@@ -665,18 +691,22 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
case BTA_AV_CLOSE_EVT: {
|
||||
/* avdtp link is closed */
|
||||
btc_a2dp_on_stopped(NULL);
|
||||
|
||||
tBTA_AV_CLOSE *close = (tBTA_AV_CLOSE *)p_data;
|
||||
/* inform the application that we are disconnected */
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda),
|
||||
close->disc_rsn);
|
||||
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), close->disc_rsn);
|
||||
/* change state to idle, send acknowledgement if start is pending */
|
||||
if (btc_av_cb.flags & BTC_AV_FLAG_PENDING_START) {
|
||||
btc_a2dp_control_command_ack(ESP_A2D_MEDIA_CTRL_ACK_FAILURE);
|
||||
/* pending start flag will be cleared when exit current state */
|
||||
}
|
||||
/* change state to idle, send acknowledgement if start is pending */
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||
|
||||
if (g_a2dp_source_ongoing_deinit) {
|
||||
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
} else if (g_a2dp_sink_ongoing_deinit) {
|
||||
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -703,11 +733,10 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
||||
btc_queue_advance();
|
||||
break;
|
||||
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
@@ -728,27 +757,22 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
{
|
||||
tBTA_AV *p_av = (tBTA_AV *)p_data;
|
||||
|
||||
BTC_TRACE_DEBUG("%s event:%s flags %x\n", __FUNCTION__,
|
||||
BTC_TRACE_DEBUG("%s event: %s flags %x\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event), btc_av_cb.flags);
|
||||
|
||||
switch (event) {
|
||||
case BTC_SM_ENTER_EVT:
|
||||
|
||||
/* we are again in started state, clear any remote suspend flags */
|
||||
btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND;
|
||||
|
||||
btc_report_audio_state(ESP_A2D_AUDIO_STATE_STARTED, &(btc_av_cb.peer_bda));
|
||||
|
||||
/* increase the a2dp consumer task priority temporarily when start
|
||||
** audio playing, to avoid overflow the audio packet queue. */
|
||||
// adjust_priority_a2dp(TRUE);
|
||||
|
||||
break;
|
||||
|
||||
case BTC_SM_EXIT_EVT:
|
||||
/* restore the a2dp consumer task priority when stop audio playing. */
|
||||
// adjust_priority_a2dp(FALSE);
|
||||
|
||||
break;
|
||||
|
||||
case BTC_AV_START_STREAM_REQ_EVT:
|
||||
@@ -763,11 +787,9 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
/* fixme -- use suspend = true always to work around issue with BTA AV */
|
||||
case BTC_AV_STOP_STREAM_REQ_EVT:
|
||||
case BTC_AV_SUSPEND_STREAM_REQ_EVT:
|
||||
|
||||
/* set pending flag to ensure btc task is not trying to restart
|
||||
stream while suspend is in progress */
|
||||
btc_av_cb.flags |= BTC_AV_FLAG_LOCAL_SUSPEND_PENDING;
|
||||
|
||||
/* if we were remotely suspended but suspend locally, local suspend
|
||||
always overrides */
|
||||
btc_av_cb.flags &= ~BTC_AV_FLAG_REMOTE_SUSPEND;
|
||||
@@ -787,25 +809,19 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTC_AV_DISCONNECT_REQ_EVT:
|
||||
|
||||
/* request avdtp to close */
|
||||
BTA_AvClose(btc_av_cb.bta_handle);
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC && g_av_with_rc == true) {
|
||||
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||
}
|
||||
|
||||
/* inform the application that we are disconnecting */
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTING, &(btc_av_cb.peer_bda), 0);
|
||||
|
||||
/* wait in closing state until fully closed */
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_CLOSING);
|
||||
break;
|
||||
|
||||
case BTA_AV_SUSPEND_EVT:
|
||||
|
||||
BTC_TRACE_DEBUG("BTA_AV_SUSPEND_EVT status %d, init %d\n",
|
||||
p_av->suspend.status, p_av->suspend.initiator);
|
||||
|
||||
BTC_TRACE_DEBUG("BTA_AV_SUSPEND_EVT status %d, init %d\n", p_av->suspend.status, p_av->suspend.initiator);
|
||||
/* a2dp suspended, stop media task until resumed */
|
||||
btc_a2dp_on_suspended(&p_av->suspend);
|
||||
|
||||
@@ -824,7 +840,6 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
if (p_av->suspend.initiator != TRUE) {
|
||||
/* remote suspend, notify HAL and await audioflinger to
|
||||
suspend/stop stream */
|
||||
|
||||
/* set remote suspend flag to block media task from restarting
|
||||
stream only if we did not already initiate a local suspend */
|
||||
if ((btc_av_cb.flags & BTC_AV_FLAG_LOCAL_SUSPEND_PENDING) == 0) {
|
||||
@@ -843,42 +858,39 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
||||
break;
|
||||
|
||||
case BTA_AV_STOP_EVT:
|
||||
|
||||
btc_av_cb.flags |= BTC_AV_FLAG_PENDING_STOP;
|
||||
btc_a2dp_on_stopped(&p_av->suspend);
|
||||
|
||||
btc_report_audio_state(ESP_A2D_AUDIO_STATE_STOPPED, &(btc_av_cb.peer_bda));
|
||||
|
||||
/* if stop was successful, change state to open */
|
||||
if (p_av->suspend.status == BTA_AV_SUCCESS) {
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_OPENED);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case BTA_AV_CLOSE_EVT: {
|
||||
|
||||
btc_av_cb.flags |= BTC_AV_FLAG_PENDING_STOP;
|
||||
|
||||
/* avdtp link is closed */
|
||||
btc_a2dp_on_stopped(NULL);
|
||||
|
||||
tBTA_AV_CLOSE *close = (tBTA_AV_CLOSE *)p_data;
|
||||
/* inform the application that we are disconnected */
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda),
|
||||
close->disc_rsn);
|
||||
|
||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda), close->disc_rsn);
|
||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||
|
||||
if (g_a2dp_source_ongoing_deinit) {
|
||||
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
} else if (g_a2dp_sink_ongoing_deinit) {
|
||||
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
CHECK_RC_EVENT(event, p_data);
|
||||
|
||||
default:
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__,
|
||||
dump_av_sm_event_name(event));
|
||||
BTC_TRACE_WARNING("%s : unhandled event:%s\n", __FUNCTION__, dump_av_sm_event_name(event));
|
||||
return FALSE;
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -957,7 +969,6 @@ static void btc_av_event_free_data(btc_sm_event_t event, void *p_data)
|
||||
** Returns bt_status_t
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
||||
static bt_status_t btc_av_init(int service_id)
|
||||
{
|
||||
if (btc_av_cb.sm_handle == NULL) {
|
||||
@@ -974,7 +985,11 @@ static bt_status_t btc_av_init(int service_id)
|
||||
}
|
||||
|
||||
if (!stat) {
|
||||
return BT_STATUS_FAIL;
|
||||
g_a2dp_on_init = false;
|
||||
g_a2dp_on_deinit = true;
|
||||
g_a2dp_source_ongoing_deinit = false;
|
||||
g_a2dp_sink_ongoing_deinit = false;
|
||||
goto av_init_fail;
|
||||
}
|
||||
|
||||
/* Also initialize the AV state machine */
|
||||
@@ -986,12 +1001,20 @@ static bt_status_t btc_av_init(int service_id)
|
||||
} else {
|
||||
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
}
|
||||
|
||||
btc_a2dp_on_init();
|
||||
g_a2dp_on_init = true;
|
||||
g_a2dp_on_deinit = false;
|
||||
g_a2dp_source_ongoing_deinit = false;
|
||||
g_a2dp_sink_ongoing_deinit = false;
|
||||
|
||||
esp_a2d_cb_param_t param;
|
||||
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
||||
param.a2d_prof_stat.init_state = ESP_A2D_INIT_SUCCESS;
|
||||
btc_a2d_cb_to_app(ESP_A2D_PROF_STATE_EVT, ¶m);
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
av_init_fail:
|
||||
return BT_STATUS_FAIL;
|
||||
}
|
||||
|
||||
@@ -1038,11 +1061,13 @@ static void clean_up(int service_id)
|
||||
tle_av_open_on_rc = NULL;
|
||||
}
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
}
|
||||
|
||||
btc_dm_disable_service(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
|
||||
if (service_id == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
btc_a2dp_sink_shutdown();
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
btc_dm_disable_service(BTA_A2DP_SINK_SERVICE_ID);
|
||||
}
|
||||
|
||||
@@ -1050,11 +1075,15 @@ static void clean_up(int service_id)
|
||||
btc_sm_shutdown(btc_av_cb.sm_handle);
|
||||
btc_av_cb.sm_handle = NULL;
|
||||
|
||||
if (service_id == BTA_A2DP_SINK_SERVICE_ID) {
|
||||
#if BTC_AV_SINK_INCLUDED
|
||||
btc_a2dp_sink_shutdown();
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
}
|
||||
esp_a2d_cb_param_t param;
|
||||
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
||||
param.a2d_prof_stat.init_state = ESP_A2D_DEINIT_SUCCESS;
|
||||
btc_a2d_cb_to_app(ESP_A2D_PROF_STATE_EVT, ¶m);
|
||||
|
||||
g_a2dp_on_init = false;
|
||||
g_a2dp_on_deinit = true;
|
||||
g_a2dp_source_ongoing_deinit = false;
|
||||
g_a2dp_sink_ongoing_deinit = false;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1229,10 +1258,16 @@ bt_status_t btc_av_execute_service(BOOLEAN b_enable, UINT8 tsep)
|
||||
/* Added BTA_AV_FEAT_NO_SCO_SSPD - this ensures that the BTA does not
|
||||
* auto-suspend av streaming on AG events(SCO or Call). The suspend shall
|
||||
* be initiated by the app/audioflinger layers */
|
||||
BTA_AvEnable(BTA_SEC_AUTHENTICATE, (BTA_AV_FEAT_NO_SCO_SSPD)
|
||||
| BTA_AV_FEAT_RCTG | BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR
|
||||
| BTA_AV_FEAT_RCCT | BTA_AV_FEAT_ADV_CTRL,
|
||||
bte_av_callback);
|
||||
if (g_av_with_rc) {
|
||||
BTC_TRACE_WARNING("A2DP Enable with AVRC")
|
||||
BTA_AvEnable(BTA_SEC_AUTHENTICATE, BTA_AV_FEAT_NO_SCO_SSPD |
|
||||
BTA_AV_FEAT_RCTG | BTA_AV_FEAT_METADATA | BTA_AV_FEAT_VENDOR |
|
||||
BTA_AV_FEAT_RCCT | BTA_AV_FEAT_ADV_CTRL,
|
||||
bte_av_callback);
|
||||
} else {
|
||||
BTC_TRACE_WARNING("A2DP Enable without AVRC")
|
||||
BTA_AvEnable(BTA_SEC_AUTHENTICATE, BTA_AV_FEAT_NO_SCO_SSPD, bte_av_callback);
|
||||
}
|
||||
BTA_AvRegister(BTA_AV_CHNL_AUDIO, BTC_AV_SERVICE_NAME, 0, bte_av_media_callback, &bta_av_a2d_cos, tsep);
|
||||
} else {
|
||||
BTA_AvDeregister(btc_av_cb.bta_handle);
|
||||
@@ -1384,7 +1419,9 @@ void btc_a2dp_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_AV_SINK_API_DISCONNECT_EVT: {
|
||||
CHECK_BTAV_INIT();
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_DISCONNECT_REQ_EVT, NULL);
|
||||
btc_av_disconn_req_t disconn_req;
|
||||
memcpy(&disconn_req.target_bda, &arg->disconn, sizeof(bt_bdaddr_t));
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_DISCONNECT_REQ_EVT, &disconn_req);
|
||||
break;
|
||||
}
|
||||
case BTC_AV_SINK_API_REG_DATA_CB_EVT: {
|
||||
@@ -1407,7 +1444,9 @@ void btc_a2dp_call_handler(btc_msg_t *msg)
|
||||
}
|
||||
case BTC_AV_SRC_API_DISCONNECT_EVT: {
|
||||
CHECK_BTAV_INIT();
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_DISCONNECT_REQ_EVT, NULL);
|
||||
btc_av_disconn_req_t disconn_req;
|
||||
memcpy(&disconn_req.target_bda, &arg->src_disconn, sizeof(bt_bdaddr_t));
|
||||
btc_sm_dispatch(btc_av_cb.sm_handle, BTC_AV_DISCONNECT_REQ_EVT, &disconn_req);
|
||||
break;
|
||||
}
|
||||
case BTC_AV_SRC_API_REG_DATA_CB_EVT: {
|
||||
@@ -1472,7 +1511,15 @@ static bt_status_t btc_a2d_sink_connect(bt_bdaddr_t *remote_bda)
|
||||
|
||||
static void btc_a2d_sink_deinit(void)
|
||||
{
|
||||
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||
g_a2dp_sink_ongoing_deinit = true;
|
||||
if (btc_av_is_connected()) {
|
||||
BTA_AvClose(btc_av_cb.bta_handle);
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC && g_av_with_rc == true) {
|
||||
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||
}
|
||||
} else {
|
||||
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
@@ -1497,7 +1544,15 @@ static bt_status_t btc_a2d_src_init(void)
|
||||
|
||||
static void btc_a2d_src_deinit(void)
|
||||
{
|
||||
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
g_a2dp_source_ongoing_deinit = true;
|
||||
if (btc_av_is_connected()) {
|
||||
BTA_AvClose(btc_av_cb.bta_handle);
|
||||
if (btc_av_cb.peer_sep == AVDT_TSEP_SNK && g_av_with_rc == true) {
|
||||
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||
}
|
||||
} else {
|
||||
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||
}
|
||||
}
|
||||
|
||||
static bt_status_t btc_a2d_src_connect(bt_bdaddr_t *remote_bda)
|
||||
|
||||
@@ -424,6 +424,14 @@ static void btc_avrc_ct_init(void)
|
||||
BTC_TRACE_DEBUG("## %s ##", __FUNCTION__);
|
||||
|
||||
memset (&btc_rc_vb, 0, sizeof(btc_rc_vb));
|
||||
|
||||
if (!g_av_with_rc) {
|
||||
g_av_with_rc = true;
|
||||
}
|
||||
if (g_a2dp_on_init) {
|
||||
BTC_TRACE_WARNING("AVRC Controller is expected to be initialized in advance of A2DP !!!");
|
||||
}
|
||||
|
||||
btc_rc_vb.rc_vol_label = MAX_LABEL;
|
||||
btc_rc_vb.rc_volume = MAX_VOLUME;
|
||||
}
|
||||
@@ -442,6 +450,13 @@ static void btc_avrc_ct_deinit(void)
|
||||
{
|
||||
BTC_TRACE_API("## %s ##", __FUNCTION__);
|
||||
|
||||
if (g_a2dp_on_deinit) {
|
||||
BTC_TRACE_WARNING("A2DP already deinit, AVRC CT shuold deinit in advance of A2DP !!!");
|
||||
}
|
||||
if (g_av_with_rc) {
|
||||
g_av_with_rc = false;
|
||||
}
|
||||
|
||||
memset(&btc_rc_vb, 0, sizeof(btc_rc_cb_t));
|
||||
BTC_TRACE_API("## %s ## completed", __FUNCTION__);
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ static void btc_to_bta_adv_data(esp_ble_adv_data_t *p_adv_data, tBTA_BLE_ADV_DAT
|
||||
if (NULL != p_elem) {
|
||||
memcpy(p_elem++, p_elem_service_data, sizeof(tBTA_BLE_PROP_ELEM));
|
||||
}
|
||||
osi_free(p_elem_service_data);
|
||||
}
|
||||
osi_free(p_elem_service_data);
|
||||
}
|
||||
|
||||
if (p_adv_data->service_uuid_len && p_adv_data->p_service_uuid) {
|
||||
@@ -290,7 +290,7 @@ static void btc_adv_data_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -309,7 +309,7 @@ static void btc_scan_rsp_data_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -328,7 +328,7 @@ static void btc_adv_data_raw_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -347,7 +347,7 @@ static void btc_scan_rsp_data_raw_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -392,7 +392,7 @@ static void btc_start_adv_callback(uint8_t status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -411,7 +411,7 @@ static void btc_stop_adv_callback(uint8_t status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -430,7 +430,7 @@ void btc_update_duplicate_exceptional_list_callback(tBTA_STATUS status, uint8_t
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -511,7 +511,7 @@ static void btc_scan_params_callback(tGATT_IF gatt_if, tBTM_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -550,7 +550,7 @@ static void btc_ble_set_scan_params(esp_ble_scan_params_t *scan_params, tBLE_SCA
|
||||
static void btc_search_callback(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -618,7 +618,7 @@ static void btc_start_scan_callback(uint8_t status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -637,7 +637,7 @@ static void btc_stop_scan_callback(tBTA_STATUS status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -659,7 +659,7 @@ void btc_update_conn_param_callback (UINT8 status, BD_ADDR bd_addr, tBTM_LE_UPDA
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_UPDATE_CONN_PARAMS_EVT;
|
||||
@@ -682,7 +682,7 @@ static void btc_set_pkt_length_callback(UINT8 status, tBTM_LE_SET_PKT_DATA_LENGT
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_PKT_LENGTH_COMPLETE_EVT;
|
||||
@@ -701,7 +701,7 @@ static void btc_add_whitelist_complete_callback(UINT8 status, tBTM_WL_OPERATION
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_UPDATE_WHITELIST_COMPLETE_EVT;
|
||||
@@ -719,7 +719,7 @@ static void btc_set_rand_addr_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
param.set_rand_addr_cmpl.status = btc_btm_status_to_esp_status(status); //todo status
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
@@ -737,7 +737,7 @@ static void btc_set_local_privacy_callback(UINT8 status)
|
||||
{
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_SET_LOCAL_PRIVACY_COMPLETE_EVT;
|
||||
@@ -766,7 +766,7 @@ static void btc_read_ble_rssi_cmpl_callback(void *p_data)
|
||||
tBTA_RSSI_RESULTS *result = (tBTA_RSSI_RESULTS *)p_data;
|
||||
esp_ble_gap_cb_param_t param;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = ESP_GAP_BLE_READ_RSSI_COMPLETE_EVT;
|
||||
@@ -856,22 +856,38 @@ static void btc_ble_set_rand_addr (BD_ADDR rand_addr, tBTA_SET_RAND_ADDR_CBACK *
|
||||
• The two most significant bits of the address shall be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 0
|
||||
A non-resolvable private address is a 48-bit randomly generated address and shall meet the following requirements:
|
||||
• The two most significant bits of the address shall be equal to 0
|
||||
• All bits of the random part of the address shall not be equal to 1
|
||||
• All bits of the random part of the address shall not be equal to 0
|
||||
*/
|
||||
BD_ADDR invalid_rand_addr_a, invalid_rand_addr_b;
|
||||
memset(invalid_rand_addr_a, 0xff, sizeof(BD_ADDR));
|
||||
memset(invalid_rand_addr_b, 0x00, sizeof(BD_ADDR));
|
||||
invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK;
|
||||
if((rand_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK
|
||||
&& memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0
|
||||
&& memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0){
|
||||
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
|
||||
} else {
|
||||
|
||||
if((rand_addr[0] & BT_STATIC_RAND_ADDR_MASK) == BT_STATIC_RAND_ADDR_MASK) {
|
||||
invalid_rand_addr_b[0] = invalid_rand_addr_b[0] | BT_STATIC_RAND_ADDR_MASK;
|
||||
if (memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0 && memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0) {
|
||||
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
BTC_TRACE_ERROR("Invalid static random address, the high bit should be 0b11, bits of the random part shall not be all 1 or 0");
|
||||
}
|
||||
} else if ((rand_addr[0] | BT_NON_RPA_MASK) == BT_NON_RPA_MASK) {
|
||||
invalid_rand_addr_a[0] = invalid_rand_addr_a[0] & BT_NON_RPA_MASK;
|
||||
if (memcmp(invalid_rand_addr_a, rand_addr, BD_ADDR_LEN) != 0 && memcmp(invalid_rand_addr_b, rand_addr, BD_ADDR_LEN) != 0) {
|
||||
BTA_DmSetRandAddress(rand_addr, btc_set_rand_addr_callback);
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
BTC_TRACE_ERROR("Invalid non-resolvable private address, the high bit should be 0b00, bits of the random part shall not be all 1 or 0");
|
||||
}
|
||||
}else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
BTC_TRACE_ERROR("Invalid random address, the high bit should be 0b11, bits of the random part shall not be all 1 or 0");
|
||||
BTC_TRACE_ERROR("Invalid random address type");
|
||||
}
|
||||
} else {
|
||||
btc_set_rand_addr_callback(BTM_INVALID_STATIC_RAND_ADDR);
|
||||
BTC_TRACE_ERROR("Invalid random addressm, the address value is NULL");
|
||||
BTC_TRACE_ERROR("Invalid address, the address value is NULL");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1120,7 +1136,7 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
BTA_DmUpdateWhiteList(arg->update_white_list.add_remove, arg->update_white_list.remote_bda, btc_add_whitelist_complete_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_READ_RSSI:
|
||||
BTA_DmBleReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
BTA_DmReadRSSI(arg->read_rssi.remote_addr, BTA_TRANSPORT_LE, btc_read_ble_rssi_cmpl_callback);
|
||||
break;
|
||||
case BTC_GAP_BLE_ACT_SET_CONN_PARAMS:
|
||||
BTA_DmSetBlePrefConnParams(arg->set_conn_params.bd_addr, arg->set_conn_params.min_conn_int,
|
||||
@@ -1220,6 +1236,12 @@ void btc_gap_ble_call_handler(btc_msg_t *msg)
|
||||
bta_dm_co_ble_oob_support(enable);
|
||||
break;
|
||||
}
|
||||
case ESP_BLE_APP_ENC_KEY_SIZE: {
|
||||
uint8_t key_size = 0;
|
||||
STREAM_TO_UINT8(key_size, value);
|
||||
bta_dm_co_ble_set_appl_enc_key_size(key_size);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ static void btc_gap_bt_read_rssi_delta_cmpl_callback(void *p_data)
|
||||
|
||||
static void btc_gap_bt_read_rssi_delta(btc_gap_bt_args_t *arg)
|
||||
{
|
||||
BTA_DmBleReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
BTA_DmReadRSSI(arg->read_rssi_delta.bda.address, BTA_TRANSPORT_BR_EDR, btc_gap_bt_read_rssi_delta_cmpl_callback);
|
||||
}
|
||||
|
||||
static esp_err_t btc_gap_bt_remove_bond_device(btc_gap_bt_args_t *arg)
|
||||
@@ -852,6 +852,7 @@ void btc_gap_bt_cb_deep_free(btc_msg_t *msg)
|
||||
case BTC_GAP_BT_READ_RSSI_DELTA_EVT:
|
||||
case BTC_GAP_BT_AUTH_CMPL_EVT:
|
||||
case BTC_GAP_BT_PIN_REQ_EVT:
|
||||
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:
|
||||
#if (BT_SSP_INCLUDED == TRUE)
|
||||
case BTC_GAP_BT_CFM_REQ_EVT:
|
||||
case BTC_GAP_BT_KEY_NOTIF_EVT:
|
||||
@@ -905,6 +906,10 @@ void btc_gap_bt_cb_handler(btc_msg_t *msg)
|
||||
break;
|
||||
}
|
||||
#endif ///BT_SSP_INCLUDED == TRUE
|
||||
case BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT:{
|
||||
btc_gap_bt_cb_to_app(ESP_BT_GAP_REMOVE_BOND_DEV_COMPLETE_EVT,(esp_bt_gap_cb_param_t *)msg->arg);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
BTC_TRACE_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
|
||||
@@ -121,14 +121,14 @@ static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
tBTA_GATTC *p_dest_data = (tBTA_GATTC *) p_dest;
|
||||
tBTA_GATTC *p_src_data = (tBTA_GATTC *) p_src;
|
||||
|
||||
if (!p_src_data || !p_dest_data) {
|
||||
if (!p_src_data || !p_dest_data || !msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate buffer for request data if necessary
|
||||
switch (msg->act) {
|
||||
case BTA_GATTC_READ_DESCR_EVT:
|
||||
case BTA_GATTC_READ_CHAR_EVT:
|
||||
case BTA_GATTC_READ_CHAR_EVT:
|
||||
case BTA_GATTC_READ_MULTIPLE_EVT: {
|
||||
if (p_src_data->read.p_value && p_src_data->read.p_value->p_value) {
|
||||
p_dest_data->read.p_value = (tBTA_GATT_UNFMT *)osi_malloc(sizeof(tBTA_GATT_UNFMT) + p_src_data->read.p_value->len);
|
||||
@@ -164,7 +164,7 @@ static void btc_gattc_free_req_data(btc_msg_t *msg)
|
||||
tBTA_GATTC *arg = (tBTA_GATTC *)(msg->arg);
|
||||
switch (msg->act) {
|
||||
case BTA_GATTC_READ_DESCR_EVT:
|
||||
case BTA_GATTC_READ_CHAR_EVT:
|
||||
case BTA_GATTC_READ_CHAR_EVT:
|
||||
case BTA_GATTC_READ_MULTIPLE_EVT: {
|
||||
if (arg->read.p_value) {
|
||||
osi_free(arg->read.p_value);
|
||||
@@ -186,7 +186,7 @@ static void btc_gattc_free_req_data(btc_msg_t *msg)
|
||||
static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
{
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg= {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
@@ -613,6 +613,14 @@ static void btc_gattc_read_char_descr(btc_ble_gattc_args_t *arg)
|
||||
BTA_GATTC_ReadCharDescr(arg->read_descr.conn_id, arg->read_descr.handle, arg->read_descr.auth_req);
|
||||
}
|
||||
|
||||
|
||||
static void btc_gattc_read_by_type(btc_ble_gattc_args_t *arg)
|
||||
{
|
||||
tBT_UUID uuid;
|
||||
btc_to_bta_uuid(&uuid, &(arg->read_by_type.uuid));
|
||||
BTA_GATTC_Read_by_type(arg->read_by_type.conn_id, arg->read_by_type.s_handle, arg->read_by_type.e_handle, &uuid, arg->read_by_type.auth_req);
|
||||
}
|
||||
|
||||
static void btc_gattc_write_char(btc_ble_gattc_args_t *arg)
|
||||
{
|
||||
BTA_GATTC_WriteCharValue(arg->write_char.conn_id,
|
||||
@@ -724,6 +732,9 @@ void btc_gattc_call_handler(btc_msg_t *msg)
|
||||
case BTC_GATTC_ACT_READ_CHAR_DESCR:
|
||||
btc_gattc_read_char_descr(arg);
|
||||
break;
|
||||
case BTC_GATTC_ACT_READ_BY_TYPE:
|
||||
btc_gattc_read_by_type(arg);
|
||||
break;
|
||||
case BTC_GATTC_ACT_WRITE_CHAR:
|
||||
btc_gattc_write_char(arg);
|
||||
break;
|
||||
@@ -898,6 +909,9 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
gattc_if = connect->client_if;
|
||||
param.connect.conn_id = BTC_GATT_GET_CONN_ID(connect->conn_id);
|
||||
memcpy(param.connect.remote_bda, connect->remote_bda, sizeof(esp_bd_addr_t));
|
||||
param.connect.conn_params.interval = connect->conn_params.interval;
|
||||
param.connect.conn_params.latency = connect->conn_params.latency;
|
||||
param.connect.conn_params.timeout = connect->conn_params.timeout;
|
||||
btc_gattc_cb_to_app(ESP_GATTC_CONNECT_EVT, gattc_if, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ static void btc_gatts_act_create_attr_tab(esp_gatts_attr_db_t *gatts_attr_db,
|
||||
switch(uuid)
|
||||
{
|
||||
case ESP_GATT_UUID_PRI_SERVICE:{
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_SRVC_ID srvc_id = {0};
|
||||
esp_gatt_srvc_id_t esp_srvc_id;
|
||||
|
||||
esp_srvc_id.id.inst_id = srvc_inst_id;
|
||||
@@ -571,7 +571,7 @@ static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
|
||||
static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
bt_status_t status;
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg = {0};
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
@@ -907,7 +907,9 @@ void btc_gatts_cb_handler(btc_msg_t *msg)
|
||||
gatts_if = p_data->conn.server_if;
|
||||
param.connect.conn_id = BTC_GATT_GET_CONN_ID(p_data->conn.conn_id);
|
||||
memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
|
||||
param.connect.conn_params.interval = p_data->conn.conn_params.interval;
|
||||
param.connect.conn_params.latency = p_data->conn.conn_params.latency;
|
||||
param.connect.conn_params.timeout = p_data->conn.conn_params.timeout;
|
||||
btc_gatts_cb_to_app(ESP_GATTS_CONNECT_EVT, gatts_if, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_DISCONNECT_EVT:
|
||||
|
||||
@@ -33,10 +33,21 @@
|
||||
#include "bta/bta_av_api.h"
|
||||
|
||||
#if (BTC_AV_INCLUDED == TRUE)
|
||||
|
||||
// global variable to inidcate avrc is initialized with a2dp
|
||||
extern bool g_av_with_rc;
|
||||
// global variable to indicate a2dp is initialized
|
||||
extern bool g_a2dp_on_init;
|
||||
// global variable to indicate a2dp is deinitialized
|
||||
extern bool g_a2dp_on_deinit;
|
||||
// global variable to indicate a2dp source deinitialization is ongoing
|
||||
extern bool g_a2dp_source_ongoing_deinit;
|
||||
// global variable to indicate a2dp sink deinitialization is ongoing
|
||||
extern bool g_a2dp_sink_ongoing_deinit;
|
||||
|
||||
/*******************************************************************************
|
||||
** Type definitions for callback functions
|
||||
********************************************************************************/
|
||||
|
||||
enum {
|
||||
BTC_AV_DATAPATH_OPEN_EVT, // original UIPC_OPEN_EVT for data channel in bluedroid
|
||||
BTC_AV_DATAPATH_MAX_EVT,
|
||||
@@ -77,6 +88,8 @@ typedef union {
|
||||
esp_a2d_mcc_t mcc;
|
||||
// BTC_AV_SINK_API_CONNECT_EVT
|
||||
bt_bdaddr_t connect;
|
||||
// BTC_AV_SINK_API_DISCONNECT_EVT
|
||||
bt_bdaddr_t disconn;
|
||||
// BTC_AV_SINK_API_REG_DATA_CB_EVT
|
||||
esp_a2d_sink_data_cb_t data_cb;
|
||||
#endif /* BTC_AV_SINK_INCLUDED */
|
||||
@@ -85,6 +98,8 @@ typedef union {
|
||||
esp_a2d_source_data_cb_t src_data_cb;
|
||||
// BTC_AV_SRC_API_CONNECT
|
||||
bt_bdaddr_t src_connect;
|
||||
// BTC_AV_SRC_API_DISCONNECT_EVT
|
||||
bt_bdaddr_t src_disconn;
|
||||
#endif /* BTC_AV_SRC_INCLUDED */
|
||||
// BTC_AV_API_MEDIA_CTRL_EVT
|
||||
esp_a2d_media_ctrl_t ctrl;
|
||||
|
||||
@@ -33,6 +33,7 @@ typedef enum {
|
||||
BTC_GAP_BT_KEY_NOTIF_EVT,
|
||||
BTC_GAP_BT_KEY_REQ_EVT,
|
||||
BTC_GAP_BT_READ_RSSI_DELTA_EVT,
|
||||
BTC_GAP_BT_REMOVE_BOND_DEV_COMPLETE_EVT,
|
||||
}btc_gap_bt_evt_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -30,6 +30,7 @@ typedef enum {
|
||||
BTC_GATTC_ACT_READ_CHAR,
|
||||
BTC_GATTC_ACT_READ_MULTIPLE_CHAR,
|
||||
BTC_GATTC_ACT_READ_CHAR_DESCR,
|
||||
BTC_GATTC_ACT_READ_BY_TYPE,
|
||||
BTC_GATTC_ACT_WRITE_CHAR,
|
||||
BTC_GATTC_ACT_WRITE_CHAR_DESCR,
|
||||
BTC_GATTC_ACT_PREPARE_WRITE,
|
||||
@@ -112,6 +113,14 @@ typedef union {
|
||||
uint16_t handle;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_descr;
|
||||
// BTC_GATTC_ACT_READ_BY_TYPE
|
||||
struct read_by_type_arg {
|
||||
uint16_t conn_id;
|
||||
uint16_t s_handle;
|
||||
uint16_t e_handle;
|
||||
esp_bt_uuid_t uuid;
|
||||
esp_gatt_auth_req_t auth_req;
|
||||
} read_by_type;
|
||||
//BTC_GATTC_ACT_WRITE_CHAR,
|
||||
struct write_char_arg {
|
||||
uint16_t conn_id;
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
|
||||
#define ESP_SPP_RINGBUF_SIZE 1000
|
||||
|
||||
#define BTC_SPP_INVALID_SCN 0x00
|
||||
|
||||
typedef enum {
|
||||
BTC_SPP_ACT_INIT = 0,
|
||||
BTC_SPP_ACT_UNINIT,
|
||||
@@ -35,6 +37,7 @@ typedef enum {
|
||||
BTC_SPP_ACT_CONNECT,
|
||||
BTC_SPP_ACT_DISCONNECT,
|
||||
BTC_SPP_ACT_START_SRV,
|
||||
BTC_SPP_ACT_STOP_SRV,
|
||||
BTC_SPP_ACT_WRITE,
|
||||
} btc_spp_act_t;
|
||||
|
||||
@@ -73,6 +76,10 @@ typedef union {
|
||||
UINT8 max_session;
|
||||
char name[ESP_SPP_SERVER_NAME_MAX + 1];
|
||||
} start_srv;
|
||||
//BTC_SPP_ACT_STOP_SRV
|
||||
struct stop_srv_arg {
|
||||
UINT8 scn;
|
||||
} stop_srv;
|
||||
//BTC_SPP_ACT_WRITE
|
||||
struct write_arg {
|
||||
UINT32 handle;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,12 @@
|
||||
|
||||
#endif /* #if CONFIG_CLASSIC_BT_ENABLED */
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#if (VND_BT_JV_BTA_L2CAP == TRUE)
|
||||
#define BTA_JV_L2CAP_INCLUDED TRUE
|
||||
#define GAP_CONN_INCLUDED TRUE
|
||||
#endif /* VND_BT_JV_BTA_L2CAP */
|
||||
|
||||
#ifndef CLASSIC_BT_INCLUDED
|
||||
#define CLASSIC_BT_INCLUDED FALSE
|
||||
#endif /* CLASSIC_BT_INCLUDED */
|
||||
@@ -125,6 +131,12 @@
|
||||
#define GATTC_INCLUDED FALSE
|
||||
#endif /* CONFIG_GATTC_ENABLE */
|
||||
|
||||
#if (CONFIG_GATTS_BLUFI_ENABLE)
|
||||
#define BLUFI_INCLUDED TRUE
|
||||
#else
|
||||
#define BLUFI_INCLUDED FALSE
|
||||
#endif /* UC_BT_BLUFI_ENABLE */
|
||||
|
||||
#if (CONFIG_GATTC_ENABLE && CONFIG_GATTC_CACHE_NVS_FLASH)
|
||||
#define GATTC_CACHE_NVS TRUE
|
||||
#else
|
||||
@@ -293,6 +305,19 @@
|
||||
#define BTA_SDP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#ifndef VND_BT_JV_BTA_L2CAP
|
||||
#define VND_BT_JV_BTA_L2CAP FALSE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_JV_L2CAP_INCLUDED
|
||||
#define BTA_JV_L2CAP_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
#ifndef GAP_CONN_INCLUDED
|
||||
#define GAP_CONN_INCLUDED FALSE
|
||||
#endif
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
** Stack-layer components
|
||||
@@ -1341,7 +1366,7 @@
|
||||
|
||||
/* The maximum number of ports supported. */
|
||||
#ifndef MAX_RFC_PORTS
|
||||
#define MAX_RFC_PORTS 16 /*max is 30*/
|
||||
#define MAX_RFC_PORTS 8 /*max is 30*/
|
||||
#endif
|
||||
|
||||
/* The maximum simultaneous links to different devices. */
|
||||
@@ -1710,15 +1735,6 @@ Range: 2 octets
|
||||
#define GAP_INCLUDED TRUE
|
||||
#endif
|
||||
|
||||
/* This is set to enable use of GAP L2CAP connections. */
|
||||
#ifndef GAP_CONN_INCLUDED
|
||||
#if (GAP_INCLUDED == TRUE && CLASSIC_BT_INCLUDED == TRUE)
|
||||
#define GAP_CONN_INCLUDED TRUE
|
||||
#else
|
||||
#define GAP_CONN_INCLUDED FALSE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* This is set to enable posting event for data write */
|
||||
#ifndef GAP_CONN_POST_EVT_INCLUDED
|
||||
#define GAP_CONN_POST_EVT_INCLUDED FALSE
|
||||
|
||||
@@ -34,6 +34,7 @@ typedef struct {
|
||||
UINT8 ble_min_key_size;
|
||||
UINT8 ble_accept_auth_enable;
|
||||
UINT8 oob_support;
|
||||
UINT8 ble_appl_enc_key_size;
|
||||
#endif
|
||||
|
||||
} tBTE_APPL_CFG;
|
||||
|
||||
@@ -197,30 +197,16 @@ task_post_status_t hci_hal_h4_task_post(task_post_t timeout)
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
static void hci_packet_complete(BT_HDR *packet){
|
||||
uint8_t type, num_handle;
|
||||
uint8_t type;
|
||||
uint16_t handle;
|
||||
uint16_t handles[MAX_L2CAP_LINKS + 4];
|
||||
uint16_t num_packets[MAX_L2CAP_LINKS + 4];
|
||||
uint16_t num_packets = 1;
|
||||
uint8_t *stream = packet->data + packet->offset;
|
||||
tL2C_LCB *p_lcb = NULL;
|
||||
|
||||
STREAM_TO_UINT8(type, stream);
|
||||
if (type == DATA_TYPE_ACL/* || type == DATA_TYPE_SCO*/) {
|
||||
STREAM_TO_UINT16(handle, stream);
|
||||
handle = handle & HCI_DATA_HANDLE_MASK;
|
||||
p_lcb = l2cu_find_lcb_by_handle(handle);
|
||||
if (p_lcb) {
|
||||
p_lcb->completed_packets++;
|
||||
}
|
||||
if (esp_vhci_host_check_send_available()){
|
||||
num_handle = l2cu_find_completed_packets(handles, num_packets);
|
||||
if (num_handle > 0){
|
||||
btsnd_hcic_host_num_xmitted_pkts (num_handle, handles, num_packets);
|
||||
}
|
||||
} else {
|
||||
//Send HCI_Host_Number_of_Completed_Packets next time.
|
||||
}
|
||||
|
||||
btsnd_hcic_host_num_xmitted_pkts(1, &handle, &num_packets);
|
||||
}
|
||||
}
|
||||
#endif ///C2H_FLOW_CONTROL_INCLUDED == TRUE
|
||||
@@ -229,7 +215,7 @@ bool host_recv_adv_packet(BT_HDR *packet)
|
||||
{
|
||||
assert(packet);
|
||||
if(packet->data[0] == DATA_TYPE_EVENT && packet->data[1] == HCI_BLE_EVENT) {
|
||||
if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT
|
||||
if(packet->data[3] == HCI_BLE_ADV_PKT_RPT_EVT
|
||||
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
|
||||
|| packet->data[3] == HCI_BLE_ADV_DISCARD_REPORT_EVT
|
||||
#endif
|
||||
@@ -263,11 +249,12 @@ static void hci_hal_h4_hdl_rx_packet(BT_HDR *packet)
|
||||
{
|
||||
uint8_t type, hdr_size;
|
||||
uint16_t length;
|
||||
uint8_t *stream = packet->data + packet->offset;
|
||||
uint8_t *stream = NULL;
|
||||
|
||||
if (!packet) {
|
||||
return;
|
||||
}
|
||||
stream = packet->data + packet->offset;
|
||||
|
||||
#if (C2H_FLOW_CONTROL_INCLUDED == TRUE)
|
||||
hci_packet_complete(packet);
|
||||
|
||||
@@ -116,7 +116,6 @@
|
||||
|
||||
#if BTA_JV_INCLUDED==TRUE
|
||||
#include "bta_jv_int.h"
|
||||
tBTA_JV_CB *bta_jv_cb_ptr = NULL;
|
||||
#endif
|
||||
|
||||
#if BTA_HL_INCLUDED == TRUE
|
||||
@@ -332,8 +331,10 @@ void BTE_DeinitStack(void)
|
||||
bta_sdp_cb_ptr = NULL;
|
||||
#endif
|
||||
#if (defined BTA_JV_INCLUDED && BTA_JV_INCLUDED == TRUE)
|
||||
osi_free(bta_jv_cb_ptr);
|
||||
bta_jv_cb_ptr = NULL;
|
||||
if (bta_jv_cb_ptr) {
|
||||
osi_free(bta_jv_cb_ptr);
|
||||
bta_jv_cb_ptr = NULL;
|
||||
}
|
||||
#endif //JV
|
||||
#if (defined BTA_HF_INCLUDED && BTA_HF_INCLUDED == TRUE)
|
||||
osi_free(bta_hf_client_cb_ptr);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user